From 3dd804598f913af842955f6dcc34708ff0df69d4 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 11:52:38 -0500 Subject: [PATCH 01/19] Every open pull request has a record and one state, read by the merge gates and the new pull requests view A durable record per open pull request in the team's connected repositories, written from the webhooks already received for every author and kept honest by a bounded GraphQL sync under the shared GitHub budget (sweep:dashboard_prs). One function (pr_needs::decide) decides each pull request's state, its turn and what it needs next from whom; the run's watch stores its standing and the reviewer's auto-merge gate merges only what it calls ready. GET /api/prs and GET /api/prs/detail serve the dashboard's pull requests page under the "view" capability. Incident case xw holds it. --- .../xw_every_open_pr_has_one_state.md | 5 + docs/pull-requests.md | 33 + services/common/contract/worker_messages.json | 1 + services/common/src/dlq.rs | 2 + services/common/src/github_budget.rs | 7 +- services/common/src/lib.rs | 3 + services/common/src/messages.rs | 13 + services/common/src/pr_needs.rs | 1470 ++++++++++++++++ services/common/src/pr_record.rs | 1545 +++++++++++++++++ services/common/src/pr_view.rs | 1045 +++++++++++ services/gateway/src/main.rs | 2 + services/gateway/src/permissions.rs | 2 + services/gateway/src/routes/github_webhook.rs | 37 +- services/gateway/src/routes/mod.rs | 1 + services/gateway/src/routes/prs.rs | 600 +++++++ services/worker/src/main.rs | 13 + services/worker/src/passes/await_merge.rs | 72 + .../passes/incidents/bm_teams_never_cross.rs | 1 + .../xw_every_open_pr_has_one_state.rs | 331 ++++ services/worker/src/passes/mod.rs | 1 + services/worker/src/passes/pr_records.rs | 227 +++ services/worker/src/passes/pr_watch.rs | 4 +- 22 files changed, 5411 insertions(+), 4 deletions(-) create mode 100644 docs/incidents/xw_every_open_pr_has_one_state.md create mode 100644 docs/pull-requests.md create mode 100644 services/common/src/pr_needs.rs create mode 100644 services/common/src/pr_record.rs create mode 100644 services/common/src/pr_view.rs create mode 100644 services/gateway/src/routes/prs.rs create mode 100644 services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs create mode 100644 services/worker/src/passes/pr_records.rs diff --git a/docs/incidents/xw_every_open_pr_has_one_state.md b/docs/incidents/xw_every_open_pr_has_one_state.md new file mode 100644 index 000000000..d2c4d511c --- /dev/null +++ b/docs/incidents/xw_every_open_pr_has_one_state.md @@ -0,0 +1,5 @@ +# xw. `xw_every_open_pr_has_one_state` + +**What happened:** A team asked which pull requests were open in its repositories and what each one needed. Nothing could say. The gateway dropped every event of a pull request CoderHelm hadn't opened, the reviewer's records covered only the pull requests it reviewed and expired after 30 days, and the run page, the reviewer's auto-merge gate and the reviewer page each read what a pull request needed in their own way, so they could disagree. + +**The guarantee:** Every open pull request in the team's connected repositories has one record (`pr_record`), written from its events whoever opened it (pull request, review, comment, check run, check suite, status and push) and from a bounded sync at install and once an hour, with no expiry while it is open. Each one has exactly one state from one function (`pr_needs::decide`); one whose facts aren't known yet is `unknown`, shown and counted, never dropped. The run's watch stores the standing that function decides and the reviewer's auto-merge gate merges only what it says is ready, so the gates and the pull requests list can't disagree. The list is read under the session's team only, and a record of another team never reaches a row. diff --git a/docs/pull-requests.md b/docs/pull-requests.md new file mode 100644 index 000000000..0a78256e4 --- /dev/null +++ b/docs/pull-requests.md @@ -0,0 +1,33 @@ +# The pull requests view + +Every open pull request in a team's connected repositories, people's as much as CoderHelm's: where it is, who worked on it, the one state it is in, and what it needs next from whom. The dashboard's **Pull requests** page reads it from `GET /api/prs`. + +## The record + +One settings-table item per pull request (`pk` = team id, `sk = PRREC##`), its body a JSON document written with a version check (`services/common/src/pr_record.rs`). + +- **Written from the events CoderHelm already receives**, for every pull request: `pull_request`, `pull_request_review`, review and issue comments, `check_run`, `check_suite`, `status` and `push`. A `status` or `push` event finds its pull request through a pointer item by head commit (`PRRECHEAD#`) or branch (`PRRECREF#`). +- **Kept honest by a sync** (`services/worker/src/passes/pr_records.rs`): one GraphQL search per organization of the team's connected repositories. It fills what events don't carry (the review decision, the branch's rules, conflicts, open conversations), adds pull requests opened before the install, and removes records of pull requests no longer open (only when the search was read to its end, and never one an event touched in the last hour). +- **No expiry while open.** A closed or merged pull request is kept for three days. +- **What it holds:** the author; who worked on it (committers, reviewers, commenters, and who asked CoderHelm); requested reviewers and teams; each person's latest review; the review decision; the checks on the head against the branch's required checks; conflicts; draft; open conversations; labels; links to stacked pull requests, to the same run's other pull requests (`plan_repos`, `repo_ci`) and to the ones named under the description's Compatibility heading; CoderHelm's run; a timeline of the newest events; and the wait ledger (who held the turn, and since when). + +## One state per pull request + +`services/common/src/pr_needs.rs` decides the state from the facts, first match wins: merged, closed, in the merge queue, left the queue, CoderHelm working, needs a decision, draft, waiting on another pull request, conflicts, checks failing, changes requested, re-review, needs a reviewer, needs review, needs a code owner, open conversations, checks running, ready with auto-merge on, ready to merge. A pull request whose facts aren't known yet is **not synced yet** (`unknown`): shown and counted, never dropped. + +Each state has a turn (a person, CoderHelm, the machines, or done) and one sentence that names the block, who acts, and the rule's source when a rule is the reason (the repository's rule, CODEOWNERS, a required check, the team's own rule). "Ready" is said only when every requirement is met. + +The same function is the merge gates' decision: the run's pull request watch stores the standing it decides (`run_standing`), and the reviewer's auto-merge gate merges only what it says is ready. The list, the run page and the gate can't disagree. + +## The API + +- `GET /api/prs`: filters `org`, `repo`, `turn` (`you`, `person`, `coderhelm`, `machines`, `done`), `state`, `person`, `q`, `view` (`my_turn`, `coderhelm_working`, `needs_decision`, `ready`, `stale`); `limit` (up to 200) and `cursor`, with `next` on the response. Counts by turn, state, repository, organization and view come over the scope before the other filters. +- `GET /api/prs/detail?repo=&number=`: the row, the path to merge, the wait ledger and the timeline with CoderHelm's runs. + +Both need the "view" capability. The team is always the session's; a record of another team never reaches a row (`docs/incidents/xw_every_open_pr_has_one_state.md`). + +## Cost + +- Reading the list costs no GitHub requests: it reads the team's records, its runs on them (one batched read) and the reviewer's records, and reuses them for 10 seconds per installation and team. +- The sync spends from the installation's shared GitHub budget as `sweep:dashboard_prs`: at most 30 requests an hour, at most 10 pages of 30 pull requests per organization each time, once an hour per team and once at install. It runs only while the budget leaves the runs their share. +- Each webhook costs one read and one write of its record. diff --git a/services/common/contract/worker_messages.json b/services/common/contract/worker_messages.json index cf2dceb2e..4c6047dba 100644 --- a/services/common/contract/worker_messages.json +++ b/services/common/contract/worker_messages.json @@ -12,6 +12,7 @@ "infra_analyze": {"type":"infra_analyze","team_id":"TEAM#team-a","triggered_by":"someone","repo":"acme/widgets"}, "resume": {"type":"resume","team_id":"TEAM#team-a","run_id":"r1","installation_id":1}, "change_wait_check": {"type":"change_wait_check","team_id":"TEAM#team-a"}, + "pr_records_sync": {"type":"pr_records_sync","team_id":"TEAM#team-a","installation_id":1}, "review": {"type":"review","team_id":"TEAM#team-a","installation_id":1,"repo_owner":"acme","repo_name":"widgets","pr_number":2,"head_sha":"abc","label":"coderhelm-review","question":"why?","trigger":"labeled","dedup_key":"d","reply_to_comment_id":6,"requested_by":"someone"}, "webhook_emit": {"type":"webhook_emit","team_id":"TEAM#team-a","event":{"id":"evt_01JBEVNT8M1N4P7Q0R3S6T9V2W","type":"run.failed","created_at":"2026-10-26T14:31:47.512Z","team_id":"TEAM#team-a","api_version":"2026-10-26","data":{"run_id":"r1"}}}, "webhook_send": {"type":"webhook_send","team_id":"TEAM#team-a","endpoint_id":"ep_01jbendpt4a7b0c3d6e9f2g5h8","event_id":"evt_01JBEVNT8M1N4P7Q0R3S6T9V2W","delivery_id":"01hzzdelivery","due_at":1792416387}, diff --git a/services/common/src/dlq.rs b/services/common/src/dlq.rs index d8fd9907d..1177ff7ad 100644 --- a/services/common/src/dlq.rs +++ b/services/common/src/dlq.rs @@ -84,6 +84,8 @@ pub const WORKER_MESSAGE_TYPES: &[&str] = &[ "role_reads_wait", // A team's runs waiting for another change read it again. "change_wait_check", + // A team's open pull requests read into their records, at install. + "pr_records_sync", // A model call's usage, held because its counters couldn't be written. "usage_record", // Knowledge sources: the scheduled sweep, and one source's sync. diff --git a/services/common/src/github_budget.rs b/services/common/src/github_budget.rs index 60797cc3c..526c44312 100644 --- a/services/common/src/github_budget.rs +++ b/services/common/src/github_budget.rs @@ -130,6 +130,10 @@ pub mod caller { pub const SWEEP_QUARANTINE: &str = "sweep:quarantine"; /// Duplicate follow-ups closing themselves. pub const SWEEP_FOLLOWUP_DEDUPE: &str = "sweep:followup_dedupe"; + /// The dashboard's pull requests view: the sync of every open pull + /// request's record (`common::pr_record`), one GraphQL search per + /// organization, at install and once an hour. + pub const SWEEP_DASHBOARD_PRS: &str = "sweep:dashboard_prs"; /// The security release's reads (a finding's pull request or run) /// while `sweep:security` is held: a few each sweep, so the release @@ -151,7 +155,7 @@ pub mod caller { (SWEEP_REVIEW, 120), (SWEEP_DRAFTS, 120), (SWEEP_PR_WATCH, 240), - (SWEEP_DEPLOYS, 270), + (SWEEP_DEPLOYS, 240), (SWEEP_REVIEW_REMINDER, 120), (SWEEP_PR_OUTCOMES, 120), (SWEEP_SKILLS, 60), @@ -166,6 +170,7 @@ pub mod caller { (SWEEP_WEEKLY, 100), (SWEEP_QUARANTINE, 90), (SWEEP_FOLLOWUP_DEDUPE, 30), + (SWEEP_DASHBOARD_PRS, 30), ]; } diff --git a/services/common/src/lib.rs b/services/common/src/lib.rs index 458b6493f..9c7a9526b 100644 --- a/services/common/src/lib.rs +++ b/services/common/src/lib.rs @@ -275,10 +275,12 @@ pub mod pr_dependency; pub mod pr_facts; /// Where each part of a description goes, and how a reader would judge it. pub mod pr_layout; +pub mod pr_needs; /// What happened to a PR CoderHelm opened, read from GitHub. pub mod pr_outcome; /// The last read of a description before it is saved, verified. pub mod pr_reader; +pub mod pr_record; /// The final read of a description before it is posted. pub mod pr_review; /// The work around a pull request that is not in its diff, each step with @@ -286,6 +288,7 @@ pub mod pr_review; pub mod pr_steps; /// A repository's pull request template as the description's structure. pub mod pr_template; +pub mod pr_view; pub mod preview; pub mod preview_access; pub mod preview_find; diff --git a/services/common/src/messages.rs b/services/common/src/messages.rs index a3915979f..cc0cb05f7 100644 --- a/services/common/src/messages.rs +++ b/services/common/src/messages.rs @@ -243,6 +243,10 @@ pub enum WorkerMessage { /// dependency again (the self-heal sweep checks every 15 minutes too). #[serde(rename = "change_wait_check")] ChangeWaitCheck(ChangeWaitCheckMessage), + /// Read a team's open pull requests into their records + /// (`pr_record`): at install, and when repositories are added. + #[serde(rename = "pr_records_sync")] + PrRecordsSync(PrRecordsSyncMessage), /// One plugin run: a brief, a schedule or a release (see /// `plugins::run`). #[serde(rename = "plugin_run")] @@ -518,6 +522,7 @@ impl WorkerMessage { | WorkerMessage::RunWaiting(_) | WorkerMessage::RoleReadsWait(_) | WorkerMessage::ChangeWaitCheck(_) + | WorkerMessage::PrRecordsSync(_) | WorkerMessage::StackMerged(_) | WorkerMessage::LogAutofix | WorkerMessage::AwsPermissionsSweep @@ -601,6 +606,7 @@ impl WorkerMessage { | WorkerMessage::RunWaiting(_) | WorkerMessage::RoleReadsWait(_) | WorkerMessage::ChangeWaitCheck(_) + | WorkerMessage::PrRecordsSync(_) | WorkerMessage::StackMerged(_) | WorkerMessage::PluginRun(_) | WorkerMessage::PluginPublish(_) @@ -948,6 +954,13 @@ pub struct RunWaitingMessage { pub why: String, } +/// Read a team's open pull requests into their records. +#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)] +pub struct PrRecordsSyncMessage { + pub team_id: String, + pub installation_id: u64, +} + /// Read again the dependency of a team's runs waiting for another change. #[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)] pub struct ChangeWaitCheckMessage { diff --git a/services/common/src/pr_needs.rs b/services/common/src/pr_needs.rs new file mode 100644 index 000000000..4823cd85f --- /dev/null +++ b/services/common/src/pr_needs.rs @@ -0,0 +1,1470 @@ +//! What an open pull request needs next, and from whom: one state, one +//! turn, one sentence. Any pull request in the team's repositories, people's +//! as much as CoderHelm's. +//! +//! The run page once had a standing for CoderHelm's own pull requests +//! ([`merge_standing`]) and the reviewer's auto-merge gate had its own +//! decision (`await_merge::decide_gate`), while a person's pull request +//! CoderHelm never touched had no answer at all. A list of every open pull +//! request built a third reading would have said "ready" where the gate +//! held, or "needs review" where the run page said CoderHelm merges it. +//! +//! [`decide`] is the one reading. It takes the facts in the order they hold +//! the merge, first match wins, and returns exactly one [`State`] with its +//! [`Turn`] and a [`Next`] that names the block, who acts, and the source of +//! the rule when a rule is the reason (the repository's rule, CODEOWNERS, a +//! required check, the team's own rule). No fact set falls through: what +//! isn't known yet is [`State::Unknown`], shown, never dropped. +//! +//! - For CoderHelm's own pull request with a run, the standing is +//! [`merge_standing::decide`]'s (the worker's pull request watch stores +//! [`Needs::standing`] from here), so the run page, the gate and the list +//! read one decision. +//! - The reviewer's auto-merge gate merges only when [`decide`] says the +//! pull request is ready (`await_merge::decide_gate`). +//! - A typed hand-off ([`crate::person_only::PersonOnly`]) is shown as the +//! line it is; CoderHelm's own limit ([`crate::person_only::OwnProblem`]) +//! stays CoderHelm's turn, never a person's to-do. + +use serde::{Deserialize, Serialize}; + +use crate::merge_standing::{self, Standing}; + +/// The one state a pull request is in, in the order [`decide`] tries them. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +pub enum State { + #[serde(rename = "merged")] + Merged, + #[serde(rename = "closed")] + Closed, + #[serde(rename = "in_queue")] + InQueue, + #[serde(rename = "left_queue")] + LeftQueue, + #[serde(rename = "coderhelm_working")] + CoderHelmWorking, + #[serde(rename = "needs_decision")] + NeedsDecision, + #[serde(rename = "draft")] + Draft, + #[serde(rename = "waiting_on_pr")] + WaitingOnPr, + #[serde(rename = "conflicts")] + Conflicts, + #[serde(rename = "checks_failing")] + ChecksFailing, + #[serde(rename = "changes_requested")] + ChangesRequested, + #[serde(rename = "re_review")] + ReReview, + #[serde(rename = "needs_reviewer")] + NeedsReviewer, + #[serde(rename = "needs_review")] + NeedsReview, + #[serde(rename = "needs_code_owner")] + NeedsCodeOwner, + #[serde(rename = "open_threads")] + OpenThreads, + #[serde(rename = "checks_running")] + ChecksRunning, + #[serde(rename = "ready_auto_merge")] + ReadyAutoMerge, + #[serde(rename = "ready_to_merge")] + ReadyToMerge, + #[serde(rename = "unknown")] + Unknown, +} + +/// Every state, in precedence order. +pub const ALL: &[State] = &[ + State::Merged, + State::Closed, + State::InQueue, + State::LeftQueue, + State::CoderHelmWorking, + State::NeedsDecision, + State::Draft, + State::WaitingOnPr, + State::Conflicts, + State::ChecksFailing, + State::ChangesRequested, + State::ReReview, + State::NeedsReviewer, + State::NeedsReview, + State::NeedsCodeOwner, + State::OpenThreads, + State::ChecksRunning, + State::ReadyAutoMerge, + State::ReadyToMerge, + State::Unknown, +]; + +impl State { + /// The stable code (the API's `state`). + pub fn code(self) -> &'static str { + match self { + State::Merged => "merged", + State::Closed => "closed", + State::InQueue => "in_queue", + State::LeftQueue => "left_queue", + State::CoderHelmWorking => "coderhelm_working", + State::NeedsDecision => "needs_decision", + State::Draft => "draft", + State::WaitingOnPr => "waiting_on_pr", + State::Conflicts => "conflicts", + State::ChecksFailing => "checks_failing", + State::ChangesRequested => "changes_requested", + State::ReReview => "re_review", + State::NeedsReviewer => "needs_reviewer", + State::NeedsReview => "needs_review", + State::NeedsCodeOwner => "needs_code_owner", + State::OpenThreads => "open_threads", + State::ChecksRunning => "checks_running", + State::ReadyAutoMerge => "ready_auto_merge", + State::ReadyToMerge => "ready_to_merge", + State::Unknown => "unknown", + } + } + + /// The short label shown on the state chip. + pub fn label(self) -> &'static str { + match self { + State::Merged => "Merged", + State::Closed => "Closed", + State::InQueue => "In merge queue", + State::LeftQueue => "Left the queue", + State::CoderHelmWorking => "CoderHelm working", + State::NeedsDecision => "Needs a decision", + State::Draft => "Draft", + State::WaitingOnPr => "Waiting on a pull request", + State::Conflicts => "Conflicts", + State::ChecksFailing => "Checks failing", + State::ChangesRequested => "Changes requested", + State::ReReview => "Re-review", + State::NeedsReviewer => "Needs a reviewer", + State::NeedsReview => "Needs review", + State::NeedsCodeOwner => "Needs a code owner", + State::OpenThreads => "Open conversations", + State::ChecksRunning => "Checks running", + State::ReadyAutoMerge => "Ready, auto-merge on", + State::ReadyToMerge => "Ready to merge", + State::Unknown => "Not synced yet", + } + } + + pub fn from_code(code: &str) -> Option { + ALL.iter().copied().find(|s| s.code() == code) + } + + /// Ready means every requirement is met; nothing else is called ready. + pub fn is_ready(self) -> bool { + matches!(self, State::ReadyAutoMerge | State::ReadyToMerge) + } +} + +/// Who holds the next move. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +pub enum Turn { + #[serde(rename = "person")] + Person, + #[serde(rename = "coderhelm")] + CoderHelm, + #[serde(rename = "machines")] + Machines, + #[serde(rename = "done")] + Done, +} + +impl Turn { + pub fn code(self) -> &'static str { + match self { + Turn::Person => "person", + Turn::CoderHelm => "coderhelm", + Turn::Machines => "machines", + Turn::Done => "done", + } + } +} + +/// Where a rule that holds the merge is set. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Rule { + /// The repository's review rule (branch protection or a ruleset). + #[serde(rename = "repo_rule")] + RepoRule, + /// The repository's CODEOWNERS file. + #[serde(rename = "codeowners")] + Codeowners, + /// A check the branch's rules require. + #[serde(rename = "required_check")] + RequiredCheck, + /// The team's own rule in CoderHelm (auto-merge off, a person's + /// approval before CoderHelm merges). + #[serde(rename = "team_rule")] + TeamRule, + /// A branch rule GitHub enforces without naming it. + #[serde(rename = "branch_rule")] + BranchRule, +} + +impl Rule { + /// The words in brackets after the block. + pub fn words(self) -> &'static str { + match self { + Rule::RepoRule => "repo rule", + Rule::Codeowners => "CODEOWNERS", + Rule::RequiredCheck => "required check", + Rule::TeamRule => "team rule", + Rule::BranchRule => "branch rule", + } + } +} + +/// Who an actor in [`Next::from`] is: `coderhelm`, `ci`, `queue`, +/// `nobody`, `person:` or `team:/`. +pub fn person(login: &str) -> String { + format!("person:{}", login.trim_start_matches('@')) +} +pub const CODERHELM: &str = "coderhelm"; +pub const CI: &str = "ci"; +pub const QUEUE: &str = "queue"; +pub const NOBODY: &str = "nobody"; + +/// The next step: what, from whom, since when, and the rule's source. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Next { + /// Stable code: the state's code, or for CoderHelm's own pull request + /// the standing's ([`merge_standing::Standing::code`]). + pub code: String, + /// One sentence: the block first, then who. + pub text: String, + /// Who acts ([`person`], [`CODERHELM`], [`CI`], [`QUEUE`], [`NOBODY`]). + pub from: Vec, + /// When the situation began (epoch seconds; 0 when not known). + pub since: i64, + /// Where the rule is set, when a rule is the reason. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rule: Option, +} + +/// One line of the path to merge. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Step { + /// `checks`, `approvals`, `conflicts`, `threads`, `coderhelm_review`, + /// `draft`, `queue`. + pub key: String, + /// `done`, `waiting`, `blocked` or `none` (doesn't apply). + pub mark: String, + pub text: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub source: Option, +} + +/// The decision. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Needs { + pub state: State, + pub turn: Turn, + pub next: Next, + /// For CoderHelm's own pull request with its run's facts: the standing + /// the run page shows (the same decision, in its words). + pub standing: Option, +} + +/// The checks on the head. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct Checks { + /// Any check was read for the head (a check event, or the sync). + pub known: bool, + pub total: u32, + pub passed: u32, + pub failed: Vec, + pub running: Vec, + /// The checks the base branch's rules require, when read. + pub required: Vec, +} + +impl Checks { + /// Failing checks that hold the merge: the required ones when the + /// branch's list is known, every failing one when it isn't. + pub fn blocking(&self) -> (Vec, Option) { + if self.required.is_empty() { + return (self.failed.clone(), None); + } + let req: Vec = self + .failed + .iter() + .filter(|f| self.required.iter().any(|r| r.eq_ignore_ascii_case(f))) + .cloned() + .collect(); + (req, Some(Rule::RequiredCheck)) + } +} + +/// CoderHelm stopped and waits on a person through a typed hand-off. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct Stop { + /// The hand-off's code (`person_only::PersonOnly::code`, or the run's + /// `handback` reason). + pub code: String, + /// The hand-off's own line, as the run shows it. + pub text: String, + /// The person it names, when it names one. + pub person: String, +} + +/// CoderHelm's own pull request's standing: decided here from its facts +/// (the worker's watch), or as the watch stored it (the list reads it). +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum OwnStanding { + Facts(merge_standing::Facts), + Decided(Standing), +} + +/// CoderHelm's run on this pull request. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct Own { + pub run_id: String, + /// The person who asked CoderHelm (the pull request is "for" them). + pub requester: String, + /// A run or round works on it now. + pub active: bool, + /// What it does now ("fixing CI", "addressing 3 review comments"). + pub what: String, + /// The fix round, from 1; 0 when not counted. + pub round: u32, + /// The run waits on a person, through a typed hand-off. + pub stopped: Option, + /// CoderHelm met a limit of its own: its line, CoderHelm's turn. + pub own_problem: Option, + pub standing: Option, +} + +/// Everything known about one pull request. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct Facts { + /// The pull request itself was read (a webhook or the sync). + pub known: bool, + pub merged: bool, + pub closed: bool, + pub draft: bool, + pub head: String, + pub base: String, + pub author: String, + pub author_is_coderhelm: bool, + pub merged_by: String, + /// In a merge queue, with its position when known. + pub in_queue: bool, + pub queue_position: Option<(u32, u32)>, + /// Removed from the merge queue since the last push: the reason. + pub left_queue: Option, + pub own: Option, + /// CoderHelm's reviewer is reviewing the head now. + pub reviewing: bool, + /// CoderHelm's latest review verdict and the commit it is on. + pub coderhelm_verdict: Option<(String, String)>, + /// Pull requests that merge first and are still open (`owner/repo#n`). + pub waits_on: Vec, + /// `Some(true)` conflicts, `Some(false)` merges cleanly, `None` GitHub + /// hasn't said. + pub conflict: Option, + pub checks: Checks, + /// GitHub's `reviewDecision`, when read. + pub review_decision: Option, + /// People whose latest review asks for changes. + pub changes_requested_by: Vec, + /// The author pushed after the latest request for changes. + pub pushed_since_changes: bool, + /// People whose approval counts on the head. + pub approved_by: Vec, + pub requested: Vec, + pub requested_teams: Vec, + /// Approvals the repository's rule requires (0 none or not known). + pub approvals_required: u32, + /// The team's rule: a person approves before CoderHelm merges. + pub team_requires_approval: bool, + pub codeowners_required: bool, + pub threads_required: bool, + pub open_threads: u32, + pub thread_authors: Vec, + /// GitHub's auto-merge is on. + pub auto_merge: bool, + /// CoderHelm's auto-merge gate is armed on it: CoderHelm merges. + pub coderhelm_merges: bool, + /// GitHub reports the merge blocked with nothing above explaining it. + pub blocked_by_rules: bool, + /// When the current situation began (epoch seconds). + pub since: i64, +} + +fn short(sha: &str) -> &str { + sha.get(..7).unwrap_or(sha) +} + +fn at(list: &[String]) -> String { + let names: Vec = list + .iter() + .map(|l| format!("@{}", l.trim_start_matches('@'))) + .collect(); + match names.len() { + 0 => String::new(), + 1 => names[0].clone(), + 2 => format!("{} and {}", names[0], names[1]), + _ => format!( + "{} and {}", + names[..names.len() - 1].join(", "), + names[names.len() - 1] + ), + } +} + +fn names(list: &[String], max: usize) -> String { + let mut out: Vec = list.iter().take(max).cloned().collect(); + if list.len() > max { + out.push(format!("{} more", list.len() - max)); + } + out.join(", ") +} + +fn rule_tag(rule: Option) -> String { + rule.map(|r| format!(" ({})", r.words())) + .unwrap_or_default() +} + +/// Turn for a list of actors: CoderHelm's when it's CoderHelm, the +/// machines' when it's CI, the queue or nobody, a person's otherwise. +pub fn turn_of(from: &[String]) -> Turn { + if from.iter().any(|f| f == CODERHELM) { + Turn::CoderHelm + } else if from + .iter() + .any(|f| f.starts_with("person:") || f.starts_with("team:")) + { + Turn::Person + } else { + Turn::Machines + } +} + +fn need(state: State, text: String, from: Vec, since: i64, rule: Option) -> Needs { + let turn = match state { + State::Merged | State::Closed => Turn::Done, + State::InQueue | State::ChecksRunning | State::ReadyAutoMerge | State::Unknown => { + Turn::Machines + } + State::CoderHelmWorking => Turn::CoderHelm, + _ => turn_of(&from), + }; + Needs { + state, + turn, + next: Next { + code: state.code().to_string(), + text, + from, + since, + rule, + }, + standing: None, + } +} + +/// The people a step is the author's: CoderHelm's when it wrote the pull +/// request for someone, the author otherwise. +fn author_from(f: &Facts) -> Vec { + if f.author_is_coderhelm { + return vec![CODERHELM.to_string()]; + } + if f.author.is_empty() { + vec![NOBODY.to_string()] + } else { + vec![person(&f.author)] + } +} + +fn author_words(f: &Facts) -> String { + if f.author_is_coderhelm { + "CoderHelm".to_string() + } else if f.author.is_empty() { + "the author".to_string() + } else { + format!("@{}", f.author) + } +} + +/// The state of `repo`'s pull request from its facts, first match wins. +pub fn decide(repo: &str, f: &Facts) -> Needs { + let mut n = decide_state(repo, f); + if n.standing.is_none() { + n.standing = f.own.as_ref().and_then(|o| own_standing(repo, o)); + } + n +} + +/// The standing of CoderHelm's own run's pull request, through [`decide`]: +/// what the worker's pull request watch stores on the run, so the run page +/// shows the decision this module makes. +pub fn run_standing(repo: &str, facts: &merge_standing::Facts) -> Standing { + let f = Facts { + known: true, + merged: facts.merged, + closed: facts.closed, + draft: facts.draft, + head: facts.head.clone(), + author_is_coderhelm: true, + own: Some(Own { + standing: Some(OwnStanding::Facts(facts.clone())), + ..Default::default() + }), + ..Default::default() + }; + decide(repo, &f) + .standing + .unwrap_or_else(|| merge_standing::decide(repo, facts)) +} + +fn decide_state(repo: &str, f: &Facts) -> Needs { + let since = f.since; + if !f.known { + return need( + State::Unknown, + "Not synced yet: CoderHelm has events for this pull request but not the pull \ + request itself; the next sync reads it." + .into(), + vec![NOBODY.into()], + since, + None, + ); + } + if f.merged { + let by = if f.merged_by.is_empty() { + String::new() + } else if f.merged_by.contains("coderhelm") { + " by CoderHelm".to_string() + } else { + format!(" by @{}", f.merged_by) + }; + return need(State::Merged, format!("Merged{by}."), vec![], since, None); + } + if f.closed { + return need( + State::Closed, + "Closed without merging.".into(), + vec![], + since, + None, + ); + } + if f.in_queue { + let pos = f + .queue_position + .map(|(p, n)| format!(": {p} of {n}")) + .unwrap_or_default(); + return need( + State::InQueue, + format!("In the merge queue{pos}; GitHub merges it when its turn comes."), + vec![QUEUE.into()], + since, + None, + ); + } + let own_active = f.own.as_ref().is_some_and(|o| o.active); + if let Some(reason) = &f.left_queue { + let (who, words) = if own_active { + ( + vec![CODERHELM.to_string()], + "CoderHelm is fixing it".to_string(), + ) + } else { + (author_from(f), format!("{} to push a fix", author_words(f))) + }; + return need( + State::LeftQueue, + format!( + "Left the merge queue: {}; {words}.", + reason.trim_end_matches('.') + ), + who, + since, + None, + ); + } + if let Some(own) = &f.own { + if own.active || own.own_problem.is_some() { + let round = if own.round > 1 { + format!(", round {}", own.round) + } else { + String::new() + }; + let what = if own.what.is_empty() { + "working on it".to_string() + } else { + own.what.clone() + }; + let text = match &own.own_problem { + Some(line) if !own.active => line.clone(), + _ => format!("CoderHelm is {what}{round}."), + }; + let mut n = need( + State::CoderHelmWorking, + text, + vec![CODERHELM.into()], + since, + None, + ); + n.standing = own_standing(repo, own); + return n; + } + if let Some(stop) = &own.stopped { + let who = [&stop.person, &own.requester, &f.author] + .into_iter() + .find(|p| !p.is_empty() && !p.contains("coderhelm")) + .map(|p| person(p)) + .unwrap_or_else(|| NOBODY.to_string()); + let rule = (stop.code == "approval").then_some(Rule::TeamRule); + let named = if who == NOBODY { + String::new() + } else { + format!( + " for {}", + at(&[who.trim_start_matches("person:").to_string()]) + ) + }; + let mut n = need( + State::NeedsDecision, + format!( + "CoderHelm stopped{named}: {}", + stop.text.trim().trim_end_matches('.').to_string() + "." + ), + vec![who], + since, + rule, + ); + n.standing = own_standing(repo, own); + return n; + } + if let Some(standing) = own_standing(repo, own) { + return from_standing(f, own, standing); + } + } + if f.reviewing { + return need( + State::CoderHelmWorking, + format!("CoderHelm is reviewing the head `{}`.", short(&f.head)), + vec![CODERHELM.into()], + since, + None, + ); + } + if f.draft { + return need( + State::Draft, + format!( + "Still a draft: {} marks it ready for review when it is.", + author_words(f) + ), + author_from(f), + since, + None, + ); + } + if !f.waits_on.is_empty() { + return need( + State::WaitingOnPr, + format!( + "Merges after {}, still open; {} follows it.", + names(&f.waits_on, 3), + author_words(f) + ), + author_from(f), + since, + None, + ); + } + if f.conflict == Some(true) { + let base = if f.base.is_empty() { + "its base" + } else { + &f.base + }; + let tail = if f.author_is_coderhelm { + "CoderHelm merges the base in and resolves them".to_string() + } else { + format!( + "{} resolves them, or asks CoderHelm with `@coderhelm fix conflicts`", + author_words(f) + ) + }; + return need( + State::Conflicts, + format!("Conflicts with `{base}`: {tail}."), + author_from(f), + since, + None, + ); + } + let (blocking, check_rule) = f.checks.blocking(); + if !blocking.is_empty() { + let tail = if f.author_is_coderhelm { + "CoderHelm fixes them".to_string() + } else { + format!( + "{} fixes them, or asks CoderHelm with `@coderhelm fix ci`", + author_words(f) + ) + }; + return need( + State::ChecksFailing, + format!( + "Checks fail on `{}`{}: {}; {tail}.", + short(&f.head), + rule_tag(check_rule), + names(&blocking, 4) + ), + author_from(f), + since, + check_rule, + ); + } + if !f.changes_requested_by.is_empty() { + if f.pushed_since_changes { + return need( + State::ReReview, + format!( + "{} pushed since the request for changes: {} reviews again.", + author_words(f), + at(&f.changes_requested_by) + ), + f.changes_requested_by.iter().map(|p| person(p)).collect(), + since, + None, + ); + } + return need( + State::ChangesRequested, + format!( + "Changes requested by {}: {} takes them.", + at(&f.changes_requested_by), + author_words(f) + ), + author_from(f), + since, + None, + ); + } + // CoderHelm's auto-merge merges only on its own approval of the head. + if f.coderhelm_merges { + match &f.coderhelm_verdict { + Some((v, sha)) if sha == &f.head && v == "APPROVE" => {} + Some((v, sha)) if sha == &f.head && v == "REQUEST_CHANGES" => { + return need( + State::ChangesRequested, + format!( + "CoderHelm's review asks for changes on `{}`: {} takes them, or asks \ + CoderHelm with `@coderhelm fix`.", + short(&f.head), + author_words(f) + ), + author_from(f), + since, + None, + ); + } + _ => { + return need( + State::CoderHelmWorking, + format!( + "CoderHelm reviews the head `{}` before its auto-merge merges it.", + short(&f.head) + ), + vec![CODERHELM.into()], + since, + None, + ); + } + } + } + // Approvals: the repository's rule, and the team's own rule when + // CoderHelm merges. + let (required, approval_rule) = if f.approvals_required > 0 { + (f.approvals_required, Some(Rule::RepoRule)) + } else if f.team_requires_approval { + (1, Some(Rule::TeamRule)) + } else if f.review_decision.as_deref() == Some("REVIEW_REQUIRED") { + (1, Some(Rule::RepoRule)) + } else { + (0, None) + }; + // GitHub's own decision is the authority on the repository's count. + let mut have = f.approved_by.len() as u32; + if f.review_decision.as_deref() == Some("APPROVED") && have > 0 { + have = have.max(required); + } + let codeowner_gap = f.codeowners_required + && f.review_decision.as_deref() == Some("REVIEW_REQUIRED") + && have >= required.max(1); + if have < required && !codeowner_gap { + let missing = required - have; + let words = merge_standing::approvals_words(missing); + let asked: Vec = f + .requested + .iter() + .map(|p| person(p)) + .chain(f.requested_teams.iter().map(|t| format!("team:{t}"))) + .collect(); + if asked.is_empty() { + return need( + State::NeedsReviewer, + format!( + "Needs {words}{} and nobody is asked to review: {} asks a reviewer.", + rule_tag(approval_rule), + author_words(f) + ), + author_from(f), + since, + approval_rule, + ); + } + let mut who: Vec = f.requested.clone(); + who.extend(f.requested_teams.iter().cloned()); + return need( + State::NeedsReview, + format!( + "Needs {words}{}: {} {} asked to review.", + rule_tag(approval_rule), + at(&who), + if who.len() == 1 { "is" } else { "are" } + ), + asked, + since, + approval_rule, + ); + } + if codeowner_gap { + let owners: Vec = f.requested_teams.clone(); + let who = if owners.is_empty() { + "a code owner of the changed files".to_string() + } else { + at(&owners) + }; + let from = if owners.is_empty() { + author_from(f) + } else { + owners.iter().map(|t| format!("team:{t}")).collect() + }; + return need( + State::NeedsCodeOwner, + format!("Needs a code owner's approval (CODEOWNERS): {who}."), + from, + since, + Some(Rule::Codeowners), + ); + } + if required == 0 && have == 0 && !f.requested.is_empty() { + let verb = if f.requested.len() == 1 { "is" } else { "are" }; + return need( + State::NeedsReview, + format!("{} {verb} asked to review.", at(&f.requested)), + f.requested.iter().map(|p| person(p)).collect(), + since, + None, + ); + } + if f.threads_required && f.open_threads > 0 { + let who = if f.thread_authors.is_empty() { + author_words(f) + } else { + at(&f.thread_authors) + }; + let from = if f.thread_authors.is_empty() { + author_from(f) + } else { + f.thread_authors.iter().map(|p| person(p)).collect() + }; + return need( + State::OpenThreads, + format!( + "{} open conversation{} hold the merge (repo rule): {who} to resolve.", + f.open_threads, + if f.open_threads == 1 { "" } else { "s" } + ), + from, + since, + Some(Rule::RepoRule), + ); + } + if !f.checks.running.is_empty() { + let done = f.checks.total.saturating_sub(f.checks.running.len() as u32); + return need( + State::ChecksRunning, + format!( + "Checks running on `{}`: {done} of {} done.", + short(&f.head), + f.checks.total.max(f.checks.running.len() as u32) + ), + vec![CI.into()], + since, + None, + ); + } + if !f.checks.known { + return need( + State::Unknown, + format!( + "Not synced yet: no check result for `{}` has reached CoderHelm; the next sync \ + reads them.", + short(&f.head) + ), + vec![NOBODY.into()], + since, + None, + ); + } + if f.conflict.is_none() { + return need( + State::Unknown, + "Not synced yet: GitHub hasn't said whether it merges cleanly; the next sync reads \ + it." + .into(), + vec![NOBODY.into()], + since, + None, + ); + } + if f.blocked_by_rules { + return need( + State::NeedsReview, + format!( + "The branch's rules still hold the merge (branch rule) and GitHub doesn't say \ + which: {} reads them on the pull request.", + author_words(f) + ), + author_from(f), + since, + Some(Rule::BranchRule), + ); + } + if f.coderhelm_merges { + return need( + State::ReadyToMerge, + "Ready to merge: every rule is met, and CoderHelm's auto-merge merges it.".into(), + vec![CODERHELM.into()], + since, + None, + ); + } + if f.auto_merge { + return need( + State::ReadyAutoMerge, + "Ready: every rule is met, and GitHub's auto-merge merges it.".into(), + vec![QUEUE.into()], + since, + None, + ); + } + need( + State::ReadyToMerge, + format!( + "Ready to merge: every rule is met; {} merges it.", + author_words(f) + ), + author_from(f), + since, + None, + ) +} + +fn own_standing(repo: &str, own: &Own) -> Option { + match own.standing.as_ref()? { + OwnStanding::Facts(facts) => Some(merge_standing::decide(repo, facts)), + OwnStanding::Decided(s) => Some(s.clone()), + } +} + +/// CoderHelm's own pull request: the standing's one reason, as a state. +fn from_standing(f: &Facts, own: &Own, s: Standing) -> Needs { + let requester = [&own.requester, &f.author] + .into_iter() + .find(|p| !p.is_empty() && !p.contains("coderhelm")) + .map(|p| person(p)); + let people = || { + let asked: Vec = f.requested.iter().map(|p| person(p)).collect(); + if !asked.is_empty() { + asked + } else { + requester + .clone() + .map(|p| vec![p]) + .unwrap_or_else(|| vec![NOBODY.to_string()]) + } + }; + let ch = || vec![CODERHELM.to_string()]; + let (state, from, rule) = match s.code.as_str() { + "merged" => (State::Merged, vec![], None), + "closed" => (State::Closed, vec![], None), + "building_plan" | "reviewing" | "fixing_review" => (State::CoderHelmWorking, ch(), None), + "conflict" => (State::Conflicts, ch(), None), + "checks_failing" => (State::ChecksFailing, ch(), None), + "review_changes_requested" => (State::ChangesRequested, ch(), None), + "checks_running" => (State::ChecksRunning, vec![CI.to_string()], None), + "draft" => (State::Draft, ch(), None), + "plan_needs_access" => (State::NeedsDecision, people(), None), + "auto_merge_off" => (State::ReadyToMerge, people(), Some(Rule::TeamRule)), + "needs_person_approval" => (State::NeedsReview, people(), Some(Rule::TeamRule)), + "repo_requires_person_review" => (State::NeedsReview, people(), Some(Rule::RepoRule)), + "merging" => (State::ReadyToMerge, ch(), None), + _ => (State::Unknown, vec![NOBODY.to_string()], None), + }; + let text = match rule { + Some(r) if !s.text.contains(r.words()) && r != Rule::RepoRule => { + format!( + "{} ({}) {}", + s.text.trim_end_matches('.'), + r.words(), + s.next + ) + } + _ => format!("{} {}", s.text, s.next), + }; + let mut n = need(state, text, from, f.since, rule); + n.next.code = s.code.clone(); + n.standing = Some(s); + n +} + +/// The path to merge: one line per requirement, from the same facts. +pub fn checklist(f: &Facts) -> Vec { + let step = |key: &str, mark: &str, text: String, source: Option| Step { + key: key.into(), + mark: mark.into(), + text, + source, + }; + let mut out = Vec::new(); + let c = &f.checks; + let (blocking, rule) = c.blocking(); + out.push(if !c.known { + step( + "checks", + "waiting", + "Checks: no result read yet".into(), + None, + ) + } else if !blocking.is_empty() { + step( + "checks", + "blocked", + format!( + "Checks {} of {} pass; failing: {}", + c.passed, + c.total, + names(&blocking, 4) + ), + rule, + ) + } else if !c.running.is_empty() { + step( + "checks", + "waiting", + format!( + "Checks {} of {} done; running: {}", + c.total.saturating_sub(c.running.len() as u32), + c.total, + names(&c.running, 4) + ), + rule, + ) + } else { + step( + "checks", + "done", + format!("Checks {} of {} pass", c.passed, c.total), + rule, + ) + }); + let (required, src) = if f.approvals_required > 0 { + (f.approvals_required, Some(Rule::RepoRule)) + } else if f.team_requires_approval { + (1, Some(Rule::TeamRule)) + } else { + (0, None) + }; + let have = f.approved_by.len() as u32; + out.push(if !f.changes_requested_by.is_empty() { + step( + "approvals", + "blocked", + format!("Changes requested by {}", at(&f.changes_requested_by)), + None, + ) + } else if required == 0 { + step( + "approvals", + if have > 0 { "done" } else { "none" }, + if have > 0 { + format!("Approved by {}", at(&f.approved_by)) + } else { + "No approval required".into() + }, + None, + ) + } else if have >= required { + step( + "approvals", + "done", + format!("Approvals {have} of {required}: {}", at(&f.approved_by)), + src, + ) + } else { + let waiting = if f.requested.is_empty() { + "nobody asked yet".to_string() + } else { + format!("waiting on {}", at(&f.requested)) + }; + step( + "approvals", + "waiting", + format!("Approvals {have} of {required}; {waiting}"), + src, + ) + }); + if f.codeowners_required { + let pending = f.review_decision.as_deref() == Some("REVIEW_REQUIRED"); + out.push(step( + "code_owners", + if pending { "waiting" } else { "done" }, + if pending { + "A code owner's approval is still needed".into() + } else { + "Code owners approved".into() + }, + Some(Rule::Codeowners), + )); + } + out.push(match f.conflict { + Some(true) => step( + "conflicts", + "blocked", + format!( + "Conflicts with `{}`", + if f.base.is_empty() { + "its base" + } else { + &f.base + } + ), + None, + ), + Some(false) => step("conflicts", "done", "No conflicts".into(), None), + None => step( + "conflicts", + "waiting", + "Conflicts: GitHub hasn't said yet".into(), + None, + ), + }); + if f.threads_required || f.open_threads > 0 { + out.push(if f.open_threads == 0 { + step( + "threads", + "done", + "Conversations resolved".into(), + f.threads_required.then_some(Rule::RepoRule), + ) + } else { + step( + "threads", + if f.threads_required { + "blocked" + } else { + "waiting" + }, + format!("{} open conversation(s)", f.open_threads), + f.threads_required.then_some(Rule::RepoRule), + ) + }); + } + if let Some((verdict, sha)) = &f.coderhelm_verdict { + let on_head = sha == &f.head; + out.push(step( + "coderhelm_review", + match (verdict.as_str(), on_head) { + ("APPROVE", true) => "done", + ("REQUEST_CHANGES", true) => "blocked", + _ => "waiting", + }, + match (verdict.as_str(), on_head) { + ("APPROVE", true) => "CoderHelm's review: approved this commit".into(), + ("REQUEST_CHANGES", true) => "CoderHelm's review: asks for changes".into(), + (_, false) => format!("CoderHelm's review is of `{}`, not the head", short(sha)), + _ => "CoderHelm's review: commented".into(), + }, + None, + )); + } + if f.draft { + out.push(step("draft", "waiting", "Still a draft".into(), None)); + } + out.push(if f.in_queue { + step("queue", "waiting", "In the merge queue".into(), None) + } else if f.coderhelm_merges { + step( + "queue", + "none", + "CoderHelm's auto-merge merges it once everything above is done".into(), + None, + ) + } else if f.auto_merge { + step("queue", "none", "GitHub's auto-merge is on".into(), None) + } else { + step("queue", "none", "Not queued; merged by hand".into(), None) + }); + out +} + +#[cfg(test)] +mod tests { + use super::*; + + const HEAD: &str = "9f8e7d6c5b4a39281706f5e4d3c2b1a098765432"; + + /// A person's pull request with every requirement met. + fn ready() -> Facts { + Facts { + known: true, + head: HEAD.into(), + base: "main".into(), + author: "octocat".into(), + conflict: Some(false), + checks: Checks { + known: true, + total: 3, + passed: 3, + ..Default::default() + }, + approvals_required: 1, + approved_by: vec!["mara".into()], + since: 1_700_000_000, + ..Default::default() + } + } + + #[test] + fn a_pull_request_with_every_rule_met_is_ready_and_names_who_merges() { + let n = decide("acme/web", &ready()); + assert_eq!(n.state, State::ReadyToMerge); + assert_eq!(n.turn, Turn::Person); + assert_eq!(n.next.from, vec!["person:octocat"]); + assert!( + n.next.text.contains("@octocat merges it"), + "{}", + n.next.text + ); + } + + #[test] + fn every_state_is_reached_and_each_has_one_turn() { + let mut seen = std::collections::BTreeSet::new(); + let mut cases: Vec = vec![Facts::default(), ready()]; + let mut push = |m: &dyn Fn(&mut Facts)| { + let mut f = ready(); + m(&mut f); + cases.push(f); + }; + push(&|f| f.merged = true); + push(&|f| f.closed = true); + push(&|f| f.in_queue = true); + push(&|f| f.left_queue = Some("tests failed on the merge commit".into())); + push(&|f| f.reviewing = true); + push(&|f| { + f.own = Some(Own { + stopped: Some(Stop { + code: "product_decision".into(), + text: "Your call: keep the old stock counts?".into(), + person: "jun".into(), + }), + ..Default::default() + }) + }); + push(&|f| f.draft = true); + push(&|f| f.waits_on = vec!["acme/api#12".into()]); + push(&|f| f.conflict = Some(true)); + push(&|f| f.checks.failed = vec!["lint".into()]); + push(&|f| f.changes_requested_by = vec!["mara".into()]); + push(&|f| { + f.changes_requested_by = vec!["mara".into()]; + f.pushed_since_changes = true + }); + push(&|f| f.approved_by.clear()); + push(&|f| { + f.approved_by.clear(); + f.requested = vec!["mara".into()] + }); + push(&|f| { + f.codeowners_required = true; + f.review_decision = Some("REVIEW_REQUIRED".into()); + f.requested_teams = vec!["acme/payments".into()] + }); + push(&|f| { + f.threads_required = true; + f.open_threads = 2 + }); + push(&|f| f.checks.running = vec!["unit".into()]); + push(&|f| f.auto_merge = true); + for f in &cases { + let n = decide("acme/web", f); + assert!(!n.next.text.is_empty(), "{n:?}"); + assert_eq!(n.next.code, n.state.code()); + seen.insert(n.state); + } + for s in ALL { + assert!(seen.contains(s), "{s:?} is never reached"); + assert_eq!(State::from_code(s.code()), Some(*s)); + } + } + + #[test] + fn what_is_not_known_yet_is_unknown_never_ready() { + let mut f = ready(); + f.conflict = None; + assert_eq!(decide("acme/web", &f).state, State::Unknown); + let mut f = ready(); + f.checks.known = false; + assert_eq!(decide("acme/web", &f).state, State::Unknown); + assert_eq!(decide("acme/web", &Facts::default()).turn, Turn::Machines); + } + + #[test] + fn a_rule_that_is_the_reason_is_named_with_its_source() { + let mut f = ready(); + f.approved_by.clear(); + f.requested = vec!["mara".into()]; + let n = decide("acme/web", &f); + assert_eq!(n.state, State::NeedsReview); + assert_eq!(n.next.rule, Some(Rule::RepoRule)); + assert!(n.next.text.contains("(repo rule)"), "{}", n.next.text); + let mut f = ready(); + f.checks.failed = vec!["lint".into()]; + f.checks.required = vec!["lint".into()]; + let n = decide("acme/web", &f); + assert!(n.next.text.contains("(required check)"), "{}", n.next.text); + // A failing check the branch doesn't require holds nothing. + f.checks.required = vec!["unit".into()]; + assert_eq!(decide("acme/web", &f).state, State::ReadyToMerge); + } + + #[test] + fn coderhelms_own_pull_request_reads_its_runs_standing() { + let mut f = ready(); + f.author = "coderhelm[bot]".into(); + f.author_is_coderhelm = true; + let standing = merge_standing::Facts { + head: HEAD.into(), + reviewer_on: true, + own_verdict: Some(("APPROVE".into(), HEAD.into())), + auto_merge: true, + require_human_approval: true, + ..Default::default() + }; + f.own = Some(Own { + requester: "octocat".into(), + standing: Some(OwnStanding::Facts(standing.clone())), + ..Default::default() + }); + let n = decide("acme/web", &f); + let s = merge_standing::decide("acme/web", &standing); + assert_eq!(n.standing.as_ref(), Some(&s)); + assert_eq!(n.next.code, "needs_person_approval"); + assert_eq!(n.state, State::NeedsReview); + assert_eq!(n.next.from, vec!["person:octocat"]); + assert_eq!(n.next.rule, Some(Rule::TeamRule)); + // The stored standing gives the same decision. + if let Some(o) = f.own.as_mut() { + o.standing = Some(OwnStanding::Decided(s)); + } + assert_eq!(decide("acme/web", &f), n); + } + + #[test] + fn coderhelms_own_limit_stays_its_turn() { + let mut f = ready(); + f.own = Some(Own { + own_problem: Some( + "CoderHelm met a limit in its tools and is taking another route".into(), + ), + ..Default::default() + }); + let n = decide("acme/web", &f); + assert_eq!(n.state, State::CoderHelmWorking); + assert_eq!(n.turn, Turn::CoderHelm); + } + + #[test] + fn a_hand_off_names_the_person_and_shows_its_own_line() { + let mut f = ready(); + f.own = Some(Own { + requester: "theo".into(), + stopped: Some(Stop { + code: "product_decision".into(), + text: "Your call: keep the old stock counts?".into(), + person: String::new(), + }), + ..Default::default() + }); + let n = decide("acme/web", &f); + assert_eq!(n.state, State::NeedsDecision); + assert_eq!(n.next.from, vec!["person:theo"]); + assert!(n + .next + .text + .contains("Your call: keep the old stock counts?")); + } + + #[test] + fn no_sentence_uses_words_the_copy_rules_ban() { + let banned = [ + "please review", + "complete manually", + "re-trigger", + "a person should", + "handed off for human review", + "mergeable", + ]; + for s in ALL { + assert!(!s.label().to_lowercase().contains("mergeable")); + } + let mut f = ready(); + for m in 0..6 { + match m { + 0 => f.draft = true, + 1 => f.conflict = Some(true), + 2 => f.checks.failed = vec!["lint".into()], + 3 => f.changes_requested_by = vec!["mara".into()], + 4 => f.blocked_by_rules = true, + _ => f.approved_by.clear(), + } + let t = decide("acme/web", &f).next.text.to_lowercase(); + for b in banned { + assert!(!t.contains(b), "{t}"); + } + } + } + + #[test] + fn the_checklist_covers_each_requirement() { + let mut f = ready(); + f.codeowners_required = true; + f.threads_required = true; + let keys: Vec = checklist(&f).into_iter().map(|s| s.key).collect(); + for k in [ + "checks", + "approvals", + "code_owners", + "conflicts", + "threads", + "queue", + ] { + assert!(keys.iter().any(|x| x == k), "{k}"); + } + } +} diff --git a/services/common/src/pr_record.rs b/services/common/src/pr_record.rs new file mode 100644 index 000000000..aa1e85f4d --- /dev/null +++ b/services/common/src/pr_record.rs @@ -0,0 +1,1545 @@ +//! One durable record per open pull request in the team's repositories, +//! people's as much as CoderHelm's, written from the GitHub events +//! CoderHelm already receives and kept honest by a bounded sync. +//! +//! The gateway once dropped every event of a pull request CoderHelm hadn't +//! opened ("Only track our PRs"), so nothing could say which pull requests +//! were open in a team's repositories, who worked on them, or what each one +//! needed next. The reviewer's and the merge gate's records cover only the +//! pull requests they handle, and they expire after 30 days. +//! +//! - One settings-table item per pull request (`pk` = team id, `sk` = +//! [`record_sk`]), its body a JSON document ([`PrRecord`]) written with a +//! version check, so two events at once never lose each other's facts. +//! - Every webhook of a pull request updates it: `pull_request`, +//! `pull_request_review`, review and issue comments, `check_run`, +//! `check_suite`, `status` and `push` (the last two find their pull +//! request through a pointer item by head commit or branch). +//! - The sync (one GraphQL search per organization, under the shared GitHub +//! budget) fills what events don't carry: the review decision, the +//! branch's rules, conflicts, open conversations; it also adds pull +//! requests opened before the install, and removes the ones no longer +//! open. +//! - No expiry while the pull request is open: a closed or merged one is +//! kept for [`CLOSED_KEEP_SECS`], so "recently merged" can be shown. +//! +//! The pure parts ([`PrRecord::apply_event`], [`PrRecord::apply_node`], +//! [`PrRecord::facts`], [`PrRecord::note_needs`]) are what the tests and the +//! incident cases drive. + +use std::collections::BTreeMap; + +use aws_sdk_dynamodb::types::AttributeValue; +use aws_sdk_dynamodb::Client as DynamoClient; +use serde::{Deserialize, Serialize}; +use serde_json::Value; + +use crate::pr_needs::{self, Facts, Needs}; + +/// Sort-key prefix of every record. +pub const SK_PREFIX: &str = "PRREC#"; +/// Pointer from a head commit to its pull request (`status` events). +pub const HEAD_PREFIX: &str = "PRRECHEAD#"; +/// Pointer from a branch to its pull request (`push` events). +pub const REF_PREFIX: &str = "PRRECREF#"; +/// How long a closed or merged pull request's record is kept. +pub const CLOSED_KEEP_SECS: i64 = 3 * 86_400; +/// How long a pointer item is kept after its last write. +pub const POINTER_KEEP_SECS: i64 = 30 * 86_400; +/// Most timeline events kept on a record (the newest). +pub const MAX_EVENTS: usize = 120; +/// Most wait-ledger spans kept on a record (the newest). +pub const MAX_SPANS: usize = 80; +/// Most check names kept for one head. +pub const MAX_CHECKS: usize = 100; + +/// Settings-table sort key of a pull request's record. +pub fn record_sk(repo: &str, number: u64) -> String { + format!("{SK_PREFIX}{repo}#{number:06}") +} + +/// `owner/repo` and the number from a record's sort key. +pub fn parse_sk(sk: &str) -> Option<(String, u64)> { + let (repo, n) = sk.strip_prefix(SK_PREFIX)?.rsplit_once('#')?; + Some((repo.to_string(), n.parse().ok()?)) +} + +pub fn head_sk(repo: &str, sha: &str) -> String { + format!("{HEAD_PREFIX}{repo}#{sha}") +} + +pub fn ref_sk(repo: &str, branch: &str) -> String { + format!("{REF_PREFIX}{repo}#{branch}") +} + +/// A GitHub login is CoderHelm's own (its app, under any install's name). +pub fn is_coderhelm(login: &str) -> bool { + login.to_ascii_lowercase().contains("coderhelm") +} + +/// One person's latest review. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct Review { + /// `APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`, `DISMISSED`. + pub state: String, + pub sha: String, + pub at: i64, +} + +/// One check on the head. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct Check { + /// `queued`, `in_progress`, `completed`. + pub status: String, + /// GitHub's conclusion once completed (`success`, `failure`, ...). + #[serde(default)] + pub conclusion: String, + pub at: i64, +} + +impl Check { + fn failed(&self) -> bool { + self.status == "completed" + && matches!( + self.conclusion.as_str(), + "failure" | "timed_out" | "startup_failure" | "action_required" | "error" + ) + } + fn running(&self) -> bool { + self.status != "completed" + } +} + +/// A link to another pull request. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct Link { + /// `stack_base` (this one is based on it), `plan` (the same run's plan, + /// in merge order), `depends` (merges after it), `contract` (named + /// under the description's Compatibility heading). + pub kind: String, + pub repo: String, + pub number: u64, +} + +/// CoderHelm's work on the pull request. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct CoderHelmLink { + /// The run that opened it or worked on it last. + #[serde(default)] + pub run_id: String, + /// The reviewer's latest session on it. + #[serde(default)] + pub session_id: String, +} + +/// One timeline event. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct Event { + pub at: i64, + /// A GitHub login, `coderhelm`, or `ci`. + pub actor: String, + /// opened, pushed, review, comment, check, queue, run, label, ready, + /// draft, merged, closed, reviewers, state. + pub kind: String, + pub text: String, + #[serde(default, skip_serializing_if = "String::is_empty")] + pub run_id: String, +} + +/// One span of the wait ledger: who held the turn from `from` until the +/// next span began. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct Span { + /// `person:`, `team:`, `coderhelm`, `ci`, `queue`, + /// `nobody` (the first actor of the step). + pub who: String, + pub state: String, + pub from: i64, +} + +/// The record's body. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct PrRecord { + pub repo: String, + pub number: u64, + /// The pull request itself was read (an event that carries it, or the + /// sync). + pub known: bool, + pub title: String, + pub url: String, + pub author: String, + /// `open`, `closed` or `merged`. + pub status: String, + pub draft: bool, + pub head_sha: String, + pub head_ref: String, + pub base_ref: String, + pub created_at: i64, + pub updated_at: i64, + pub closed_at: i64, + pub merged_by: String, + pub additions: u32, + pub deletions: u32, + pub labels: Vec, + pub requested: Vec, + pub requested_teams: Vec, + /// Each person's latest review that took a side (approved or changes), + /// or their latest comment review when they took none. + pub reviews: BTreeMap, + /// CoderHelm's latest verdict (`APPROVE`, `REQUEST_CHANGES`, `COMMENT`) + /// and the commit it is on. + pub coderhelm_verdict: Option<(String, String)>, + pub review_decision: Option, + pub approvals_required: u32, + pub codeowners_required: bool, + pub threads_required: bool, + pub required_checks: Vec, + /// The commit `checks` are for. + pub checks_sha: String, + pub checks: BTreeMap, + pub conflict: Option, + /// GitHub's `mergeStateStatus` / `mergeable_state`, lower case. + pub merge_state: String, + pub open_threads: u32, + pub thread_authors: Vec, + pub auto_merge: bool, + pub in_queue: bool, + pub left_queue: Option, + /// Who worked on it: login to roles (author, committer, reviewer, + /// commenter, requester, requested). + pub people: BTreeMap>, + /// The person who asked CoderHelm for it. + pub requester: String, + pub links: Vec, + pub coderhelm: CoderHelmLink, + pub events: Vec, + pub spans: Vec, + /// When the sync last read it (epoch seconds; 0 never). + pub synced_at: i64, + /// When an event last changed it. + pub event_at: i64, +} + +fn ts(v: &Value) -> i64 { + v.as_str() + .and_then(|s| chrono::DateTime::parse_from_rfc3339(s).ok()) + .map(|d| d.timestamp()) + .unwrap_or(0) +} + +fn s(v: &Value) -> String { + v.as_str().unwrap_or("").to_string() +} + +fn login(v: &Value) -> String { + v["login"].as_str().unwrap_or("").to_string() +} + +fn push_unique(list: &mut Vec, v: &str) { + if !v.is_empty() && !list.iter().any(|x| x.eq_ignore_ascii_case(v)) { + list.push(v.to_string()); + } +} + +/// `owner/repo#n` references under the description's `## Compatibility` +/// heading (the contracts index's link between pull requests). +pub fn compatibility_links(body: &str) -> Vec<(String, u64)> { + let mut out = Vec::new(); + let mut inside = false; + for line in body.lines() { + let t = line.trim(); + if t.starts_with('#') { + inside = t + .trim_start_matches('#') + .trim() + .eq_ignore_ascii_case("compatibility"); + continue; + } + if !inside { + continue; + } + for word in t.split(|c: char| c.is_whitespace() || "()[],;`".contains(c)) { + let word = word + .trim_start_matches("https://github.com/") + .replace("/pull/", "#"); + let Some((repo, n)) = word.rsplit_once('#') else { + continue; + }; + let ok = repo.split('/').count() == 2 + && repo + .chars() + .all(|c| c.is_ascii_alphanumeric() || "-_./".contains(c)); + if let (true, Ok(n)) = (ok, n.parse::()) { + if !out.contains(&(repo.to_string(), n)) { + out.push((repo.to_string(), n)); + } + } + } + } + out.truncate(10); + out +} + +impl PrRecord { + pub fn new(repo: &str, number: u64) -> PrRecord { + PrRecord { + repo: repo.to_string(), + number, + status: "open".into(), + ..Default::default() + } + } + + pub fn org(&self) -> &str { + self.repo.split('/').next().unwrap_or("") + } + + pub fn is_open(&self) -> bool { + self.status == "open" + } + + pub fn author_is_coderhelm(&self) -> bool { + is_coderhelm(&self.author) + } + + fn role(&mut self, who: &str, role: &str) { + if who.is_empty() { + return; + } + let who = if is_coderhelm(who) { "coderhelm" } else { who }; + let roles = self.people.entry(who.to_string()).or_default(); + if !roles.iter().any(|r| r == role) { + roles.push(role.to_string()); + } + if self.people.len() > 40 { + // Keep the author and the first people seen. + let keep: Vec = self.people.keys().take(40).cloned().collect(); + self.people.retain(|k, _| keep.contains(k)); + } + } + + fn event(&mut self, at: i64, actor: &str, kind: &str, text: String) { + let actor = if is_coderhelm(actor) { + "coderhelm".to_string() + } else { + actor.to_string() + }; + // A redelivered event is the same event. + if self + .events + .iter() + .rev() + .take(5) + .any(|e| e.at == at && e.kind == kind && e.text == text && e.actor == actor) + { + return; + } + self.events.push(Event { + at, + actor, + kind: kind.into(), + text, + run_id: String::new(), + }); + self.events.sort_by_key(|e| e.at); + if self.events.len() > MAX_EVENTS { + let cut = self.events.len() - MAX_EVENTS; + self.events.drain(..cut); + } + } + + fn new_head(&mut self, sha: &str) { + if !sha.is_empty() && sha != self.head_sha { + self.head_sha = sha.to_string(); + self.left_queue = None; + } + } + + /// The pull request object (webhook or REST shape). + fn take_pr(&mut self, pr: &Value) { + if pr["number"].as_u64().is_none() { + return; + } + self.known = true; + self.title = s(&pr["title"]); + self.url = s(&pr["html_url"]); + let author = login(&pr["user"]); + if !author.is_empty() { + self.author = author.clone(); + self.role(&author, "author"); + } + self.draft = pr["draft"].as_bool().unwrap_or(false); + let merged = pr["merged"].as_bool().unwrap_or(false) || !pr["merged_at"].is_null(); + self.status = match (pr["state"].as_str(), merged) { + (_, true) => "merged", + (Some("closed"), _) => "closed", + _ => "open", + } + .into(); + self.new_head(pr["head"]["sha"].as_str().unwrap_or("")); + self.head_ref = s(&pr["head"]["ref"]); + self.base_ref = s(&pr["base"]["ref"]); + self.created_at = ts(&pr["created_at"]); + self.updated_at = ts(&pr["updated_at"]).max(self.updated_at); + if let Some(t) = [ts(&pr["merged_at"]), ts(&pr["closed_at"])] + .into_iter() + .find(|t| *t > 0) + { + self.closed_at = t; + } + if let Some(by) = pr["merged_by"]["login"].as_str() { + self.merged_by = by.to_string(); + } + if let Some(a) = pr["additions"].as_u64() { + self.additions = a as u32; + self.deletions = pr["deletions"].as_u64().unwrap_or(0) as u32; + } + if let Some(labels) = pr["labels"].as_array() { + self.labels = labels.iter().map(|l| s(&l["name"])).collect(); + } + if let Some(r) = pr["requested_reviewers"].as_array() { + self.requested = r.iter().map(login).filter(|l| !l.is_empty()).collect(); + } + if let Some(t) = pr["requested_teams"].as_array() { + let org = self.org().to_string(); + self.requested_teams = t + .iter() + .map(|t| format!("{org}/{}", s(&t["slug"]))) + .collect(); + } + for r in self.requested.clone() { + self.role(&r, "requested"); + } + if let Some(m) = pr["mergeable"].as_bool() { + self.conflict = Some(!m); + } + if let Some(st) = pr["mergeable_state"].as_str() { + self.merge_state = st.to_ascii_lowercase(); + if st == "dirty" { + self.conflict = Some(true); + } + } + if pr.get("auto_merge").is_some() { + self.auto_merge = !pr["auto_merge"].is_null(); + } + if let Some(body) = pr["body"].as_str() { + self.links.retain(|l| l.kind != "contract"); + for (repo, n) in compatibility_links(body) { + self.links.push(Link { + kind: "contract".into(), + repo, + number: n, + }); + } + } + } + + /// Apply one GitHub webhook. Returns false when it says nothing about + /// this pull request. + pub fn apply_event(&mut self, event_type: &str, payload: &Value, now: i64) -> bool { + let action = payload["action"].as_str().unwrap_or(""); + let sender = login(&payload["sender"]); + let at = |v: &Value| { + let t = ts(v); + if t > 0 { + t + } else { + now + } + }; + match event_type { + "pull_request" => { + let pr = &payload["pull_request"]; + let before = self.head_sha.clone(); + self.take_pr(pr); + let when = at(&pr["updated_at"]); + match action { + "opened" => self.event( + at(&pr["created_at"]), + &self.author.clone(), + "opened", + "opened it".into(), + ), + "reopened" => self.event(when, &sender, "opened", "reopened it".into()), + "closed" if self.status == "merged" => { + let by = if self.merged_by.is_empty() { + sender.clone() + } else { + self.merged_by.clone() + }; + self.event(when, &by, "merged", "merged it".into()) + } + "closed" => { + self.event(when, &sender, "closed", "closed it without merging".into()) + } + "synchronize" => { + let short = self.head_sha.get(..7).unwrap_or("").to_string(); + self.role(&sender, "committer"); + self.event( + when, + &sender, + "pushed", + format!("pushed; the head is now {short}"), + ); + if before != self.head_sha { + self.checks.clear(); + self.checks_sha = self.head_sha.clone(); + } + } + "ready_for_review" => { + self.event(when, &sender, "ready", "marked it ready for review".into()) + } + "converted_to_draft" => { + self.event(when, &sender, "draft", "turned it back into a draft".into()) + } + "review_requested" => { + let who = payload["requested_reviewer"]["login"] + .as_str() + .map(|l| format!("@{l}")) + .or_else(|| { + payload["requested_team"]["slug"] + .as_str() + .map(|t| format!("@{}/{t}", self.org())) + }) + .unwrap_or_default(); + self.event(when, &sender, "reviewers", format!("asked {who} to review")) + } + "review_request_removed" => self.event( + when, + &sender, + "reviewers", + "removed a review request".into(), + ), + "labeled" => self.event( + when, + &sender, + "label", + format!("added the label `{}`", s(&payload["label"]["name"])), + ), + "unlabeled" => self.event( + when, + &sender, + "label", + format!("took the label `{}` off", s(&payload["label"]["name"])), + ), + "enqueued" => { + self.in_queue = true; + self.left_queue = None; + self.event(when, &sender, "queue", "added it to the merge queue".into()) + } + "dequeued" => { + self.in_queue = false; + let reason = payload["reason"] + .as_str() + .unwrap_or("") + .to_ascii_lowercase() + .replace('_', " "); + if self.status == "open" && reason != "merged" { + self.left_queue = Some(if reason.is_empty() { + "removed from the queue".into() + } else { + reason.clone() + }); + } + self.event( + when, + "ci", + "queue", + format!( + "left the merge queue{}", + if reason.is_empty() { + String::new() + } else { + format!(": {reason}") + } + ), + ) + } + "auto_merge_enabled" => { + self.auto_merge = true; + self.event( + when, + &sender, + "state", + "turned GitHub's auto-merge on".into(), + ) + } + "auto_merge_disabled" => { + self.auto_merge = false; + self.event( + when, + &sender, + "state", + "turned GitHub's auto-merge off".into(), + ) + } + _ => {} + } + if !self.head_sha.is_empty() && self.checks_sha.is_empty() { + self.checks_sha = self.head_sha.clone(); + } + self.event_at = now; + true + } + "pull_request_review" => { + let r = &payload["review"]; + let who = login(&r["user"]); + if who.is_empty() { + return false; + } + if !self.known { + self.take_pr(&payload["pull_request"]); + } + let state = r["state"].as_str().unwrap_or("").to_ascii_uppercase(); + let sha = s(&r["commit_id"]); + let when = at(&r["submitted_at"]); + if is_coderhelm(&who) { + let verdict = match state.as_str() { + "APPROVED" => "APPROVE", + "CHANGES_REQUESTED" => "REQUEST_CHANGES", + _ => "COMMENT", + }; + if action != "dismissed" { + self.coderhelm_verdict = Some((verdict.into(), sha.clone())); + } else { + self.coderhelm_verdict = None; + } + } else { + let keep = match self.reviews.get(&who) { + // A comment never replaces a side taken. + Some(prev) if state == "COMMENTED" => prev.state == "COMMENTED", + _ => true, + }; + if keep || action == "dismissed" { + self.reviews.insert( + who.clone(), + Review { + state: if action == "dismissed" { + "DISMISSED".into() + } else { + state.clone() + }, + sha, + at: when, + }, + ); + } + self.requested.retain(|p| !p.eq_ignore_ascii_case(&who)); + } + self.role(&who, "reviewer"); + let words = match (action, state.as_str()) { + ("dismissed", _) => "had a review dismissed".to_string(), + (_, "APPROVED") => "approved".to_string(), + (_, "CHANGES_REQUESTED") => "asked for changes".to_string(), + _ => "commented in a review".to_string(), + }; + self.event(when, &who, "review", words); + self.event_at = now; + true + } + "pull_request_review_comment" | "issue_comment" => { + if action != "created" { + return false; + } + let c = &payload["comment"]; + let who = login(&c["user"]); + if who.is_empty() { + return false; + } + if event_type == "pull_request_review_comment" && !self.known { + self.take_pr(&payload["pull_request"]); + } + let body = c["body"].as_str().unwrap_or(""); + if !is_coderhelm(&who) && body.to_ascii_lowercase().contains("@coderhelm") { + self.role(&who, "requester"); + if self.requester.is_empty() { + self.requester = who.clone(); + } + self.event( + at(&c["created_at"]), + &who, + "comment", + "asked CoderHelm".into(), + ); + } else { + self.role(&who, "commenter"); + self.event(at(&c["created_at"]), &who, "comment", "commented".into()); + } + self.event_at = now; + true + } + "check_run" => { + let run = &payload["check_run"]; + let sha = s(&run["head_sha"]); + if !self.take_check_sha(&sha) { + return false; + } + let name = s(&run["name"]); + self.checks.retain(|k, _| !k.starts_with("suite:")); + let c = Check { + status: s(&run["status"]), + conclusion: s(&run["conclusion"]), + at: at(&run["completed_at"]).max(at(&run["started_at"])), + }; + if c.failed() && self.checks.get(&name).is_none_or(|p| !p.failed()) { + self.event(c.at, "ci", "check", format!("`{name}` failed")); + } + self.put_check(name, c); + self.event_at = now; + true + } + "check_suite" => { + let suite = &payload["check_suite"]; + let sha = s(&suite["head_sha"]); + if !self.take_check_sha(&sha) { + return false; + } + // Named checks come from check runs; a suite stands in only + // while no run is known for the head. + if self.checks.keys().all(|k| k.starts_with("suite:")) { + let app = suite["app"]["name"].as_str().unwrap_or("checks"); + self.put_check( + format!("suite:{app}"), + Check { + status: s(&suite["status"]), + conclusion: s(&suite["conclusion"]), + at: at(&suite["updated_at"]), + }, + ); + } + if action == "completed" { + let concl = s(&suite["conclusion"]); + self.event( + at(&suite["updated_at"]), + "ci", + "check", + format!("a check suite finished: {concl}"), + ); + } + self.event_at = now; + true + } + "status" => { + let sha = s(&payload["sha"]); + if !self.take_check_sha(&sha) { + return false; + } + let state = payload["state"].as_str().unwrap_or(""); + let (status, conclusion) = match state { + "pending" => ("in_progress", ""), + "success" => ("completed", "success"), + "failure" => ("completed", "failure"), + _ => ("completed", "error"), + }; + self.put_check( + s(&payload["context"]), + Check { + status: status.into(), + conclusion: conclusion.into(), + at: at(&payload["updated_at"]), + }, + ); + self.event_at = now; + true + } + "push" => { + let after = s(&payload["after"]); + let pusher = payload["pusher"]["name"].as_str().unwrap_or("").to_string(); + let mut authors: Vec = Vec::new(); + for c in payload["commits"].as_array().into_iter().flatten().take(50) { + let a = c["author"]["username"].as_str().unwrap_or(""); + push_unique(&mut authors, a); + } + for a in &authors { + self.role(a, "committer"); + } + if !pusher.is_empty() { + self.role(&pusher, "committer"); + } + if !after.is_empty() && !after.starts_with("0000000") { + if after != self.head_sha { + self.checks.clear(); + self.checks_sha = after.clone(); + } + self.new_head(&after); + } + self.event_at = now; + true + } + _ => false, + } + } + + fn take_check_sha(&mut self, sha: &str) -> bool { + if sha.is_empty() { + return false; + } + if self.head_sha.is_empty() { + self.head_sha = sha.to_string(); + } + if sha != self.head_sha { + return false; + } + if self.checks_sha != sha { + self.checks.clear(); + self.checks_sha = sha.to_string(); + } + true + } + + fn put_check(&mut self, name: String, c: Check) { + if name.is_empty() { + return; + } + if self.checks.len() >= MAX_CHECKS && !self.checks.contains_key(&name) { + return; + } + // An older report never replaces a newer one. + if self + .checks + .get(&name) + .is_some_and(|p| p.at > c.at && c.at > 0) + { + return; + } + self.checks.insert(name, c); + } + + /// Apply one pull request node from the sync's GraphQL search + /// ([`SEARCH_QUERY`]); it is the authority for everything it names. + pub fn apply_node(&mut self, n: &Value, now: i64) { + self.known = true; + self.title = s(&n["title"]); + self.url = s(&n["url"]); + let author = login(&n["author"]); + if !author.is_empty() { + self.author = author.clone(); + self.role(&author, "author"); + } + self.draft = n["isDraft"].as_bool().unwrap_or(false); + self.status = match n["state"].as_str() { + Some("MERGED") => "merged", + Some("CLOSED") => "closed", + _ => "open", + } + .into(); + let head = s(&n["headRefOid"]); + if head != self.head_sha { + self.checks.clear(); + } + self.new_head(&head); + self.checks_sha = self.head_sha.clone(); + self.head_ref = s(&n["headRefName"]); + self.base_ref = s(&n["baseRefName"]); + self.created_at = ts(&n["createdAt"]); + self.updated_at = ts(&n["updatedAt"]); + self.additions = n["additions"].as_u64().unwrap_or(0) as u32; + self.deletions = n["deletions"].as_u64().unwrap_or(0) as u32; + self.labels = n["labels"]["nodes"] + .as_array() + .into_iter() + .flatten() + .map(|l| s(&l["name"])) + .collect(); + self.requested.clear(); + self.requested_teams.clear(); + for r in n["reviewRequests"]["nodes"] + .as_array() + .into_iter() + .flatten() + { + let rv = &r["requestedReviewer"]; + if let Some(l) = rv["login"].as_str() { + push_unique(&mut self.requested, l); + } else if let Some(slug) = rv["slug"].as_str() { + let t = format!("{}/{slug}", self.org()); + push_unique(&mut self.requested_teams, &t); + } + } + for r in self.requested.clone() { + self.role(&r, "requested"); + } + for r in n["latestOpinionatedReviews"]["nodes"] + .as_array() + .into_iter() + .flatten() + { + let who = login(&r["author"]); + if who.is_empty() { + continue; + } + let state = s(&r["state"]); + let sha = s(&r["commit"]["oid"]); + if is_coderhelm(&who) { + let v = match state.as_str() { + "APPROVED" => "APPROVE", + "CHANGES_REQUESTED" => "REQUEST_CHANGES", + _ => "COMMENT", + }; + self.coderhelm_verdict = Some((v.into(), sha)); + } else { + self.reviews.insert( + who.clone(), + Review { + state, + sha, + at: ts(&r["submittedAt"]), + }, + ); + } + self.role(&who, "reviewer"); + } + for p in n["participants"]["nodes"].as_array().into_iter().flatten() { + let l = login(p); + if !self.people.contains_key(&l) && !l.is_empty() { + self.role(&l, "commenter"); + } + } + self.review_decision = n["reviewDecision"].as_str().map(str::to_string); + self.conflict = match n["mergeable"].as_str() { + Some("CONFLICTING") => Some(true), + Some("MERGEABLE") => Some(false), + _ => None, + }; + self.merge_state = n["mergeStateStatus"] + .as_str() + .unwrap_or("") + .to_ascii_lowercase(); + self.auto_merge = !n["autoMergeRequest"].is_null(); + self.in_queue = n["isInMergeQueue"].as_bool().unwrap_or(false); + let rule = &n["baseRef"]["branchProtectionRule"]; + if rule.is_object() { + self.approvals_required = + rule["requiredApprovingReviewCount"].as_u64().unwrap_or(0) as u32; + self.codeowners_required = rule["requiresCodeOwnerReviews"].as_bool().unwrap_or(false); + self.threads_required = rule["requiresConversationResolution"] + .as_bool() + .unwrap_or(false); + self.required_checks = rule["requiredStatusCheckContexts"] + .as_array() + .into_iter() + .flatten() + .map(s) + .collect(); + } + let mut open = 0; + let mut authors = Vec::new(); + for t in n["reviewThreads"]["nodes"].as_array().into_iter().flatten() { + if t["isResolved"].as_bool() == Some(false) { + open += 1; + let a = login(&t["comments"]["nodes"][0]["author"]); + push_unique(&mut authors, &a); + } + } + self.open_threads = open; + self.thread_authors = authors; + let contexts = + &n["commits"]["nodes"][0]["commit"]["statusCheckRollup"]["contexts"]["nodes"]; + if let Some(list) = contexts.as_array() { + self.checks.clear(); + for c in list.iter().take(MAX_CHECKS) { + let (name, check) = if c["__typename"] == "StatusContext" { + let (status, concl) = match c["state"].as_str() { + Some("PENDING") | Some("EXPECTED") => ("in_progress", ""), + Some("SUCCESS") => ("completed", "success"), + Some("FAILURE") => ("completed", "failure"), + _ => ("completed", "error"), + }; + ( + s(&c["context"]), + Check { + status: status.into(), + conclusion: concl.into(), + at: now, + }, + ) + } else { + ( + s(&c["name"]), + Check { + status: s(&c["status"]).to_ascii_lowercase(), + conclusion: s(&c["conclusion"]).to_ascii_lowercase(), + at: now, + }, + ) + }; + if !name.is_empty() { + self.checks.insert(name, check); + } + } + } + self.synced_at = now; + } + + /// The facts the needs function reads, from this record alone; the + /// reader adds CoderHelm's run, its reviewer and stacked pull requests. + pub fn facts(&self) -> Facts { + let head = &self.head_sha; + let mut changes = Vec::new(); + let mut approved = Vec::new(); + for (who, r) in &self.reviews { + match r.state.as_str() { + "CHANGES_REQUESTED" => changes.push(who.clone()), + // An approval of an older commit counts when GitHub's own + // decision keeps it, or it is on the head. + "APPROVED" + if &r.sha == head || self.review_decision.as_deref() == Some("APPROVED") => + { + approved.push(who.clone()) + } + _ => {} + } + } + let pushed_since = !changes.is_empty() + && self.reviews.iter().any(|(_, r)| { + r.state == "CHANGES_REQUESTED" && !r.sha.is_empty() && &r.sha != head + }); + let mut checks = pr_needs::Checks { + known: !self.checks.is_empty() && self.checks_sha == *head, + required: self.required_checks.clone(), + ..Default::default() + }; + if checks.known { + for (name, c) in &self.checks { + let name = name.trim_start_matches("suite:").to_string(); + checks.total += 1; + if c.running() { + checks.running.push(name); + } else if c.failed() { + checks.failed.push(name); + } else { + checks.passed += 1; + } + } + } + // A required check not reported yet is still to run. + if checks.known { + for r in &self.required_checks { + if !self.checks.keys().any(|k| k.eq_ignore_ascii_case(r)) { + checks.total += 1; + checks.running.push(r.clone()); + } + } + } + let blocked = self.merge_state == "blocked"; + Facts { + known: self.known, + merged: self.status == "merged", + closed: self.status == "closed", + draft: self.draft, + head: head.clone(), + base: self.base_ref.clone(), + author: self.author.clone(), + author_is_coderhelm: self.author_is_coderhelm(), + merged_by: self.merged_by.clone(), + in_queue: self.in_queue, + left_queue: self.left_queue.clone(), + coderhelm_verdict: self.coderhelm_verdict.clone(), + conflict: self.conflict, + checks, + review_decision: self.review_decision.clone(), + changes_requested_by: changes, + pushed_since_changes: pushed_since, + approved_by: approved, + requested: self + .requested + .iter() + .filter(|p| !is_coderhelm(p)) + .cloned() + .collect(), + requested_teams: self.requested_teams.clone(), + approvals_required: self.approvals_required, + codeowners_required: self.codeowners_required, + threads_required: self.threads_required, + open_threads: self.open_threads, + thread_authors: self.thread_authors.clone(), + auto_merge: self.auto_merge, + blocked_by_rules: blocked, + since: self.spans.last().map(|s| s.from).unwrap_or(self.created_at), + ..Default::default() + } + } + + /// Record the decision on the wait ledger: a new span when the step or + /// who holds it changed. Returns whether it changed. + pub fn note_needs(&mut self, n: &Needs, now: i64) -> bool { + let who = n + .next + .from + .first() + .cloned() + .unwrap_or_else(|| pr_needs::NOBODY.to_string()); + let state = n.state.code().to_string(); + if self + .spans + .last() + .is_some_and(|s| s.who == who && s.state == state) + { + return false; + } + let from = if self.spans.is_empty() && self.created_at > 0 { + self.created_at.min(now) + } else { + now + }; + self.spans.push(Span { who, state, from }); + if self.spans.len() > MAX_SPANS { + let cut = self.spans.len() - MAX_SPANS; + self.spans.drain(..cut); + } + true + } + + /// When the record expires: never while open. + pub fn ttl(&self) -> Option { + (!self.is_open()).then(|| self.closed_at.max(self.event_at) + CLOSED_KEEP_SECS) + } +} + +/// Totals of the wait ledger: seconds each holder held the turn, up to +/// `now` (or when it closed), largest first. +pub fn ledger_totals(spans: &[Span], end: i64) -> Vec<(String, i64)> { + let mut by: BTreeMap = BTreeMap::new(); + for (i, s) in spans.iter().enumerate() { + let to = spans.get(i + 1).map(|n| n.from).unwrap_or(end); + *by.entry(s.who.clone()).or_default() += (to - s.from).max(0); + } + let mut out: Vec<(String, i64)> = by.into_iter().collect(); + out.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0))); + out +} + +/// The sync's search: open pull requests of one owner, newest first, with +/// everything the needs function reads. `$q` is the search, `$after` the +/// page cursor. +pub const SEARCH_QUERY: &str = "query($q: String!, $after: String) { + search(type: ISSUE, query: $q, first: 30, after: $after) { + issueCount + pageInfo { hasNextPage endCursor } + nodes { + ... on PullRequest { + number title url state isDraft createdAt updatedAt additions deletions + headRefName headRefOid baseRefName reviewDecision mergeable mergeStateStatus + isInMergeQueue + repository { nameWithOwner } + author { login } + autoMergeRequest { enabledAt } + labels(first: 20) { nodes { name } } + reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } ... on Team { slug } } } } + latestOpinionatedReviews(first: 20) { nodes { state submittedAt author { login } commit { oid } } } + participants(first: 20) { nodes { login } } + reviewThreads(first: 50) { nodes { isResolved comments(first: 1) { nodes { author { login } } } } } + baseRef { branchProtectionRule { requiredApprovingReviewCount requiresCodeOwnerReviews requiresConversationResolution requiredStatusCheckContexts } } + commits(last: 1) { nodes { commit { statusCheckRollup { contexts(first: 60) { nodes { __typename ... on CheckRun { name status conclusion } ... on StatusContext { context state } } } } } } } + } + } + } +}"; + +/// Pages of [`SEARCH_QUERY`] one sync reads per owner at most (30 pull +/// requests a page): the bound of one owner's sync. +pub const MAX_PAGES: u32 = 10; + +/// The search for an owner's open pull requests. +pub fn search_text(owner: &str, org: bool) -> String { + let q = if org { "org" } else { "user" }; + format!("is:pr is:open archived:false {q}:{owner} sort:updated-desc") +} + +// ─── Storage ──────────────────────────────────────────────────────────────── + +type Err = Box; +pub type Item = std::collections::HashMap; + +/// The record in `item`, with its version. +pub fn from_item(item: &Item) -> Option<(PrRecord, i64)> { + let doc = item.get("doc")?.as_s().ok()?; + let rec: PrRecord = serde_json::from_str(doc).ok()?; + let ver = item + .get("ver") + .and_then(|v| v.as_n().ok()) + .and_then(|v| v.parse().ok()) + .unwrap_or(0); + Some((rec, ver)) +} + +/// Read one record. +pub async fn load( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + repo: &str, + number: u64, +) -> Result, Err> { + let out = dynamo + .get_item() + .table_name(table) + .key("pk", AttributeValue::S(team_id.into())) + .key("sk", AttributeValue::S(record_sk(repo, number))) + .consistent_read(true) + .send() + .await?; + Ok(out.item().and_then(from_item)) +} + +/// Write a record when its version is still `ver` (0: not there yet). +/// False when another writer got there first. +async fn put( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + rec: &PrRecord, + needs: &Needs, + ver: i64, +) -> Result { + let mut req = dynamo + .put_item() + .table_name(table) + .item("pk", AttributeValue::S(team_id.into())) + .item("sk", AttributeValue::S(record_sk(&rec.repo, rec.number))) + .item("doc", AttributeValue::S(serde_json::to_string(rec)?)) + .item("ver", AttributeValue::N((ver + 1).to_string())) + .item("repo", AttributeValue::S(rec.repo.clone())) + .item("status", AttributeValue::S(rec.status.clone())) + .item("state", AttributeValue::S(needs.state.code().into())) + .item("turn", AttributeValue::S(needs.turn.code().into())); + if let Some(t) = rec.ttl() { + req = req.item("ttl", AttributeValue::N(t.to_string())); + } + req = if ver == 0 { + req.condition_expression("attribute_not_exists(sk)") + } else { + req.condition_expression("ver = :v") + .expression_attribute_values(":v", AttributeValue::N(ver.to_string())) + }; + match req.send().await { + Ok(_) => Ok(true), + Err(e) => { + let lost = e + .as_service_error() + .is_some_and(|s| s.is_conditional_check_failed_exception()); + if lost { + Ok(false) + } else { + Err(e.into()) + } + } + } +} + +/// Read, change and write one record, again from a fresh read when +/// another writer got there first (a few times). `change` returns false to +/// write nothing. +pub async fn update( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + repo: &str, + number: u64, + now: i64, + mut change: F, +) -> Result, Err> +where + F: FnMut(&mut PrRecord) -> bool, +{ + for _ in 0..4 { + let (mut rec, ver) = load(dynamo, table, team_id, repo, number) + .await? + .unwrap_or_else(|| (PrRecord::new(repo, number), 0)); + if !change(&mut rec) { + return Ok(None); + } + let needs = pr_needs::decide(repo, &rec.facts()); + rec.note_needs(&needs, now); + if put(dynamo, table, team_id, &rec, &needs, ver).await? { + return Ok(Some(rec)); + } + } + Err("the pull request's record kept changing under this write".into()) +} + +/// Remove a record (the sync found it no longer open). +pub async fn delete( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + repo: &str, + number: u64, +) -> Result<(), Err> { + dynamo + .delete_item() + .table_name(table) + .key("pk", AttributeValue::S(team_id.into())) + .key("sk", AttributeValue::S(record_sk(repo, number))) + .send() + .await?; + Ok(()) +} + +/// Point a head commit and a branch at their pull request. +pub async fn point( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + rec: &PrRecord, + now: i64, +) -> Result<(), Err> { + for sk in [ + (!rec.head_sha.is_empty()).then(|| head_sk(&rec.repo, &rec.head_sha)), + (!rec.head_ref.is_empty()).then(|| ref_sk(&rec.repo, &rec.head_ref)), + ] + .into_iter() + .flatten() + { + dynamo + .put_item() + .table_name(table) + .item("pk", AttributeValue::S(team_id.into())) + .item("sk", AttributeValue::S(sk)) + .item("pr_number", AttributeValue::N(rec.number.to_string())) + .item( + "ttl", + AttributeValue::N((now + POINTER_KEEP_SECS).to_string()), + ) + .send() + .await?; + } + Ok(()) +} + +/// The pull request a pointer names. +pub async fn pointed( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + sk: &str, +) -> Result, Err> { + let out = dynamo + .get_item() + .table_name(table) + .key("pk", AttributeValue::S(team_id.into())) + .key("sk", AttributeValue::S(sk.into())) + .send() + .await?; + Ok(out + .item() + .and_then(|i| i.get("pr_number")) + .and_then(|v| v.as_n().ok()) + .and_then(|v| v.parse().ok())) +} + +/// Every record of a team (one query, paged). +pub async fn all(dynamo: &DynamoClient, table: &str, team_id: &str) -> Result, Err> { + let mut out = Vec::new(); + let mut start: Option = None; + loop { + let page = dynamo + .query() + .table_name(table) + .key_condition_expression("pk = :pk AND begins_with(sk, :p)") + .expression_attribute_values(":pk", AttributeValue::S(team_id.into())) + .expression_attribute_values(":p", AttributeValue::S(SK_PREFIX.into())) + .set_exclusive_start_key(start) + .send() + .await?; + let now = chrono::Utc::now().timestamp(); + for item in page.items() { + // DynamoDB deletes expired items late. + let expired = item + .get("ttl") + .and_then(|v| v.as_n().ok()) + .and_then(|v| v.parse::().ok()) + .is_some_and(|t| t < now); + if expired { + continue; + } + if let Some((rec, _)) = from_item(item) { + out.push(rec); + } + } + start = page.last_evaluated_key().cloned(); + if start.is_none() { + return Ok(out); + } + } +} + +/// The pull requests one webhook is about, in `repo`: `None` when the +/// event names none directly (a `status` or `push`: found by pointer). +pub fn event_prs(event_type: &str, payload: &Value) -> Option> { + let one = |v: &Value| v.as_u64().map(|n| vec![n]); + match event_type { + "pull_request" | "pull_request_review" | "pull_request_review_comment" => { + one(&payload["pull_request"]["number"]) + } + "issue_comment" => payload["issue"]["pull_request"] + .is_object() + .then(|| one(&payload["issue"]["number"])) + .flatten(), + "check_run" => Some( + payload["check_run"]["pull_requests"] + .as_array() + .into_iter() + .flatten() + .filter_map(|p| p["number"].as_u64()) + .take(5) + .collect(), + ), + "check_suite" => Some( + payload["check_suite"]["pull_requests"] + .as_array() + .into_iter() + .flatten() + .filter_map(|p| p["number"].as_u64()) + .take(5) + .collect(), + ), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + const NOW: i64 = 1_800_000_000; + + fn opened() -> Value { + json!({ + "action": "opened", + "sender": {"login": "octocat"}, + "pull_request": { + "number": 318, "title": "Round cart totals per currency", + "html_url": "https://github.com/acme/web/pull/318", + "user": {"login": "octocat"}, "draft": false, "state": "open", "merged": false, + "head": {"sha": "aaaaaaa1111111", "ref": "fix/cart-rounding"}, + "base": {"ref": "main"}, + "created_at": "2026-01-10T10:00:00Z", "updated_at": "2026-01-10T10:00:00Z", + "requested_reviewers": [{"login": "mara"}], "requested_teams": [], + "labels": [{"name": "bookstore"}], + "body": "Fixes rounding.\n\n## Compatibility\n- acme/api#12 adds the field\n" + } + }) + } + + #[test] + fn a_persons_pull_request_is_recorded_from_its_events() { + let mut r = PrRecord::new("acme/web", 318); + assert!(r.apply_event("pull_request", &opened(), NOW)); + assert!(r.known); + assert_eq!(r.author, "octocat"); + assert_eq!(r.requested, vec!["mara"]); + assert_eq!( + r.links, + vec![Link { + kind: "contract".into(), + repo: "acme/api".into(), + number: 12 + }] + ); + // A check run on the head, then a review asking for changes. + let run = json!({"action": "completed", "check_run": {"name": "lint", "head_sha": "aaaaaaa1111111", + "status": "completed", "conclusion": "failure", "completed_at": "2026-01-10T10:05:00Z", + "pull_requests": [{"number": 318}]}}); + assert!(r.apply_event("check_run", &run, NOW)); + let f = r.facts(); + assert_eq!(f.checks.failed, vec!["lint"]); + let review = json!({"action": "submitted", "review": {"user": {"login": "mara"}, "state": "changes_requested", + "commit_id": "aaaaaaa1111111", "submitted_at": "2026-01-10T11:00:00Z"}, "pull_request": {"number": 318}}); + assert!(r.apply_event("pull_request_review", &review, NOW)); + assert_eq!(r.facts().changes_requested_by, vec!["mara"]); + assert!(r.requested.is_empty()); + assert!(r.people["mara"].contains(&"reviewer".to_string())); + // A check on another commit says nothing about the head. + let other = + json!({"check_run": {"name": "unit", "head_sha": "bbbbbbb", "status": "queued"}}); + assert!(!r.apply_event("check_run", &other, NOW)); + } + + #[test] + fn a_push_after_changes_requested_asks_for_a_re_review() { + let mut r = PrRecord::new("acme/web", 318); + r.apply_event("pull_request", &opened(), NOW); + r.reviews.insert( + "mara".into(), + Review { + state: "CHANGES_REQUESTED".into(), + sha: "aaaaaaa1111111".into(), + at: NOW, + }, + ); + let mut sync = opened(); + sync["action"] = json!("synchronize"); + sync["pull_request"]["head"]["sha"] = json!("ccccccc2222222"); + r.apply_event("pull_request", &sync, NOW); + assert!(r.facts().pushed_since_changes); + assert!(r.checks.is_empty(), "checks belong to the old head"); + assert!(r.people["octocat"].contains(&"committer".to_string())); + } + + #[test] + fn asking_coderhelm_in_a_comment_names_the_requester() { + let mut r = PrRecord::new("acme/web", 318); + let c = json!({"action": "created", "issue": {"number": 318, "pull_request": {}}, + "comment": {"user": {"login": "theo"}, "body": "@coderhelm fix ci", "created_at": "2026-01-10T12:00:00Z"}}); + assert!(r.apply_event("issue_comment", &c, NOW)); + assert_eq!(r.requester, "theo"); + assert_eq!(event_prs("issue_comment", &c), Some(vec![318])); + } + + #[test] + fn the_sync_node_fills_what_events_dont_carry() { + let node = json!({ + "number": 318, "title": "Round cart totals", "url": "https://github.com/acme/web/pull/318", + "state": "OPEN", "isDraft": false, "createdAt": "2026-01-10T10:00:00Z", + "updatedAt": "2026-01-10T12:00:00Z", "additions": 40, "deletions": 3, + "headRefName": "fix/cart-rounding", "headRefOid": "aaaaaaa1111111", "baseRefName": "main", + "reviewDecision": "REVIEW_REQUIRED", "mergeable": "MERGEABLE", "mergeStateStatus": "BLOCKED", + "isInMergeQueue": false, "author": {"login": "octocat"}, "autoMergeRequest": null, + "labels": {"nodes": []}, + "reviewRequests": {"nodes": [{"requestedReviewer": {"slug": "payments"}}]}, + "latestOpinionatedReviews": {"nodes": []}, + "participants": {"nodes": [{"login": "jun"}]}, + "reviewThreads": {"nodes": [{"isResolved": false, "comments": {"nodes": [{"author": {"login": "jun"}}]}}]}, + "baseRef": {"branchProtectionRule": {"requiredApprovingReviewCount": 1, "requiresCodeOwnerReviews": true, + "requiresConversationResolution": true, "requiredStatusCheckContexts": ["unit"]}}, + "commits": {"nodes": [{"commit": {"statusCheckRollup": {"contexts": {"nodes": [ + {"__typename": "CheckRun", "name": "unit", "status": "COMPLETED", "conclusion": "SUCCESS"}]}}}}]} + }); + let mut r = PrRecord::new("acme/web", 318); + r.apply_node(&node, NOW); + assert_eq!(r.requested_teams, vec!["acme/payments"]); + assert_eq!(r.open_threads, 1); + assert_eq!(r.thread_authors, vec!["jun"]); + assert_eq!(r.conflict, Some(false)); + let n = pr_needs::decide("acme/web", &r.facts()); + assert_eq!(n.state, pr_needs::State::NeedsReview, "{n:?}"); + assert!(n.next.text.contains("@acme/payments"), "{}", n.next.text); + assert_eq!(r.synced_at, NOW); + } + + #[test] + fn the_ledger_counts_who_held_the_turn() { + let mut r = PrRecord::new("acme/web", 318); + r.created_at = NOW - 100; + let mut n = pr_needs::decide("acme/web", &Facts::default()); + assert!(r.note_needs(&n, NOW)); + assert!(!r.note_needs(&n, NOW + 5), "the same step is one span"); + n.next.from = vec!["person:mara".into()]; + assert!(r.note_needs(&n, NOW + 50)); + let t = ledger_totals(&r.spans, NOW + 80); + assert_eq!(t[0], ("nobody".to_string(), 150)); + assert_eq!(t[1], ("person:mara".to_string(), 30)); + } + + #[test] + fn an_open_record_never_expires_and_a_closed_one_does() { + let mut r = PrRecord::new("acme/web", 318); + assert_eq!(r.ttl(), None); + r.status = "merged".into(); + r.closed_at = NOW; + assert_eq!(r.ttl(), Some(NOW + CLOSED_KEEP_SECS)); + } +} diff --git a/services/common/src/pr_view.rs b/services/common/src/pr_view.rs new file mode 100644 index 000000000..d055b96e4 --- /dev/null +++ b/services/common/src/pr_view.rs @@ -0,0 +1,1045 @@ +//! The pull requests view: every open pull request of one team, each with +//! its one state from [`crate::pr_needs::decide`], filtered, counted and +//! paged for `GET /api/prs`. +//! +//! Everything here is pure: the gateway reads the team's records +//! ([`crate::pr_record`]), its runs on them and its reviewer's records, and +//! hands them in. [`rows`] keeps only the records whose key names the team +//! asking, so a record of another team never reaches a row, whatever the +//! read returned. + +use std::collections::{BTreeMap, HashMap}; + +use serde::Serialize; + +use crate::merge_standing::Standing; +use crate::pr_needs::{self, Facts, Needs, Own, OwnStanding, State, Stop, Turn}; +use crate::pr_record::{self, Item, Link, PrRecord}; + +/// CoderHelm's run on a pull request, as the runs table has it. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct RunJoin { + pub run_id: String, + pub status: String, + pub title: String, + pub sender: String, + pub current_pass: String, + pub created_at: String, + pub updated_at: String, + pub round: u32, + /// The standing the watch stored (`merge_standing::FIELD`). + pub standing: Option, + /// `needs_input`: the hand-off's code and line. + pub stop: Option, + /// A limit of CoderHelm's own, its line. + pub own_problem: Option, + /// The run's other pull requests, in merge order (`owner/repo#n`). + pub plan: Vec, + /// Pull requests this one merges after (from `repo_ci`). + pub after: Vec, +} + +/// The reviewer's records on a pull request. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct ReviewJoin { + /// A review of the head is queued or running. + pub reviewing: bool, + pub session_id: String, + /// CoderHelm's auto-merge gate is armed (waiting, not stopped). + pub gate_armed: bool, +} + +/// Everything joined to the records. +#[derive(Debug, Clone, Default)] +pub struct Joins { + pub runs: HashMap, + /// By `owner/repo#n`. + pub reviews: HashMap, +} + +/// One person on the pull request. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Person { + pub login: String, + pub roles: Vec, + pub coderhelm: bool, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Author { + pub login: String, + pub coderhelm: bool, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct NextOut { + pub code: String, + pub text: String, + pub from: Vec, + pub since: Option, + pub rule: Option, +} + +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)] +pub struct ChecksOut { + pub total: u32, + pub passed: u32, + pub failed: u32, + pub running: u32, + pub required_failed: Vec, + pub known: bool, +} + +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)] +pub struct ReviewsOut { + pub approvals: u32, + pub required: u32, + pub changes_requested_by: Vec, + pub requested: Vec, + pub coderhelm_verdict: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct SizeOut { + pub additions: u32, + pub deletions: u32, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct LastAction { + pub actor: String, + pub text: String, + pub at: String, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct CoderHelmOut { + pub run_id: Option, + pub session_id: Option, + pub round: u32, + pub working: bool, + pub what: String, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct LinkOut { + pub kind: String, + pub repo: String, + pub number: u64, + pub url: String, + pub state: Option, +} + +/// One row of the list. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Row { + pub key: String, + pub org: String, + pub repo: String, + pub number: u64, + pub title: String, + pub url: String, + pub author: Author, + /// For CoderHelm's pull request: the person it works for. + #[serde(rename = "for")] + pub for_person: Option, + pub draft: bool, + pub base: String, + pub head: String, + pub created_at: Option, + pub updated_at: Option, + pub state: String, + pub state_label: String, + pub turn: String, + pub next: NextOut, + pub modifiers: Vec, + pub people: Vec, + pub checks: ChecksOut, + pub reviews: ReviewsOut, + pub conflict: Option, + pub open_threads: u32, + pub labels: Vec, + pub size: Option, + pub last_action: Option, + pub coderhelm: Option, + pub links: Vec, + pub waiting_since: Option, + /// Sort and filter keys, not sent. + #[serde(skip)] + pub rank: (u8, u8, i64), + #[serde(skip)] + pub involves: Vec, + #[serde(skip)] + pub stale: bool, +} + +pub fn rfc3339(secs: i64) -> Option { + (secs > 0) + .then(|| chrono::DateTime::from_timestamp(secs, 0)) + .flatten() + .map(|d| d.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)) +} + +fn parse_time(s: &str) -> i64 { + chrono::DateTime::parse_from_rfc3339(s) + .map(|d| d.timestamp()) + .unwrap_or(0) +} + +/// What CoderHelm does now, from the run's step. +pub fn what_of(current_pass: &str) -> &'static str { + match current_pass { + "triage" => "reading the ticket", + "plan" => "planning the change", + "implement" => "writing the change", + "review" | "self_review" => "reviewing its own change", + "pr" => "opening the pull request", + "ci" | "ci_fix" | "fix_ci" => "fixing CI", + "feedback" | "fix_round" => "addressing review comments", + "conflict" | "conflicts" | "resolve_conflicts" => "resolving conflicts", + _ => "working on it", + } +} + +/// Run statuses in which CoderHelm works on the pull request now. +pub const RUN_ACTIVE: &[&str] = &[ + crate::run_status::PENDING, + crate::run_status::QUEUED, + crate::run_status::RUNNING, +]; + +fn run_active(status: &str) -> bool { + RUN_ACTIVE.contains(&status) +} + +/// The team's records out of the read: only items whose key is the team's. +pub fn records_of(team_id: &str, items: &[Item]) -> Vec { + items + .iter() + .filter(|i| i.get("pk").and_then(|v| v.as_s().ok()).map(String::as_str) == Some(team_id)) + .filter(|i| { + i.get("sk") + .and_then(|v| v.as_s().ok()) + .is_some_and(|s| s.starts_with(pr_record::SK_PREFIX)) + }) + .filter_map(|i| pr_record::from_item(i).map(|(r, _)| r)) + .collect() +} + +/// The facts of one record with its joins. +pub fn facts_of( + rec: &PrRecord, + run: Option<&RunJoin>, + review: Option<&ReviewJoin>, + open_keys: &BTreeMap, +) -> Facts { + let mut f = rec.facts(); + if let Some(r) = review { + f.reviewing = r.reviewing; + f.coderhelm_merges = r.gate_armed; + } + if let Some(run) = run { + f.own = Some(Own { + run_id: run.run_id.clone(), + requester: if run.sender.is_empty() { + rec.requester.clone() + } else { + run.sender.clone() + }, + active: run_active(&run.status), + what: what_of(&run.current_pass).to_string(), + round: run.round, + stopped: run.stop.clone(), + own_problem: run.own_problem.clone(), + standing: rec + .author_is_coderhelm() + .then(|| run.standing.clone().map(OwnStanding::Decided)) + .flatten(), + }); + } + // Pull requests it merges after that are still open. + for l in &rec.links { + let key = format!("{}#{}", l.repo, l.number); + if matches!(l.kind.as_str(), "stack_base" | "depends") && open_keys.contains_key(&key) { + f.waits_on.push(key); + } + } + if let Some(run) = run { + for k in &run.after { + if open_keys.contains_key(k) && !f.waits_on.contains(k) { + f.waits_on.push(k.clone()); + } + } + } + f +} + +/// Links between the team's own records: a pull request based on another's +/// branch is stacked on it; the run's plan links its pull requests. +pub fn link_records(recs: &mut [PrRecord], joins: &Joins) { + let heads: HashMap<(String, String), u64> = recs + .iter() + .filter(|r| r.is_open() && !r.head_ref.is_empty()) + .map(|r| ((r.repo.clone(), r.head_ref.clone()), r.number)) + .collect(); + let mut children: HashMap<(String, u64), Vec> = HashMap::new(); + for r in recs.iter_mut() { + r.links.retain(|l| { + !matches!( + l.kind.as_str(), + "stack_base" | "stack_child" | "plan" | "depends" + ) + }); + if let Some(n) = heads.get(&(r.repo.clone(), r.base_ref.clone())) { + if *n != r.number { + r.links.push(Link { + kind: "stack_base".into(), + repo: r.repo.clone(), + number: *n, + }); + children + .entry((r.repo.clone(), *n)) + .or_default() + .push(r.number); + } + } + if let Some(run) = joins.runs.get(&r.coderhelm.run_id) { + let me = format!("{}#{}", r.repo, r.number); + for k in run.plan.iter().filter(|k| **k != me) { + if let Some((repo, n)) = k.rsplit_once('#') { + if let Ok(n) = n.parse() { + let kind = if run.after.contains(k) { + "depends" + } else { + "plan" + }; + r.links.push(Link { + kind: kind.into(), + repo: repo.into(), + number: n, + }); + } + } + } + } + } + for r in recs.iter_mut() { + if let Some(kids) = children.get(&(r.repo.clone(), r.number)) { + for k in kids { + r.links.push(Link { + kind: "stack_child".into(), + repo: r.repo.clone(), + number: *k, + }); + } + } + } +} + +fn turn_rank(turn: &str) -> u8 { + match turn { + "you" => 0, + "coderhelm" => 1, + "person" => 2, + "machines" => 3, + _ => 4, + } +} + +/// The turn as the viewer sees it: theirs when they are among who acts. +pub fn viewer_turn(n: &Needs, viewer: Option<&str>) -> String { + if n.turn == Turn::Person { + if let Some(v) = viewer.filter(|v| !v.is_empty()) { + let me = pr_needs::person(v); + if n.next.from.iter().any(|f| f.eq_ignore_ascii_case(&me)) { + return "you".into(); + } + } + } + n.turn.code().to_string() +} + +/// One row per record of the team, each with its one state. +pub fn rows( + team_id: &str, + items: &[Item], + joins: &Joins, + viewer: Option<&str>, + now: i64, +) -> Vec { + let mut recs = records_of(team_id, items); + link_records(&mut recs, joins); + let mut decided: Vec<(PrRecord, Needs, Facts)> = Vec::new(); + let open_keys: BTreeMap = recs + .iter() + .filter(|r| r.is_open()) + .map(|r| (format!("{}#{}", r.repo, r.number), String::new())) + .collect(); + for r in recs { + let key = format!("{}#{}", r.repo, r.number); + let run = joins.runs.get(&r.coderhelm.run_id); + let review = joins.reviews.get(&key); + let f = facts_of(&r, run, review, &open_keys); + let n = pr_needs::decide(&r.repo, &f); + decided.push((r, n, f)); + } + let states: HashMap = decided + .iter() + .map(|(r, n, _)| { + ( + format!("{}#{}", r.repo, r.number), + n.state.code().to_string(), + ) + }) + .collect(); + // The repository's usual wait in each state: a row waiting longer than + // three in four of its peers is stale (none below four peers). + let mut waits: HashMap<(String, State), Vec> = HashMap::new(); + for (r, n, _) in &decided { + if r.is_open() { + let since = waiting_since(r); + waits + .entry((r.repo.clone(), n.state)) + .or_default() + .push(now - since); + } + } + let p75: HashMap<(String, State), i64> = waits + .into_iter() + .filter(|(_, v)| v.len() >= 4) + .map(|(k, mut v)| { + v.sort(); + let i = (v.len() * 3).div_ceil(4).saturating_sub(1); + (k, v[i]) + }) + .collect(); + decided + .into_iter() + .map(|(r, n, f)| { + let since = waiting_since(&r); + let stale = r.is_open() + && p75 + .get(&(r.repo.clone(), n.state)) + .is_some_and(|p| now - since > *p && *p > 0); + row(&r, &n, &f, joins, &states, viewer, since, stale) + }) + .collect() +} + +fn waiting_since(r: &PrRecord) -> i64 { + r.spans + .last() + .map(|s| s.from) + .filter(|t| *t > 0) + .unwrap_or(r.created_at) +} + +#[allow(clippy::too_many_arguments)] +fn row( + r: &PrRecord, + n: &Needs, + f: &Facts, + joins: &Joins, + states: &HashMap, + viewer: Option<&str>, + since: i64, + stale: bool, +) -> Row { + let key = format!("{}#{}", r.repo, r.number); + let run = joins.runs.get(&r.coderhelm.run_id); + let review = joins.reviews.get(&key); + let turn = viewer_turn(n, viewer); + let for_person = r + .author_is_coderhelm() + .then(|| { + run.map(|x| x.sender.clone()) + .filter(|s| !s.is_empty()) + .or_else(|| (!r.requester.is_empty()).then(|| r.requester.clone())) + }) + .flatten(); + let mut people: Vec = r + .people + .iter() + .map(|(login, roles)| Person { + login: login.clone(), + roles: roles.clone(), + coderhelm: login == "coderhelm", + }) + .collect(); + if let Some(p) = &for_person { + match people.iter_mut().find(|x| &x.login == p) { + Some(x) if !x.roles.iter().any(|r| r == "requester") => { + x.roles.push("requester".into()) + } + Some(_) => {} + None => people.push(Person { + login: p.clone(), + roles: vec!["requester".into()], + coderhelm: false, + }), + } + } + if (run.is_some() || review.is_some()) && !people.iter().any(|p| p.coderhelm) { + people.push(Person { + login: "coderhelm".into(), + roles: vec![if run.is_some() { "worker" } else { "reviewer" }.into()], + coderhelm: true, + }); + } + // Author first. + people.sort_by_key(|p| (!p.roles.iter().any(|r| r == "author"), p.login.clone())); + let (blocking, _) = f.checks.blocking(); + let mut modifiers = Vec::new(); + if stale { + modifiers.push("stale".to_string()); + } + if r.links + .iter() + .any(|l| matches!(l.kind.as_str(), "stack_base" | "stack_child")) + { + modifiers.push("stacked".into()); + } + if r.author_is_coderhelm() { + modifiers.push("agent_authored".into()); + } + if r.additions + r.deletions >= 1000 { + modifiers.push("large".into()); + } + let last = r.events.last().map(|e| LastAction { + actor: e.actor.clone(), + text: e.text.clone(), + at: rfc3339(e.at).unwrap_or_default(), + }); + let coderhelm = (run.is_some() + || review.is_some_and(|v| !v.session_id.is_empty() || v.reviewing)) + .then(|| CoderHelmOut { + run_id: run.map(|x| x.run_id.clone()), + session_id: review + .map(|v| v.session_id.clone()) + .filter(|s| !s.is_empty()), + round: run.map(|x| x.round).unwrap_or(0), + working: n.state == State::CoderHelmWorking, + what: if review.is_some_and(|v| v.reviewing) && !run.is_some_and(|x| run_active(&x.status)) + { + "reviewing".into() + } else { + run.map(|x| what_of(&x.current_pass).to_string()) + .unwrap_or_default() + }, + }); + let links = r + .links + .iter() + .map(|l| { + let k = format!("{}#{}", l.repo, l.number); + LinkOut { + kind: l.kind.clone(), + repo: l.repo.clone(), + number: l.number, + url: format!("https://github.com/{}/pull/{}", l.repo, l.number), + state: states.get(&k).cloned(), + } + }) + .collect(); + let mut involves: Vec = r.people.keys().map(|k| k.to_ascii_lowercase()).collect(); + if let Some(p) = &for_person { + involves.push(p.to_ascii_lowercase()); + } + let blocks_others = r.links.iter().any(|l| l.kind == "stack_child") + || r.labels.iter().any(|l| l.eq_ignore_ascii_case("hotfix")); + Row { + key, + org: r.org().to_string(), + repo: r.repo.clone(), + number: r.number, + title: r.title.clone(), + url: if r.url.is_empty() { + format!("https://github.com/{}/pull/{}", r.repo, r.number) + } else { + r.url.clone() + }, + author: Author { + login: r.author.clone(), + coderhelm: r.author_is_coderhelm(), + }, + for_person, + draft: r.draft, + base: r.base_ref.clone(), + head: r.head_ref.clone(), + created_at: rfc3339(r.created_at), + updated_at: rfc3339(r.updated_at.max(r.event_at)), + state: n.state.code().into(), + state_label: n.state.label().into(), + turn: turn.clone(), + next: NextOut { + code: n.next.code.clone(), + text: n.next.text.clone(), + from: n.next.from.clone(), + since: rfc3339(since), + rule: n.next.rule.map(|r| { + serde_json::to_value(r) + .ok() + .and_then(|v| v.as_str().map(str::to_string)) + .unwrap_or_default() + }), + }, + modifiers, + people, + checks: ChecksOut { + total: f.checks.total, + passed: f.checks.passed, + failed: f.checks.failed.len() as u32, + running: f.checks.running.len() as u32, + required_failed: if f.checks.required.is_empty() { + vec![] + } else { + blocking + }, + known: f.checks.known, + }, + reviews: ReviewsOut { + approvals: f.approved_by.len() as u32, + required: f.approvals_required, + changes_requested_by: f.changes_requested_by.clone(), + requested: f + .requested + .iter() + .cloned() + .chain(f.requested_teams.iter().cloned()) + .collect(), + coderhelm_verdict: f.coderhelm_verdict.as_ref().map(|(v, _)| v.clone()), + }, + conflict: f.conflict, + open_threads: f.open_threads, + labels: r.labels.clone(), + size: (r.additions + r.deletions > 0).then_some(SizeOut { + additions: r.additions, + deletions: r.deletions, + }), + last_action: last, + coderhelm, + links, + waiting_since: rfc3339(since), + rank: ( + turn_rank(&turn), + if n.state == State::NeedsDecision { + 0 + } else if blocks_others { + 1 + } else { + 2 + }, + since, + ), + involves, + stale, + } +} + +/// The list's filters. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct Query { + pub org: Option, + pub repo: Option, + pub turn: Option, + pub states: Vec, + pub person: Option, + pub q: Option, + pub view: Option, +} + +/// The saved views, by code. +pub const VIEWS: &[&str] = &[ + "my_turn", + "coderhelm_working", + "needs_decision", + "ready", + "stale", +]; + +fn in_view(row: &Row, view: &str) -> bool { + match view { + "my_turn" => row.turn == "you", + "coderhelm_working" => row.state == "coderhelm_working", + "needs_decision" => row.state == "needs_decision", + "ready" => matches!(row.state.as_str(), "ready_to_merge" | "ready_auto_merge"), + "stale" => row.stale, + _ => true, + } +} + +fn in_scope(row: &Row, q: &Query) -> bool { + q.org + .as_deref() + .is_none_or(|o| row.org.eq_ignore_ascii_case(o)) + && q.repo + .as_deref() + .is_none_or(|r| row.repo.eq_ignore_ascii_case(r)) +} + +fn matches(row: &Row, q: &Query) -> bool { + if let Some(t) = q.turn.as_deref() { + if row.turn != t { + return false; + } + } + if !q.states.is_empty() && !q.states.iter().any(|s| s == &row.state) { + return false; + } + if let Some(p) = q.person.as_deref() { + let p = p.trim_start_matches('@').to_ascii_lowercase(); + if !row.involves.contains(&p) { + return false; + } + } + if let Some(v) = q.view.as_deref() { + if !in_view(row, v) { + return false; + } + } + if let Some(text) = q.q.as_deref().map(str::trim).filter(|t| !t.is_empty()) { + let t = text.to_ascii_lowercase(); + let hay = format!( + "{} {}#{} #{} {} {} {}", + row.title, row.repo, row.number, row.number, row.author.login, row.head, row.next.text + ) + .to_ascii_lowercase(); + if !t.split_whitespace().all(|w| hay.contains(w)) { + return false; + } + } + true +} + +/// Counts over the scope, before the other filters: the strip and the +/// saved views always show their totals. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)] +pub struct Counts { + pub turn: BTreeMap, + pub state: BTreeMap, + pub repo: BTreeMap, + pub org: BTreeMap, + pub views: BTreeMap, +} + +/// One page. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Page { + pub rows: Vec, + pub total: usize, + pub next: Option, + pub counts: Counts, +} + +/// Filter, count, order and page the rows. The cursor is the offset into +/// the ordered, filtered list (`o:`). +pub fn page(mut all: Vec, q: &Query, limit: usize, cursor: Option<&str>) -> Page { + let mut counts = Counts::default(); + for r in all.iter() { + *counts.org.entry(r.org.clone()).or_default() += 1; + if q.org + .as_deref() + .is_none_or(|o| r.org.eq_ignore_ascii_case(o)) + { + *counts.repo.entry(r.repo.clone()).or_default() += 1; + } + } + all.retain(|r| in_scope(r, q)); + for r in &all { + *counts.turn.entry(r.turn.clone()).or_default() += 1; + *counts.state.entry(r.state.clone()).or_default() += 1; + for v in VIEWS { + if in_view(r, v) { + *counts.views.entry(v.to_string()).or_default() += 1; + } + } + } + for v in VIEWS { + counts.views.entry(v.to_string()).or_default(); + } + all.retain(|r| matches(r, q)); + all.sort_by(|a, b| a.rank.cmp(&b.rank).then_with(|| a.key.cmp(&b.key))); + let total = all.len(); + let start = cursor + .and_then(|c| c.strip_prefix("o:")) + .and_then(|n| n.parse::().ok()) + .unwrap_or(0) + .min(total); + let limit = limit.clamp(1, 200); + let end = (start + limit).min(total); + let next = (end < total).then(|| format!("o:{end}")); + let rows = all.drain(start..end).collect(); + Page { + rows, + total, + next, + counts, + } +} + +/// The wait ledger of one record, up to `now` (or when it closed). +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct LedgerSpan { + pub who: String, + pub state: String, + pub from: Option, + pub to: Option, + pub secs: i64, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct LedgerTotal { + pub who: String, + pub secs: i64, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Ledger { + pub open_secs: i64, + pub spans: Vec, + pub totals: Vec, +} + +/// The ledger, with the current decision as its live last span when it +/// differs from the stored one (the run or the reviewer moved since the +/// last event). +pub fn ledger(r: &PrRecord, n: &Needs, now: i64) -> Ledger { + let mut rec = r.clone(); + rec.note_needs(n, now); + let end = if r.is_open() { now } else { r.closed_at.max(1) }; + let spans: Vec = rec + .spans + .iter() + .enumerate() + .map(|(i, s)| { + let to = rec.spans.get(i + 1).map(|x| x.from); + LedgerSpan { + who: s.who.clone(), + state: s.state.clone(), + from: rfc3339(s.from), + to: to.and_then(rfc3339), + secs: (to.unwrap_or(end) - s.from).max(0), + } + }) + .collect(); + let totals = pr_record::ledger_totals(&rec.spans, end) + .into_iter() + .map(|(who, secs)| LedgerTotal { who, secs }) + .collect(); + Ledger { + open_secs: (end + - rec + .created_at + .max(rec.spans.first().map(|s| s.from).unwrap_or(end))) + .max(0), + spans, + totals, + } +} + +/// One timeline event out. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct TimelineEvent { + pub at: String, + pub actor: String, + pub coderhelm: bool, + pub kind: String, + pub text: String, + pub run_id: Option, +} + +/// The timeline, oldest first: the record's events, and CoderHelm's runs +/// as one event each (the dashboard folds a run's events under it). +pub fn timeline(r: &PrRecord, runs: &[RunJoin]) -> Vec { + let mut out: Vec<(i64, TimelineEvent)> = r + .events + .iter() + .map(|e| { + ( + e.at, + TimelineEvent { + at: rfc3339(e.at).unwrap_or_default(), + actor: e.actor.clone(), + coderhelm: e.actor == "coderhelm", + kind: e.kind.clone(), + text: e.text.clone(), + run_id: None, + }, + ) + }) + .collect(); + for run in runs { + let start = parse_time(&run.created_at); + let end = parse_time(&run.updated_at).max(start); + // CoderHelm's own events inside the run's time are the run's. + for (t, e) in out.iter_mut() { + if e.coderhelm && *t >= start && *t <= end && e.run_id.is_none() { + e.run_id = Some(run.run_id.clone()); + } + } + out.push(( + start, + TimelineEvent { + at: rfc3339(start).unwrap_or_default(), + actor: "coderhelm".into(), + coderhelm: true, + kind: "run".into(), + text: if run.title.is_empty() { + format!("run: {}", run.status) + } else { + format!("{} ({})", run.title, run.status) + }, + run_id: Some(run.run_id.clone()), + }, + )); + } + out.sort_by_key(|(t, _)| *t); + out.into_iter().map(|(_, e)| e).collect() +} + +#[cfg(test)] +mod tests { + use super::*; + use aws_sdk_dynamodb::types::AttributeValue; + + const NOW: i64 = 1_800_000_000; + + fn item(team: &str, rec: &PrRecord) -> Item { + let mut i = Item::new(); + i.insert("pk".into(), AttributeValue::S(team.into())); + i.insert( + "sk".into(), + AttributeValue::S(pr_record::record_sk(&rec.repo, rec.number)), + ); + i.insert( + "doc".into(), + AttributeValue::S(serde_json::to_string(rec).unwrap()), + ); + i + } + + fn rec(repo: &str, n: u64, author: &str) -> PrRecord { + let mut r = PrRecord::new(repo, n); + r.known = true; + r.title = format!("Bookstore change {n}"); + r.author = author.into(); + r.people.insert(author.into(), vec!["author".into()]); + r.head_sha = "aaaaaaa1111111".into(); + r.checks_sha = r.head_sha.clone(); + r.checks.insert( + "unit".into(), + pr_record::Check { + status: "completed".into(), + conclusion: "success".into(), + at: NOW, + }, + ); + r.conflict = Some(false); + r.created_at = NOW - 3600; + r + } + + #[test] + fn another_teams_record_never_becomes_a_row() { + let mine = rec("acme/web", 1, "octocat"); + let theirs = rec("acme/web", 2, "octocat"); + let items = vec![item("TEAM#a", &mine), item("TEAM#b", &theirs)]; + let rows = rows("TEAM#a", &items, &Joins::default(), None, NOW); + assert_eq!(rows.len(), 1); + assert_eq!(rows[0].number, 1); + } + + #[test] + fn the_viewers_turn_is_theirs_and_views_count_before_filters() { + let mut a = rec("acme/web", 1, "octocat"); + a.requested = vec!["mara".into()]; + a.approvals_required = 1; + let b = rec("acme/api", 2, "theo"); + let items = vec![item("TEAM#a", &a), item("TEAM#a", &b)]; + let all = rows("TEAM#a", &items, &Joins::default(), Some("mara"), NOW); + let q = Query { + view: Some("my_turn".into()), + ..Default::default() + }; + let p = page(all.clone(), &q, 50, None); + assert_eq!(p.total, 1); + assert_eq!(p.rows[0].turn, "you"); + assert_eq!(p.counts.views["my_turn"], 1); + assert_eq!(p.counts.org["acme"], 2); + let q = Query { + repo: Some("acme/api".into()), + ..Default::default() + }; + let p = page(all, &q, 50, None); + assert_eq!(p.total, 1); + assert_eq!(p.counts.repo.len(), 2, "repos count across the org"); + } + + #[test] + fn a_stacked_pull_request_waits_on_its_base() { + let mut base = rec("acme/web", 1, "octocat"); + base.head_ref = "feature/a".into(); + base.base_ref = "main".into(); + let mut top = rec("acme/web", 2, "octocat"); + top.head_ref = "feature/b".into(); + top.base_ref = "feature/a".into(); + let items = vec![item("TEAM#a", &base), item("TEAM#a", &top)]; + let all = rows("TEAM#a", &items, &Joins::default(), None, NOW); + let top = all.iter().find(|r| r.number == 2).unwrap(); + assert_eq!(top.state, "waiting_on_pr"); + assert!(top.modifiers.contains(&"stacked".to_string())); + let base = all.iter().find(|r| r.number == 1).unwrap(); + assert!(base.links.iter().any(|l| l.kind == "stack_child")); + } + + #[test] + fn paging_is_by_cursor_and_ends() { + let items: Vec = (1..=5) + .map(|n| item("TEAM#a", &rec("acme/web", n, "octocat"))) + .collect(); + let all = rows("TEAM#a", &items, &Joins::default(), None, NOW); + let p = page(all.clone(), &Query::default(), 2, None); + assert_eq!(p.rows.len(), 2); + assert_eq!(p.next.as_deref(), Some("o:2")); + let p = page(all, &Query::default(), 2, Some("o:4")); + assert_eq!(p.rows.len(), 1); + assert_eq!(p.next, None); + } + + #[test] + fn a_coderhelm_pull_request_is_for_its_requester_and_folds_its_runs() { + let mut r = rec("acme/web", 7, "coderhelm[bot]"); + r.coderhelm.run_id = "run-1".into(); + r.events.push(pr_record::Event { + at: NOW - 100, + actor: "coderhelm".into(), + kind: "pushed".into(), + text: "pushed".into(), + run_id: String::new(), + }); + let run = RunJoin { + run_id: "run-1".into(), + status: "running".into(), + sender: "octocat".into(), + current_pass: "ci_fix".into(), + round: 2, + created_at: rfc3339(NOW - 200).unwrap(), + updated_at: rfc3339(NOW).unwrap(), + ..Default::default() + }; + let mut joins = Joins::default(); + joins.runs.insert("run-1".into(), run.clone()); + let all = rows("TEAM#a", &[item("TEAM#a", &r)], &joins, None, NOW); + assert_eq!(all[0].for_person.as_deref(), Some("octocat")); + assert_eq!(all[0].state, "coderhelm_working"); + assert!( + all[0].next.text.contains("fixing CI, round 2"), + "{}", + all[0].next.text + ); + let t = timeline(&r, &[run]); + assert!(t + .iter() + .all(|e| !e.coderhelm || e.run_id.as_deref() == Some("run-1"))); + } +} diff --git a/services/gateway/src/main.rs b/services/gateway/src/main.rs index a374b1e04..b02b645a1 100644 --- a/services/gateway/src/main.rs +++ b/services/gateway/src/main.rs @@ -691,6 +691,8 @@ fn build_app(state: Arc) -> Router { .route("/reviewer/review", get(routes::reviewer::get_review)) .route("/reviewer/session", get(routes::reviewer::get_session)) .route("/reviewer/live", get(routes::reviewer::live_prs)) + .route("/prs", get(routes::prs::list_prs)) + .route("/prs/detail", get(routes::prs::get_pr)) .route("/reviewer/open-prs", get(routes::reviewer::open_prs)) .route( "/reviewer/gate", diff --git a/services/gateway/src/permissions.rs b/services/gateway/src/permissions.rs index ee9b660f3..6f488995f 100644 --- a/services/gateway/src/permissions.rs +++ b/services/gateway/src/permissions.rs @@ -125,6 +125,8 @@ pub const CAPABILITIES: &[Capability] = &[ "reviewer::get_review", "reviewer::get_session", "reviewer::open_prs", + "prs::list_prs", + "prs::get_pr", "review_lessons::list_lessons", "learning::get_learning", "learning::get_health", diff --git a/services/gateway/src/routes/github_webhook.rs b/services/gateway/src/routes/github_webhook.rs index c5d1e5bcd..acb99c2ac 100644 --- a/services/gateway/src/routes/github_webhook.rs +++ b/services/gateway/src/routes/github_webhook.rs @@ -443,6 +443,23 @@ async fn route( .await; } } + // Installed, or repositories added: the team's open pull requests + // are read once, in the background (`pr_records` in the worker). + if !team.is_empty() + && r.is_ok() + && matches!( + payload["action"].as_str(), + Some("created" | "added" | "new_permissions_accepted" | "unsuspend") + ) + { + let sync = WorkerMessage::PrRecordsSync(common::messages::PrRecordsSyncMessage { + team_id: team.clone(), + installation_id, + }); + if let Err(e) = send_to_queue(state, &state.config.ticket_queue_url, &sync).await { + warn!(error = ?e, "Could not ask for the team's open pull requests to be read"); + } + } d.target = team.clone(); return (r, team); } @@ -497,6 +514,21 @@ async fn dispatch( .await; // Activity on a pull request takes CoderHelm's stale label off now. super::stale_prs::on_webhook(state, event_type, payload, team_id).await; + // Every pull request's record follows its events, people's pull + // requests as much as CoderHelm's (the pull requests view). + if matches!( + event_type, + "pull_request" + | "pull_request_review" + | "pull_request_review_comment" + | "issue_comment" + | "check_run" + | "check_suite" + | "status" + | "push" + ) { + super::prs::on_webhook(state, team_id, event_type, payload).await; + } // A plan task's pull request moved: its plan's state follows. if matches!( event_type, @@ -2172,7 +2204,8 @@ async fn handle_pull_request( record_revert(state, payload, team_id, installation_id).await; } - // Only track our PRs + // The rest is for CoderHelm's own runs; every pull request's record + // (people's too) was written in `dispatch` (`prs::on_webhook`). let pr_user = payload["pull_request"]["user"]["login"] .as_str() .unwrap_or(""); @@ -5529,7 +5562,7 @@ async fn trigger_plan_dependents( } /// Look up run_id from the runs table by PR number using the repo-index GSI. -async fn lookup_run_by_pr( +pub(super) async fn lookup_run_by_pr( state: &AppState, team_id: &str, owner: &str, diff --git a/services/gateway/src/routes/mod.rs b/services/gateway/src/routes/mod.rs index 21817c6d9..541b684ed 100644 --- a/services/gateway/src/routes/mod.rs +++ b/services/gateway/src/routes/mod.rs @@ -81,6 +81,7 @@ pub mod plans; pub mod plugin_pkgs; pub mod plugins; pub mod preview_access; +pub mod prs; pub mod repo_setup; pub mod require_sso; #[cfg(test)] diff --git a/services/gateway/src/routes/prs.rs b/services/gateway/src/routes/prs.rs new file mode 100644 index 000000000..9c7057222 --- /dev/null +++ b/services/gateway/src/routes/prs.rs @@ -0,0 +1,600 @@ +//! The pull requests view: every open pull request in the team's +//! repositories, where it is, who worked on it, its one state, and what it +//! needs next from whom. +//! +//! - [`on_webhook`] writes each pull request's record +//! (`common::pr_record`) from the GitHub events the gateway already +//! receives, for every pull request, not only CoderHelm's. +//! - `GET /api/prs` ([`list_prs`]) and `GET /api/prs/detail` +//! ([`get_pr`]) read the team's records, join CoderHelm's runs and its +//! reviewer's records, and decide each one's state with +//! `common::pr_needs::decide`, the same function the merge gates use. +//! +//! The team is the session's, never a parameter; every read is keyed by it, +//! and the rows keep only records whose key is the team's +//! (`common::pr_view::records_of`). The short cache is keyed by the +//! installation and the team. + +use std::collections::HashMap; +use std::sync::{Arc, LazyLock}; +use std::time::{Duration, Instant}; + +use aws_sdk_dynamodb::types::{AttributeValue, KeysAndAttributes}; +use axum::{ + extract::{Query, State}, + http::StatusCode, + Extension, Json, +}; +use common::pr_record::{self, Item, PrRecord}; +use common::pr_view::{self, Joins, ReviewJoin, RunJoin}; +use serde::Deserialize; +use serde_json::{json, Value}; +use tracing::{error, warn}; + +use super::run_checks::{read_key, TtlCache}; +use crate::models::Claims; +use crate::AppState; + +/// How long one team's read is reused (the page polls while visible). +const LIST_TTL: Duration = Duration::from_secs(10); + +/// One team's records and what is joined to them. +type Snapshot = Arc<(Vec, Joins)>; + +/// The team's records and joins as last read, keyed by +/// `read_key(installation_id, "prs#")`. +static LIST: LazyLock> = LazyLock::new(TtlCache::new); + +fn now() -> i64 { + chrono::Utc::now().timestamp() +} + +// ─── The writer ───────────────────────────────────────────────────────────── + +/// Every pull request event updates its pull request's record: people's +/// pull requests as much as CoderHelm's. Never fails the webhook; a write +/// that can't land is logged, and the sync reads the pull request again. +pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, payload: &Value) { + let repo = payload["repository"]["full_name"].as_str().unwrap_or(""); + if repo.is_empty() || team_id.is_empty() { + return; + } + let table = &state.config.settings_table_name; + let numbers = match pr_record::event_prs(event_type, payload) { + Some(n) => n, + None => { + let sk = match event_type { + "status" => payload["sha"] + .as_str() + .map(|sha| pr_record::head_sk(repo, sha)), + "push" => payload["ref"] + .as_str() + .and_then(|r| r.strip_prefix("refs/heads/")) + .map(|b| pr_record::ref_sk(repo, b)), + _ => None, + }; + let Some(sk) = sk else { return }; + match pr_record::pointed(&state.dynamo, table, team_id, &sk).await { + Ok(Some(n)) => vec![n], + Ok(None) => return, + Err(e) => { + warn!(repo, event_type, error = %e, "Pull request record: pointer read failed"); + return; + } + } + } + }; + let t = now(); + for number in numbers { + let written = pr_record::update(&state.dynamo, table, team_id, repo, number, t, |r| { + r.apply_event(event_type, payload, t) + }) + .await; + let rec = match written { + Ok(Some(rec)) => rec, + Ok(None) => continue, + Err(e) => { + warn!(repo, number, event_type, error = %e, "Pull request record not written"); + continue; + } + }; + if event_type == "pull_request" { + if let Err(e) = pr_record::point(&state.dynamo, table, team_id, &rec, t).await { + warn!(repo, number, error = %e, "Pull request record: pointer not written"); + } + } + // CoderHelm's run on it, found once. + let asks = rec.author_is_coderhelm() || !rec.requester.is_empty(); + if rec.coderhelm.run_id.is_empty() && asks { + let (owner, name) = repo.split_once('/').unwrap_or((repo, "")); + let run_id = + super::github_webhook::lookup_run_by_pr(state, team_id, owner, name, number).await; + if !run_id.is_empty() { + let _ = pr_record::update(&state.dynamo, table, team_id, repo, number, t, |r| { + if r.coderhelm.run_id == run_id { + return false; + } + r.coderhelm.run_id = run_id.clone(); + true + }) + .await; + } + } + } +} + +// ─── The reads ────────────────────────────────────────────────────────────── + +fn s(item: &Item, k: &str) -> String { + item.get(k) + .and_then(|v| v.as_s().ok()) + .cloned() + .unwrap_or_default() +} + +fn n(item: &Item, k: &str) -> Option { + item.get(k)?.as_n().ok()?.parse().ok() +} + +async fn items_under(state: &AppState, team_id: &str, prefix: &str) -> Result, String> { + let mut out = Vec::new(); + let mut start: Option = None; + loop { + let page = state + .dynamo + .query() + .table_name(&state.config.settings_table_name) + .key_condition_expression("pk = :pk AND begins_with(sk, :p)") + .expression_attribute_values(":pk", AttributeValue::S(team_id.into())) + .expression_attribute_values(":p", AttributeValue::S(prefix.into())) + .set_exclusive_start_key(start) + .send() + .await + .map_err(|e| format!("{}", aws_sdk_dynamodb::error::DisplayErrorContext(&e)))?; + out.extend(page.items().iter().cloned()); + start = page.last_evaluated_key().cloned(); + if start.is_none() { + return Ok(out); + } + } +} + +/// Pure: a run record's facts for the view. +pub fn run_join(item: &Item) -> RunJoin { + use common::run_status::NEEDS_INPUT; + let status = s(item, "status"); + let stop = (status == NEEDS_INPUT) + .then(|| { + let w: common::run_wait::WaitingOn = + serde_json::from_str(&s(item, "waiting_on")).ok()?; + if w.pause.is_some() { + return None; + } + let text = if w.detail.is_empty() { + w.action.clone() + } else { + format!("{}: {}", w.action.trim_end_matches('.'), w.detail) + }; + Some(pr_needs_stop(&w.handback, &text)) + }) + .flatten(); + let prs = common::run_prs::from_item(item); + let plan: Vec = prs + .iter() + .filter(|p| p.pr_number > 0 && p.repo.contains('/')) + .map(|p| format!("{}#{}", p.repo, p.pr_number)) + .collect(); + let mut after = Vec::new(); + if let Ok(ci) = serde_json::from_str::(&s(item, "repo_ci")) { + // Each pull request's `after` names the repositories it merges + // after: their pull requests in the same plan. + for p in ci["prs"].as_array().into_iter().flatten() { + for repo in p["after"].as_array().into_iter().flatten() { + if let Some(k) = plan + .iter() + .find(|k| k.starts_with(&format!("{}#", repo.as_str().unwrap_or("")))) + { + if !after.contains(k) { + after.push(k.clone()); + } + } + } + } + } + RunJoin { + run_id: common::paged::run_id_of(item).unwrap_or_default(), + title: s(item, "title"), + sender: s(item, "sender"), + current_pass: s(item, "current_pass"), + created_at: s(item, "created_at"), + updated_at: s(item, "updated_at"), + round: n(item, "review_cycle").unwrap_or(0).max(0) as u32, + standing: common::merge_standing::Standing::from_json(&s( + item, + common::merge_standing::FIELD, + )), + stop, + own_problem: None, + plan, + after, + status, + } +} + +fn pr_needs_stop(code: &str, text: &str) -> common::pr_needs::Stop { + common::pr_needs::Stop { + code: code.to_string(), + text: text.to_string(), + person: String::new(), + } +} + +/// Pure: the reviewer's records by pull request. +pub fn review_joins(live: &[Item], gates: &[Item], now: i64) -> HashMap { + use common::review_live as rl; + let mut out: HashMap = HashMap::new(); + let key = |sk: &str, prefix: &str| -> Option { + let (repo, pr) = sk.strip_prefix(prefix)?.rsplit_once('#')?; + Some(format!("{repo}#{}", pr.parse::().ok()?)) + }; + for it in live { + if let Some(k) = key(&s(it, "sk"), rl::SK_PREFIX) { + let raw = s(it, "phase"); + let step = rl::effective_phase(&raw, n(it, "expires_at"), now); + let e = out.entry(k).or_default(); + e.reviewing = rl::in_flight(step); + e.session_id = s(it, "job"); + } + } + for it in gates { + if let Some(k) = key(&s(it, "sk"), common::merge_gate::SK_PREFIX) { + let st = s(it, "state"); + let armed = matches!( + st.as_str(), + common::merge_gate::STATE_WAITING_APPROVAL | common::merge_gate::STATE_WAITING_CI + ); + out.entry(k).or_default().gate_armed = armed; + } + } + out +} + +async fn runs_by_id(state: &AppState, team_id: &str, ids: &[String]) -> HashMap { + let mut out = HashMap::new(); + let table = &state.config.runs_table_name; + for chunk in ids.chunks(100) { + let mut ka = KeysAndAttributes::builder(); + for id in chunk { + ka = ka.keys(HashMap::from([ + ( + "team_id".to_string(), + AttributeValue::S(team_id.to_string()), + ), + ("run_id".to_string(), AttributeValue::S(id.clone())), + ])); + } + let Ok(ka) = ka.build() else { continue }; + let mut request = HashMap::from([(table.clone(), ka)]); + for _ in 0..2 { + match state + .dynamo + .batch_get_item() + .set_request_items(Some(request.clone())) + .send() + .await + { + Ok(res) => { + for item in res + .responses() + .and_then(|r| r.get(table)) + .into_iter() + .flatten() + { + // The key names the team; a row of another team is + // never joined. + if s(item, "team_id") != team_id { + continue; + } + let j = run_join(item); + out.insert(j.run_id.clone(), j); + } + match res.unprocessed_keys().filter(|u| !u.is_empty()) { + Some(left) => request = left.clone(), + None => break, + } + } + Err(e) => { + warn!(team_id, error = %e, "Pull requests: runs not read"); + break; + } + } + } + } + out +} + +/// The team's records and joins, from the short cache or the tables. +async fn read_all( + state: &AppState, + team_id: &str, +) -> Result<(Snapshot, Vec), StatusCode> { + let installation_id = super::api::get_team_installation_id(state, team_id) + .await + .unwrap_or(0); + let key = read_key(installation_id, &format!("prs#{team_id}")); + let at = Instant::now(); + if let Some(hit) = LIST.get(&key, at) { + return Ok(( + hit, + vec![json!({"name": "records", "read": "ok", "detail": "cached"})], + )); + } + let items = items_under(state, team_id, pr_record::SK_PREFIX) + .await + .map_err(|e| { + error!(team_id, error = %e, "Pull requests: records not read"); + StatusCode::INTERNAL_SERVER_ERROR + })?; + let mut sources = vec![json!({"name": "records", "read": "ok", "detail": ""})]; + let t = now(); + let (live, gates) = match ( + items_under(state, team_id, common::review_live::SK_PREFIX).await, + items_under(state, team_id, common::merge_gate::SK_PREFIX).await, + ) { + (Ok(l), Ok(g)) => (l, g), + (l, g) => { + sources.push(json!({"name": "reviewer", "read": "failed", "detail": "the reviewer's records couldn't be read; its work isn't shown"})); + (l.unwrap_or_default(), g.unwrap_or_default()) + } + }; + let recs = pr_view::records_of(team_id, &items); + let mut ids: Vec = recs + .iter() + .map(|r| r.coderhelm.run_id.clone()) + .filter(|r| !r.is_empty()) + .collect(); + ids.sort(); + ids.dedup(); + let joins = Joins { + runs: runs_by_id(state, team_id, &ids).await, + reviews: review_joins(&live, &gates, t), + }; + let v = Arc::new((items, joins)); + LIST.put(key, v.clone(), LIST_TTL, at); + Ok((v, sources)) +} + +#[derive(Deserialize, Default)] +pub struct ListQuery { + org: Option, + repo: Option, + turn: Option, + state: Option, + person: Option, + q: Option, + view: Option, + limit: Option, + cursor: Option, +} + +fn clean(v: Option) -> Option { + v.map(|s| s.trim().to_string()).filter(|s| !s.is_empty()) +} + +fn valid_word(v: &str) -> bool { + v.len() <= 100 + && v.chars() + .all(|c| c.is_ascii_alphanumeric() || "-_.,/@".contains(c)) +} + +/// Pure: the query's filters, or 400 for a word outside the vocabulary. +pub fn query_of(q: ListQuery) -> Result<(pr_view::Query, usize, Option), StatusCode> { + let org = clean(q.org); + let repo = clean(q.repo); + if let Some(r) = &repo { + super::reviewer::validate_repo(r)?; + } + for v in [&org, &q.person, &q.turn, &q.state, &q.view] + .into_iter() + .flatten() + { + if !valid_word(v) { + return Err(StatusCode::BAD_REQUEST); + } + } + let turn = clean(q.turn); + if turn + .as_deref() + .is_some_and(|t| !["you", "person", "coderhelm", "machines", "done"].contains(&t)) + { + return Err(StatusCode::BAD_REQUEST); + } + let states: Vec = clean(q.state) + .map(|s| s.split(',').map(|x| x.trim().to_string()).collect()) + .unwrap_or_default(); + if states + .iter() + .any(|s| common::pr_needs::State::from_code(s).is_none()) + { + return Err(StatusCode::BAD_REQUEST); + } + let view = clean(q.view); + if view + .as_deref() + .is_some_and(|v| !pr_view::VIEWS.contains(&v)) + { + return Err(StatusCode::BAD_REQUEST); + } + let text = clean(q.q).map(|t| common::truncate_str(&t, 200).to_string()); + Ok(( + pr_view::Query { + org, + repo, + turn, + states, + person: clean(q.person), + q: text, + view, + }, + q.limit.unwrap_or(100).clamp(1, 200), + clean(q.cursor), + )) +} + +fn synced_at(items: &[Item], team_id: &str, q: &pr_view::Query) -> Option { + let recs = pr_view::records_of(team_id, items); + recs.iter() + .filter(|r| { + q.org + .as_deref() + .is_none_or(|o| r.org().eq_ignore_ascii_case(o)) + }) + .filter(|r| { + q.repo + .as_deref() + .is_none_or(|x| r.repo.eq_ignore_ascii_case(x)) + }) + .map(|r| r.synced_at.max(r.event_at)) + .filter(|t| *t > 0) + .min() + .and_then(pr_view::rfc3339) +} + +/// GET /api/prs — every open pull request of the team, its one state and +/// what it needs next from whom; filters, counts over the scope, paging. +pub async fn list_prs( + State(state): State>, + Extension(claims): Extension, + Query(q): Query, +) -> Result, StatusCode> { + let (query, limit, cursor) = query_of(q)?; + let (data, sources) = read_all(&state, &claims.team_id).await?; + let (items, joins) = (&data.0, &data.1); + let viewer = claims.github_login.as_deref(); + let rows = pr_view::rows(&claims.team_id, items, joins, viewer, now()); + let synced = synced_at(items, &claims.team_id, &query); + let page = pr_view::page(rows, &query, limit, cursor.as_deref()); + Ok(Json(json!({ + "prs": page.rows, + "total": page.total, + "next": page.next, + "counts": page.counts, + "viewer": viewer, + "synced_at": synced, + "sources": sources, + }))) +} + +#[derive(Deserialize)] +pub struct DetailQuery { + repo: String, + number: u64, +} + +/// GET /api/prs/detail?repo=&number= — one pull request: its row, the path +/// to merge, the wait ledger and the timeline with CoderHelm's runs. +pub async fn get_pr( + State(state): State>, + Extension(claims): Extension, + Query(q): Query, +) -> Result, StatusCode> { + super::reviewer::validate_repo(&q.repo)?; + let (data, _) = read_all(&state, &claims.team_id).await?; + let (items, joins) = (&data.0, &data.1); + let t = now(); + let viewer = claims.github_login.as_deref(); + let key = format!("{}#{}", q.repo, q.number); + let rows = pr_view::rows(&claims.team_id, items, joins, viewer, t); + let row = rows + .into_iter() + .find(|r| r.key.eq_ignore_ascii_case(&key)) + .ok_or(StatusCode::NOT_FOUND)?; + let recs = pr_view::records_of(&claims.team_id, items); + let rec: PrRecord = recs + .into_iter() + .find(|r| r.repo.eq_ignore_ascii_case(&q.repo) && r.number == q.number) + .ok_or(StatusCode::NOT_FOUND)?; + let open_keys = Default::default(); + let run = joins.runs.get(&rec.coderhelm.run_id); + let facts = pr_view::facts_of(&rec, run, joins.reviews.get(&row.key), &open_keys); + let needs = common::pr_needs::decide(&rec.repo, &facts); + let runs: Vec = run.cloned().into_iter().collect(); + let runs_out: Vec = runs + .iter() + .map(|r| { + json!({ + "run_id": r.run_id, + "title": r.title, + "status": r.status, + "started_at": (!r.created_at.is_empty()).then_some(&r.created_at), + "ended_at": (!common::pr_view::RUN_ACTIVE.contains(&r.status.as_str()) && !r.updated_at.is_empty()).then_some(&r.updated_at), + "url": format!("/runs/detail?id={}", r.run_id), + }) + }) + .collect(); + Ok(Json(json!({ + "pr": row, + "checklist": common::pr_needs::checklist(&facts), + "ledger": pr_view::ledger(&rec, &needs, t), + "timeline": pr_view::timeline(&rec, &runs), + "runs": runs_out, + "synced_at": pr_view::rfc3339(rec.synced_at.max(rec.event_at)), + }))) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn q(f: impl FnOnce(&mut ListQuery)) -> ListQuery { + let mut l = ListQuery::default(); + f(&mut l); + l + } + + #[test] + fn the_query_takes_only_its_own_words() { + assert!(query_of(q(|l| l.turn = Some("you".into()))).is_ok()); + assert!(query_of(q(|l| l.turn = Some("everyone".into()))).is_err()); + assert!(query_of(q(|l| l.state = Some("needs_review,draft".into()))).is_ok()); + assert!(query_of(q(|l| l.state = Some("mergeable".into()))).is_err()); + assert!(query_of(q(|l| l.view = Some("my_turn".into()))).is_ok()); + assert!(query_of(q(|l| l.repo = Some("acme/../web".into()))).is_err()); + let (_, limit, _) = query_of(q(|l| l.limit = Some(9_999))).unwrap(); + assert_eq!(limit, 200); + } + + #[test] + fn a_waiting_run_is_its_hand_off_and_a_paused_one_is_not() { + let mut item = Item::new(); + item.insert("run_id".into(), AttributeValue::S("01AAAA".into())); + item.insert("status".into(), AttributeValue::S("needs_input".into())); + item.insert( + "waiting_on".into(), + AttributeValue::S( + r#"{"action":"Choose how stock counts migrate","handback":"product_decision"}"# + .into(), + ), + ); + let j = run_join(&item); + assert_eq!( + j.stop.as_ref().map(|s| s.code.as_str()), + Some("product_decision") + ); + assert!(j.stop.unwrap().text.contains("stock counts")); + } + + #[test] + fn the_reviewers_records_join_by_pull_request() { + let mut live = Item::new(); + live.insert( + "sk".into(), + AttributeValue::S(common::review_live::record_sk("acme", "web", 318)), + ); + live.insert("phase".into(), AttributeValue::S("reviewing".into())); + live.insert("job".into(), AttributeValue::S("job-1".into())); + let j = review_joins(&[live], &[], 0); + assert!(j["acme/web#318"].reviewing); + assert_eq!(j["acme/web#318"].session_id, "job-1"); + } +} diff --git a/services/worker/src/main.rs b/services/worker/src/main.rs index accbe1601..53056b38e 100644 --- a/services/worker/src/main.rs +++ b/services/worker/src/main.rs @@ -808,6 +808,16 @@ async fn handle_message_inner(state: Arc, message: models::WorkerMe if let Err(e) = as_sweep(who::SWEEP_SKILLS, passes::skills::sweep(&state)).await { error!("Skill repository sweep failed: {e:?}"); } + // Every open pull request's record (the pull requests view): + // each team at most once an hour, one search per organization. + let prs = as_sweep(who::SWEEP_DASHBOARD_PRS, passes::pr_records::sweep(&state)).await; + info!( + teams = prs.teams, + written = prs.written, + removed = prs.removed, + pages = prs.pages, + "Pull request records sync done" + ); // Stale pull requests: each repository at most once an hour. let stale = as_sweep(who::SWEEP_STALE_PRS, passes::stale_prs::sweep(&state)).await; info!( @@ -1152,6 +1162,9 @@ async fn handle_message_inner(state: Arc, message: models::WorkerMe models::WorkerMessage::ChangeWaitCheck(msg) => { passes::change_wait::check_all(&state, Some(&msg.team_id)).await; } + models::WorkerMessage::PrRecordsSync(msg) => { + passes::pr_records::sync_message(&state, &msg).await; + } models::WorkerMessage::RoleReadsWait(msg) => { passes::role_wait::check(&state, &msg).await; } diff --git a/services/worker/src/passes/await_merge.rs b/services/worker/src/passes/await_merge.rs index 19c31b892..fe6fd264b 100644 --- a/services/worker/src/passes/await_merge.rs +++ b/services/worker/src/passes/await_merge.rs @@ -652,6 +652,18 @@ pub(crate) fn decide_gate(v: &GateView) -> GateDecision { } Ci::Green => { lines.push((Mark::Done, "CI green".to_string())); + // The shared needs function has the last word: the gate merges + // only what the pull requests view shows as ready. + let needs = common::pr_needs::decide("", &gate_facts(v, Some(&Ci::Green))); + if !needs.state.is_ready() { + lines.push((Mark::Waiting, needs.next.text)); + return GateDecision { + state: STATE_WAITING_APPROVAL, + lines, + note: None, + action: Action::WaitForPeople, + }; + } GateDecision { state: STATE_WAITING_CI, lines, @@ -662,6 +674,66 @@ pub(crate) fn decide_gate(v: &GateView) -> GateDecision { } } +/// Pure: what the gate knows, as the shared needs function +/// (`common::pr_needs::decide`) reads it. `ci` is the gate's reading of the +/// head's checks, `None` before it reads them. Conflicts are read by the +/// merge itself (`MergeOutcome::BaseMoved`), so the gate's facts say none. +pub(crate) fn gate_facts(v: &GateView, ci: Option<&Ci>) -> common::pr_needs::Facts { + use common::pr_needs::{Checks, Facts}; + let human = person_key(v); + let mut checks = Checks::default(); + match ci { + Some(Ci::Green) => { + checks.known = true; + checks.total = 1; + checks.passed = 1; + } + Some(Ci::Pending(names)) => { + checks.known = true; + checks.total = names.len().max(1) as u32; + checks.running = names.clone(); + } + Some(Ci::Failing(names)) => { + checks.known = true; + checks.total = names.len().max(1) as u32; + checks.failed = names.clone(); + } + None => {} + } + let approved_by = if !human { + Vec::new() + } else if v.approvals.approved_at_head.is_empty() { + v.approvals.approved_by.clone() + } else { + v.approvals.approved_at_head.clone() + }; + Facts { + known: true, + draft: v.draft, + head: v.head.clone(), + base: v.base.clone(), + coderhelm_verdict: v + .bot_verdict + .clone() + .filter(|_| !v.approvals.bot_dismissed_at_head) + .map(|verdict| (verdict, v.head.clone())), + changes_requested_by: v.approvals.blocking_by.clone(), + approved_by, + requested: v.requested.clone(), + review_decision: v.review_decision.clone(), + approvals_required: v + .rules + .required_approvals + .unwrap_or(0) + .min(u64::from(u32::MAX)) as u32, + team_requires_approval: v.require_human, + conflict: Some(false), + checks, + coderhelm_merges: true, + ..Default::default() + } +} + /// Pure: the panel's lines for CoderHelm's block: what holds it, as the review /// named it. A review older than named items points at the review. fn holding_lines(holding: &[String]) -> Vec<(Mark, String)> { diff --git a/services/worker/src/passes/incidents/bm_teams_never_cross.rs b/services/worker/src/passes/incidents/bm_teams_never_cross.rs index b2b40f107..f4988d90c 100644 --- a/services/worker/src/passes/incidents/bm_teams_never_cross.rs +++ b/services/worker/src/passes/incidents/bm_teams_never_cross.rs @@ -353,6 +353,7 @@ const CACHES: &[(&str, &str)] = &[ ("gateway/src/permissions.rs::ROUTES", "route table; no data"), ("gateway/src/routes/chat_work_prs.rs::CACHE", "URL, reused only on a 304 to the team's own token; repo checked against the team's repos first"), ("gateway/src/routes/github_webhook.rs::SEEN", "installation id; log throttle"), + ("gateway/src/routes/prs.rs::LIST", "installation id plus the team id (read_key(installation_id, \"prs#\")); its rows keep only that team's records"), ("gateway/src/routes/roles.rs::CACHE", "(team, role)"), ("gateway/src/routes/run_checks.rs::TOKENS", "installation id"), ("gateway/src/routes/run_checks.rs::PR_HEADS", "installation id (read_key)"), diff --git a/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs new file mode 100644 index 000000000..348e869bd --- /dev/null +++ b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs @@ -0,0 +1,331 @@ +//! xw. A team asked which pull requests were open in its repositories and +//! what each one needed. Nothing could say: the gateway dropped every event +//! of a pull request CoderHelm hadn't opened ("Only track our PRs"), the +//! reviewer's records covered only the pull requests it reviewed and +//! expired after 30 days, and the run page, the reviewer's auto-merge gate +//! and the reviewer page each read what a pull request needed in their own +//! way. +//! +//! Guarantees: +//! - every open pull request of the team's repositories has a record, +//! written from its events (any author) and the sync, and appears in the +//! list; +//! - each pull request has exactly one state from one function +//! (`common::pr_needs::decide`), and a pull request whose facts aren't +//! known yet is `unknown`, shown and counted, never dropped; +//! - the merge gates and the list read that same function, so they can't +//! disagree; +//! - a record of another team never reaches a row. + +use aws_sdk_dynamodb::types::AttributeValue; +use common::merge_standing; +use common::pr_needs::{self, Checks, Facts, Own, OwnStanding, State}; +use common::pr_record::{self, Item, PrRecord}; +use common::pr_view::{self, Joins, Query}; + +use crate::passes::await_merge::{ + decide_gate, gate_facts, Action, CheckSummary, Ci, GateView, ReviewRules, +}; +use crate::passes::review_actions::Approvals; + +const NOW: i64 = 1_800_000_000; +const HEAD: &str = "9f8e7d6c5b4a39281706f5e4d3c2b1a098765432"; + +fn item(team: &str, rec: &PrRecord) -> Item { + let mut i = Item::new(); + i.insert("pk".into(), AttributeValue::S(team.into())); + i.insert( + "sk".into(), + AttributeValue::S(pr_record::record_sk(&rec.repo, rec.number)), + ); + i.insert( + "doc".into(), + AttributeValue::S(serde_json::to_string(rec).expect("record")), + ); + i +} + +fn opened(n: u64, author: &str) -> serde_json::Value { + serde_json::json!({ + "action": "opened", + "sender": {"login": author}, + "pull_request": { + "number": n, "title": format!("Bookstore change {n}"), + "html_url": format!("https://github.com/acme/web/pull/{n}"), + "user": {"login": author}, "draft": false, "state": "open", "merged": false, + "head": {"sha": HEAD, "ref": format!("change-{n}")}, "base": {"ref": "main"}, + "created_at": "2026-01-10T10:00:00Z", "updated_at": "2026-01-10T10:00:00Z", + "requested_reviewers": [], "requested_teams": [], "labels": [] + } + }) +} + +fn src(path: &str) -> String { + let root = concat!(env!("CARGO_MANIFEST_DIR"), "/.."); + std::fs::read_to_string(format!("{root}/{path}")).unwrap_or_else(|e| panic!("{path}: {e}")) +} + +#[test] +fn every_open_pull_request_appears_whoever_opened_it() { + let team = "TEAM#bookstore"; + let mut items = Vec::new(); + // A person's pull request, CoderHelm's, a draft, and one only a check + // event has named so far. + for (n, author) in [(1, "octocat"), (2, "coderhelm[bot]"), (3, "mara")] { + let mut r = PrRecord::new("acme/web", n); + assert!(r.apply_event("pull_request", &opened(n, author), NOW)); + if n == 3 { + r.draft = true; + } + items.push(item(team, &r)); + } + let mut only_checks = PrRecord::new("acme/web", 4); + let run = + serde_json::json!({"check_run": {"name": "unit", "head_sha": HEAD, "status": "queued"}}); + assert!(only_checks.apply_event("check_run", &run, NOW)); + items.push(item(team, &only_checks)); + let rows = pr_view::rows(team, &items, &Joins::default(), None, NOW); + let page = pr_view::page(rows, &Query::default(), 200, None); + assert_eq!(page.total, 4); + let mut numbers: Vec = page.rows.iter().map(|r| r.number).collect(); + numbers.sort(); + assert_eq!(numbers, vec![1, 2, 3, 4]); + + // Every pull request event reaches the writer, before any handler's + // early return, and the writer names the pull request of each. + let hook = src("gateway/src/routes/github_webhook.rs"); + let dispatch = &hook[hook.find("async fn dispatch(").expect("dispatch")..]; + let dispatch = &dispatch[..dispatch + .find("\nasync fn route_event(") + .expect("route_event")]; + assert!(dispatch.contains("super::prs::on_webhook(state, team_id, event_type, payload)")); + for ev in [ + "\"pull_request\"", + "\"pull_request_review\"", + "\"pull_request_review_comment\"", + "\"issue_comment\"", + "\"check_run\"", + "\"check_suite\"", + "\"status\"", + "\"push\"", + ] { + assert!(dispatch.contains(ev), "{ev} isn't written"); + } + assert!(!hook.contains("// Only track our PRs")); + // The install and the sweep read the pull requests opened before. + assert!(hook.contains("WorkerMessage::PrRecordsSync(")); + let main = src("worker/src/main.rs"); + assert!(main.contains("passes::pr_records::sweep(&state)")); + assert!(main.contains("passes::pr_records::sync_message(&state, &msg)")); + // No expiry while open. + let mut r = PrRecord::new("acme/web", 1); + assert_eq!(r.ttl(), None); + r.status = "closed".into(); + assert!(r.ttl().is_some()); +} + +#[test] +fn one_state_per_pull_request_and_unknown_is_shown() { + let mut seen = std::collections::BTreeSet::new(); + let base = Facts { + known: true, + head: HEAD.into(), + author: "octocat".into(), + conflict: Some(false), + checks: Checks { + known: true, + total: 1, + passed: 1, + ..Default::default() + }, + ..Default::default() + }; + // Every combination of the facts that hold the merge gets exactly one + // state, and the same facts always the same one. + for bits in 0u32..(1 << 9) { + let mut f = base.clone(); + let on = |i: u32| bits & (1 << i) != 0; + f.draft = on(0); + f.conflict = if on(1) { Some(true) } else { f.conflict }; + if on(2) { + f.checks.failed = vec!["lint".into()]; + } + if on(3) { + f.checks.running = vec!["unit".into()]; + } + if on(4) { + f.changes_requested_by = vec!["mara".into()]; + } + f.approvals_required = if on(5) { 1 } else { 0 }; + f.known = !on(6); + f.checks.known = !on(7); + f.coderhelm_merges = on(8); + let a = pr_needs::decide("acme/web", &f); + let b = pr_needs::decide("acme/web", &f); + assert_eq!(a, b); + assert!(!a.next.text.is_empty()); + assert!(pr_needs::ALL.contains(&a.state)); + seen.insert(a.state); + } + assert!(seen.contains(&State::Unknown)); + + // An unknown pull request is a row, counted under its state. + let team = "TEAM#bookstore"; + let mut r = PrRecord::new("acme/web", 9); + r.apply_event( + "check_run", + &serde_json::json!({"check_run": {"name": "unit", "head_sha": HEAD, "status": "queued"}}), + NOW, + ); + let rows = pr_view::rows(team, &[item(team, &r)], &Joins::default(), None, NOW); + let page = pr_view::page(rows, &Query::default(), 50, None); + assert_eq!(page.rows.len(), 1); + assert_eq!(page.rows[0].state, "unknown"); + assert_eq!(page.counts.state.get("unknown"), Some(&1)); + assert_eq!(page.rows[0].turn, "machines"); +} + +fn gate_view() -> GateView { + GateView { + draft: false, + require_human: true, + bot_verdict: Some("APPROVE".into()), + bot_holding: vec![], + approvals: Approvals::default(), + want_labels: vec![], + present_labels: vec![], + labels_added_at: None, + taken_off: vec![], + preview_ran: vec![], + ci: None, + now: NOW, + head: HEAD.into(), + base: "main".into(), + review_decision: None, + earlier_approval_holds: false, + rules: ReviewRules::default(), + requested: vec![], + base_merge_at_head: false, + } +} + +#[test] +fn the_merge_gates_and_the_list_read_one_decision() { + // The reviewer's auto-merge gate merges exactly when the list says + // ready, over every combination of what it weighs. + for bits in 0u32..(1 << 8) { + let on = |i: u32| bits & (1 << i) != 0; + let mut v = gate_view(); + v.draft = on(0); + v.require_human = on(1); + v.bot_verdict = match (on(2), on(3)) { + (true, _) => Some("APPROVE".into()), + (false, true) => Some("REQUEST_CHANGES".into()), + _ => None, + }; + if on(4) { + v.approvals.approved_by = vec!["mara".into()]; + v.approvals.approved_at_head = vec!["mara".into()]; + } + if on(5) { + v.approvals.blocking_by = vec!["jun".into()]; + } + let summary = match (on(6), on(7)) { + (false, false) => CheckSummary::default(), + (true, false) => CheckSummary { + failing: vec!["lint".into()], + ..Default::default() + }, + _ => CheckSummary { + pending: vec!["unit".into()], + ..Default::default() + }, + }; + let ci = summary.ci(); + v.ci = Some(summary); + let gate = decide_gate(&v); + let list = pr_needs::decide("acme/web", &gate_facts(&v, Some(&ci))); + assert_eq!( + gate.action == Action::Merge, + list.state.is_ready(), + "bits {bits:08b}: the gate says {:?}, the list says {:?}", + gate.action, + list.state + ); + if matches!(ci, Ci::Failing(_)) { + assert_ne!(gate.action, Action::Merge); + } + } + + // The run's watch stores the standing this function decides, and the + // list reads the stored standing to the same state. + let watch = src("worker/src/passes/pr_watch.rs"); + assert!(watch.contains("common::pr_needs::run_standing(")); + assert!(!watch.contains("merge_standing::decide(")); + let gate = src("worker/src/passes/await_merge.rs"); + assert!(gate.contains("common::pr_needs::decide(\"\", &gate_facts(v, Some(&Ci::Green)))")); + for bits in 0u32..(1 << 6) { + let on = |i: u32| bits & (1 << i) != 0; + let facts = merge_standing::Facts { + head: HEAD.into(), + reviewer_on: on(0), + own_verdict: on(1).then(|| ("APPROVE".to_string(), HEAD.to_string())), + auto_merge: on(2), + require_human_approval: on(3), + conflict: on(4), + checks_running: on(5), + ..Default::default() + }; + let standing = pr_needs::run_standing("acme/web", &facts); + assert_eq!(standing, merge_standing::decide("acme/web", &facts)); + let stored = Facts { + known: true, + head: HEAD.into(), + author: "coderhelm[bot]".into(), + author_is_coderhelm: true, + own: Some(Own { + standing: Some(OwnStanding::Decided(standing.clone())), + ..Default::default() + }), + ..Default::default() + }; + let fresh = Facts { + own: Some(Own { + standing: Some(OwnStanding::Facts(facts)), + ..Default::default() + }), + ..stored.clone() + }; + let a = pr_needs::decide("acme/web", &stored); + let b = pr_needs::decide("acme/web", &fresh); + assert_eq!(a.state, b.state); + assert_eq!(a.next.code, standing.code); + } +} + +#[test] +fn no_pull_request_of_another_team_reaches_a_row() { + let mine = PrRecord { + known: true, + ..PrRecord::new("acme/web", 1) + }; + let theirs = PrRecord { + known: true, + ..PrRecord::new("acme/web", 2) + }; + let items = vec![item("TEAM#a", &mine), item("TEAM#b", &theirs)]; + let rows = pr_view::rows("TEAM#a", &items, &Joins::default(), None, NOW); + assert_eq!(rows.iter().map(|r| r.number).collect::>(), vec![1]); + assert!(pr_view::records_of("TEAM#c", &items).is_empty()); + + // The reads are keyed by the session's team, the runs it joins are + // the team's, and the cache names the installation and the team. + let prs = src("gateway/src/routes/prs.rs"); + assert!(prs.contains("read_all(&state, &claims.team_id)")); + assert!(prs.contains("pr_view::rows(&claims.team_id, items, joins, viewer")); + assert!(prs.contains("read_key(installation_id, &format!(\"prs#{team_id}\"))")); + assert!(prs.contains("if s(item, \"team_id\") != team_id {")); + assert!(!prs.contains("q.team")); + let perms = src("gateway/src/permissions.rs"); + assert!(perms.contains("\"prs::list_prs\"") && perms.contains("\"prs::get_pr\"")); +} diff --git a/services/worker/src/passes/mod.rs b/services/worker/src/passes/mod.rs index efb87db81..468c76ce8 100644 --- a/services/worker/src/passes/mod.rs +++ b/services/worker/src/passes/mod.rs @@ -1403,6 +1403,7 @@ pub mod plugins; mod pr; mod pr_holder; pub mod pr_outcomes; +pub mod pr_records; mod pr_risk; pub mod pr_watch; pub mod preview; diff --git a/services/worker/src/passes/pr_records.rs b/services/worker/src/passes/pr_records.rs new file mode 100644 index 000000000..bda8dce40 --- /dev/null +++ b/services/worker/src/passes/pr_records.rs @@ -0,0 +1,227 @@ +//! The sync of every open pull request's record (`common::pr_record`): +//! one GraphQL search per organization of the team's repositories, under +//! the shared GitHub budget (`sweep:dashboard_prs`). +//! +//! The webhooks keep each record current; the sync reads what they don't +//! carry (the review decision, the branch's rules, conflicts, open +//! conversations), adds the pull requests opened before the install, and +//! removes the records of pull requests no longer open. It runs when the +//! app is installed or repositories are added (`PrRecordsSync`), and on the +//! sweep tick at most once an hour per team. +//! +//! Bounds: [`pr_record::MAX_PAGES`] pages of 30 per organization, each one +//! counted request, each asked of the budget first ([`SweepGate`]); a +//! record is removed only when the search was read to its end. + +use std::collections::HashSet; + +use common::github_budget::caller as who; +use common::pr_record; +use serde_json::json; +use tracing::{info, warn}; + +use crate::clients::github::GitHubClient; +use crate::clients::github_budget::SweepGate; +use crate::WorkerState; + +/// What one sweep did. +#[derive(Debug, Default)] +pub struct SweepReport { + pub teams: usize, + pub written: usize, + pub removed: usize, + pub pages: u32, +} + +/// The sweep tick: each team at most once an hour. +pub async fn sweep(state: &WorkerState) -> SweepReport { + let mut report = SweepReport::default(); + let mut gate = SweepGate::new(who::SWEEP_DASHBOARD_PRS); + let hour = chrono::Utc::now().format("%Y%m%d%H").to_string(); + for team in super::learning_wait::teams(state).await { + let Some(iid) = super::review_reminder::team_installation_id(state, &team).await else { + continue; + }; + let claim = format!("PRREC_SYNC#{hour}"); + if !super::review_pr::claim_once_ttl(state, &team, &claim, 2 * 3600).await { + continue; + } + report.teams += 1; + sync_team(state, &team, iid, &mut gate, &mut report).await; + } + report +} + +/// One team, now (the install's first read). +pub async fn sync_message(state: &WorkerState, msg: &common::messages::PrRecordsSyncMessage) { + let mut gate = SweepGate::new(who::SWEEP_DASHBOARD_PRS); + let mut report = SweepReport::default(); + crate::clients::github_budget::scoped( + who::SWEEP_DASHBOARD_PRS, + sync_team( + state, + &msg.team_id, + msg.installation_id, + &mut gate, + &mut report, + ), + ) + .await; + info!( + team_id = %msg.team_id, + written = report.written, + removed = report.removed, + pages = report.pages, + "Pull request records read at install" + ); +} + +/// Pure: the organizations to search, from the team's connected +/// repositories, and the repositories kept. +pub fn owners_of(repos: &[String]) -> (Vec, HashSet) { + let keep: HashSet = repos.iter().map(|r| r.to_ascii_lowercase()).collect(); + let mut owners: Vec = repos + .iter() + .filter_map(|r| r.split_once('/').map(|(o, _)| o.to_string())) + .collect(); + owners.sort(); + owners.dedup(); + (owners, keep) +} + +async fn sync_team( + state: &WorkerState, + team_id: &str, + installation_id: u64, + gate: &mut SweepGate, + report: &mut SweepReport, +) { + let repos: Vec = super::infra_repo::team_repos(state, team_id) + .await + .into_iter() + .filter(|r| r.enabled) + .map(|r| r.full_name) + .collect(); + let (owners, keep) = owners_of(&repos); + if owners.is_empty() { + return; + } + let github = match GitHubClient::new( + &state.secrets.github_app_id, + &state.secrets.github_private_key, + installation_id, + &state.http, + ) { + Ok(g) => g, + Err(e) => { + warn!(team_id, error = %e, "Pull request sync: no GitHub client"); + return; + } + }; + let table = &state.config.settings_table_name; + for owner in owners { + let mut seen: HashSet = HashSet::new(); + let mut complete = false; + let mut after: Option = None; + let mut as_org = true; + let mut page = 0; + while page < pr_record::MAX_PAGES { + if !gate.allows(state, installation_id, 1).await { + break; + } + let vars = json!({"q": pr_record::search_text(&owner, as_org), "after": after}); + let data = match github.graphql_read(pr_record::SEARCH_QUERY, vars).await { + Ok(d) => d, + // A personal account's repositories are searched by user. + Err(_) if as_org && page == 0 => { + as_org = false; + continue; + } + Err(e) => { + warn!(team_id, owner = %owner, error = %e, "Pull request sync: search failed"); + break; + } + }; + page += 1; + report.pages += 1; + let now = chrono::Utc::now().timestamp(); + for node in data["search"]["nodes"].as_array().into_iter().flatten() { + let repo = node["repository"]["nameWithOwner"].as_str().unwrap_or(""); + let Some(number) = node["number"].as_u64() else { + continue; + }; + if !keep.contains(&repo.to_ascii_lowercase()) { + continue; + } + seen.insert(format!("{}#{number}", repo.to_ascii_lowercase())); + let written = + pr_record::update(&state.dynamo, table, team_id, repo, number, now, |r| { + r.apply_node(node, now); + true + }) + .await; + match written { + Ok(Some(rec)) => { + report.written += 1; + let _ = pr_record::point(&state.dynamo, table, team_id, &rec, now).await; + } + Ok(None) => {} + Err(e) => { + warn!(team_id, repo, number, error = %e, "Pull request record not synced") + } + } + } + let info = &data["search"]["pageInfo"]; + if info["hasNextPage"].as_bool() != Some(true) { + complete = true; + break; + } + after = info["endCursor"].as_str().map(str::to_string); + } + if !complete { + continue; + } + // Read to its end: a record of this owner's still marked open that + // the search no longer lists is no longer open. + let items = match pr_record::all(&state.dynamo, table, team_id).await { + Ok(i) => i, + Err(e) => { + warn!(team_id, error = %e, "Pull request sync: records not read"); + continue; + } + }; + // The search index trails GitHub by a little: a pull request an + // event touched in the last hour is never taken off. + let recent = chrono::Utc::now().timestamp() - 3600; + for rec in items { + if rec.event_at > recent { + continue; + } + let key = format!("{}#{}", rec.repo.to_ascii_lowercase(), rec.number); + if rec.org().eq_ignore_ascii_case(&owner) && rec.is_open() && !seen.contains(&key) { + match pr_record::delete(&state.dynamo, table, team_id, &rec.repo, rec.number).await + { + Ok(()) => report.removed += 1, + Err(e) => warn!(team_id, error = %e, "Pull request record not removed"), + } + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn each_organization_is_searched_once_and_only_connected_repos_are_kept() { + let (owners, keep) = owners_of(&[ + "acme/web".to_string(), + "acme/api".to_string(), + "octocat/bookstore".to_string(), + ]); + assert_eq!(owners, vec!["acme", "octocat"]); + assert!(keep.contains("acme/web")); + assert!(!keep.contains("acme/infra")); + } +} diff --git a/services/worker/src/passes/pr_watch.rs b/services/worker/src/passes/pr_watch.rs index 570d8ad9c..518046b52 100644 --- a/services/worker/src/passes/pr_watch.rs +++ b/services/worker/src/passes/pr_watch.rs @@ -1142,7 +1142,9 @@ async fn standing( ), None => (Vec::new(), None), }; - let standing = merge_standing::decide( + // The one decision the run page, the merge gate and the pull requests + // view share (`common::pr_needs`). + let standing = common::pr_needs::run_standing( &format!("{}/{}", c.owner, c.repo), &merge_standing::Facts { approvals_required, From da7e4e7c6b53bd506639c3873047a9186e92b48e Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 11:57:38 -0500 Subject: [PATCH 02/19] Format the pull requests route --- services/gateway/src/routes/prs.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/services/gateway/src/routes/prs.rs b/services/gateway/src/routes/prs.rs index 9c7057222..238b9db29 100644 --- a/services/gateway/src/routes/prs.rs +++ b/services/gateway/src/routes/prs.rs @@ -314,10 +314,7 @@ async fn runs_by_id(state: &AppState, team_id: &str, ids: &[String]) -> HashMap< } /// The team's records and joins, from the short cache or the tables. -async fn read_all( - state: &AppState, - team_id: &str, -) -> Result<(Snapshot, Vec), StatusCode> { +async fn read_all(state: &AppState, team_id: &str) -> Result<(Snapshot, Vec), StatusCode> { let installation_id = super::api::get_team_installation_id(state, team_id) .await .unwrap_or(0); From 9ef4f5d2fda8ba0d960ba254d84ecd1c66acd834 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 12:29:52 -0500 Subject: [PATCH 03/19] Keep each pull request's history, change log and nightly percentiles for the org overview Every duration starts at ready for review, and human review leaves out the author and every bot. Records keep their state and turn change log, people's reviews and review requests, and check transitions. A merged or closed pull request leaves a history row kept 400 days with its run and session links and revert and follow-up links. A nightly job writes each org's and repository's snapshot and percentiles, team-scoped and bounded. --- docs/pull-requests.md | 10 + docs/pull-requests/api_contract.md | 114 +++ services/common/src/lib.rs | 1 + services/common/src/pr_history.rs | 771 ++++++++++++++++++ services/common/src/pr_needs.rs | 85 ++ services/common/src/pr_record.rs | 285 ++++++- services/common/src/pr_view.rs | 7 + services/gateway/src/routes/prs.rs | 52 ++ services/worker/src/main.rs | 4 + .../xw_every_open_pr_has_one_state.rs | 5 + services/worker/src/passes/pr_records.rs | 43 + 11 files changed, 1369 insertions(+), 8 deletions(-) create mode 100644 docs/pull-requests/api_contract.md create mode 100644 services/common/src/pr_history.rs diff --git a/docs/pull-requests.md b/docs/pull-requests.md index 0a78256e4..a79896e45 100644 --- a/docs/pull-requests.md +++ b/docs/pull-requests.md @@ -11,6 +11,16 @@ One settings-table item per pull request (`pk` = team id, `sk = PRREC##`) is written and kept 400 days: ready, first human review, CoderHelm's first review, final approval, merge or close and who merged, rounds of changes requested, size, author type, CoderHelm's part (author, fixer, reviewer or none) with its runs and review sessions, the change log, and links. +- **Reverts and follow-ups.** A merged revert ("Reverts owner/repo#n") marks the pull request it reverts; a merged pull request that names an earlier merged one within 14 days of its merge marks it as followed up. Both are labeled a proxy for a failed change. +- **The nightly snapshot** (`sk = PRSNAP##`, kept 400 days), once a day per team and per org and repository (the first 300): open pull requests by stage and turn, how many are past the scope's p85, arrivals, merges (by author type), closed without merging, reviews asked and done, reverts, and the percentiles: cycle time p50, p85 and p95 over 90 days, first human review p50 and p85 over 8 weeks, and each stage's p85. A repository with fewer than 30 merges in 90 days uses its org's percentiles and says so; an org with less than 8 weeks of history is marked young, so the page shows external bands instead. The job reads only the team's own records and history (at most 25,000 history rows) and makes no GitHub requests. + ## One state per pull request `services/common/src/pr_needs.rs` decides the state from the facts, first match wins: merged, closed, in the merge queue, left the queue, CoderHelm working, needs a decision, draft, waiting on another pull request, conflicts, checks failing, changes requested, re-review, needs a reviewer, needs review, needs a code owner, open conversations, checks running, ready with auto-merge on, ready to merge. A pull request whose facts aren't known yet is **not synced yet** (`unknown`): shown and counted, never dropped. diff --git a/docs/pull-requests/api_contract.md b/docs/pull-requests/api_contract.md new file mode 100644 index 000000000..bfa99cc47 --- /dev/null +++ b/docs/pull-requests/api_contract.md @@ -0,0 +1,114 @@ +# /api/prs contract (platform PR and dashboard PR share this) + +All times are RFC 3339 UTC strings. All example data invented (acme/web, octocat, the bookstore). + +## GET /api/prs + +Query (all optional): `org`, `repo` (owner/name), `turn` (you|person|coderhelm|machines|done), +`state` (one State code, or several joined by ","), `person` (a GitHub login: involves), +`q` (free text: title, repo, number, author, branch), `view` (my_turn|coderhelm_working|needs_decision|ready|stale), +`limit` (1..200, default 100), `cursor` (opaque string from `next`). + +Team comes from the session only. 404 from an older backend means "not served yet". + +```json +{ + "prs": [PrRow], + "total": 37, + "next": "o:100" , + "counts": { + "turn": {"you": 2, "person": 9, "coderhelm": 4, "machines": 6, "done": 1}, + "state": {"needs_review": 5, "checks_failing": 2, "unknown": 1}, + "repo": {"acme/web": 20, "acme/api": 17}, + "org": {"acme": 37}, + "views": {"my_turn": 2, "coderhelm_working": 4, "needs_decision": 1, "ready": 3, "stale": 2} + }, + "viewer": "octocat", + "synced_at": "2026-01-10T12:00:00Z", + "sources": [{"name": "webhooks", "read": "ok", "detail": ""}, {"name": "reconcile", "read": "ok", "detail": "acme: 37 open pull requests read"}] +} +``` +`counts` are over the scope (org/repo) BEFORE the turn/state/person/q/view filters, so the strip and the saved views always show their totals. `total` is after filters. + +### PrRow +```json +{ + "key": "acme/web#318", + "org": "acme", "repo": "acme/web", "number": 318, + "title": "Round cart totals per currency", + "url": "https://github.com/acme/web/pull/318", + "author": {"login": "coderhelm[bot]", "coderhelm": true}, + "for": "octocat", + "draft": false, "base": "main", "head": "fix/cart-rounding", + "created_at": "...", "updated_at": "...", + "state": "checks_failing", + "state_label": "Checks failing", + "stage": "blocked", + "ready_at": "...", + "turn": "coderhelm", + "next": {"code": "checks_failing", "text": "Checks fail on lint: CoderHelm is fixing them, round 2.", "from": ["coderhelm"], "since": "...", "rule": "required_check"}, + "modifiers": ["stale", "stacked", "agent_authored", "large"], + "people": [{"login": "octocat", "roles": ["requester", "reviewer"], "coderhelm": false}], + "checks": {"total": 12, "passed": 10, "failed": 1, "running": 1, "required_failed": ["lint"], "known": true}, + "reviews": {"approvals": 1, "required": 2, "changes_requested_by": [], "requested": ["mara"], "coderhelm_verdict": "APPROVE"}, + "conflict": false, + "open_threads": 0, + "labels": ["hotfix"], + "size": {"additions": 240, "deletions": 31}, + "last_action": {"actor": "coderhelm", "text": "pushed 2 commits", "at": "..."}, + "coderhelm": {"run_id": "...", "session_id": "...", "round": 2, "working": true, "what": "Fixing CI"}, + "links": [{"kind": "depends", "repo": "acme/api", "number": 12, "url": "https://github.com/acme/api/pull/12", "state": "needs_review"}], + "waiting_since": "..." +} +``` +`from` entries: `coderhelm`, `ci`, `queue`, `nobody`, `person:`, `team:/`, `author`. +`rule`: `repo_rule` | `codeowners` | `required_check` | `team_rule` | `branch_rule` | null. +`turn`: "you" when the viewer's login is in `from` (or is the author on an author turn). + +### States (exactly one per PR, first match wins) +merged, closed, in_queue, left_queue, coderhelm_working, needs_decision, draft, waiting_on_pr, +conflicts, checks_failing, changes_requested, re_review, needs_reviewer, needs_review, +needs_code_owner, open_threads, checks_running, ready_auto_merge, ready_to_merge, unknown. + +Turn per state: merged/closed = done; in_queue/checks_running/ready_auto_merge/unknown = machines; +coderhelm_working = coderhelm; the others = person or coderhelm (per PR, from `next.from`). + +## GET /api/prs/detail?repo=acme/web&number=318 +```json +{ + "pr": PrRow, + "checklist": [{"key": "checks", "mark": "done|waiting|blocked|none", "text": "Required checks 12 of 12 pass", "source": "required_check"}], + "ledger": {"open_secs": 97200, "spans": [{"who": "person:mara", "from": "...", "to": "...", "secs": 3600}], "totals": [{"who": "coderhelm", "secs": 2820}]}, + "timeline": [{"at": "...", "actor": "octocat", "coderhelm": false, "kind": "review", "text": "approved", "run_id": null}], + "runs": [{"run_id": "...", "title": "Fix CI (lint)", "status": "running", "started_at": "...", "ended_at": null, "url": "/runs/detail?id=..."}], + "synced_at": "..." +} +``` +`kind`: opened, pushed, review, comment, check, queue, run, label, ready, draft, merged, closed, reviewers, state. +Timeline events with a `run_id` belong to that run's collapsible block. 404 when the PR isn't the team's. + + +## Stages (the overview's strip), from `common::pr_needs::stage_of` +`draft`, `first_review`, `in_review`, `blocked`, `coderhelm_working`, `approved` (null once merged or closed). +first_review = needs_reviewer/needs_review with no human review yet; in_review = the same after one, plus changes_requested, re_review, needs_code_owner, open_threads; +blocked = conflicts, checks_failing, waiting_on_pr, left_queue, needs_decision, unknown; approved = in_queue, checks_running, ready_auto_merge, ready_to_merge. +Every age and duration starts at `ready_at` (left draft, else created). Human review excludes the author, CoderHelm and every `[bot]`. + +## Stored shapes the overview reads (shared Rust types; do not fork them) +All settings-table rows, `pk` = team id, body JSON in `doc`. Types live in `services/common/src/pr_record.rs` and `services/common/src/pr_history.rs`. + +- Current row `PRREC#owner/repo#000318` (`pr_record::PrRecord`), no expiry while open, 3 days after close. Adds to the fields above: + `ready_at`, `spans[] {who, state, turn, stage, from}` (the state and turn change log, newest 80), + `review_log[] {who, state, sha, at, human, has_body}`, `request_log[] {who, at, removed_at}`, + `check_log[] {rollup: red|pending|green, at}` (newest 150 each), + `coderhelm {run_id, session_id, run_ids[], session_ids[]}`, `links[] {kind: stack_base|stack_child|plan|depends|contract|references|reverts, repo, number}`. +- History `PRHIST#owner/repo#000318` (`pr_history::History`), written on merge or close, kept 400 days: + `repo, number, title, author, author_type (person|coderhelm|bot), created_at, ready_at, first_human_review_at, first_coderhelm_review_at, final_approval_at, + merged, merged_at, closed_at, merged_by, changes_rounds, additions, deletions, coderhelm_role (author|fixer|reviewer|none), run_ids[], session_ids[], requester, + spans[], review_log[], request_log[], check_log[], links[], reverted_by: [repo, number, at] | null, follow_ups: [[repo, number, at]]`. + Helpers: `cycle_secs()`, `first_review_secs()`, `waiting_on_person_secs()`, `reworked()` (revert or follow-up within 14 days; a proxy). + Attribute `closed_at` (number) for range filters; `pr_history::all_since(team, since)`. +- Daily snapshot `PRSNAP##YYYY-MM-DD` (`pr_history::Snapshot`), scope = `acme` (org) or `acme/web`, kept 400 days, written nightly per team (first 300 repos): + `scope, day, stages {stage: n}, turns {turn: n}, open, past_p85, arrivals, merges, closed_unmerged, review_requests, reviews_done, reverts, merges_by {author_type: n}, + pct {cycle: [p50,p85,p95] secs over 90 days, first_review: [p50,p85] over 8 weeks, stage_p85 {stage: secs}, merged}, inherited (repo under 30 merges uses the org's), young (org under 8 weeks: show external bands)`. + Weekly counts are the 7 days to the snapshot. `pr_history::snapshots_of(team, scope, since_day)` reads them oldest first. diff --git a/services/common/src/lib.rs b/services/common/src/lib.rs index 9c7a9526b..32f2da030 100644 --- a/services/common/src/lib.rs +++ b/services/common/src/lib.rs @@ -273,6 +273,7 @@ pub mod pr_conventions; /// A dependency pull request's facts, from what the pipeline records. pub mod pr_dependency; pub mod pr_facts; +pub mod pr_history; /// Where each part of a description goes, and how a reader would judge it. pub mod pr_layout; pub mod pr_needs; diff --git a/services/common/src/pr_history.rs b/services/common/src/pr_history.rs new file mode 100644 index 000000000..ba1069462 --- /dev/null +++ b/services/common/src/pr_history.rs @@ -0,0 +1,771 @@ +//! What happened to every pull request after it closed, kept long enough to +//! answer "how long do our pull requests usually take" from the org's own +//! history, and the nightly snapshot of each org and repository that the +//! overview reads instead of scanning pull requests on page load. +//! +//! - One history row per merged or closed pull request (`pk` = team id, +//! `sk` = [`hist_sk`]), written when it closes, kept [`HISTORY_KEEP_SECS`] +//! (over a year: a quarter-on-quarter comparison and a year of reverts +//! fit). It carries every duration from **ready for review**, human +//! review times that leave out the author and every bot, the wait +//! ledger's turn changes, the review, request and check logs, CoderHelm's +//! runs and review sessions on it, and its revert and follow-up links. +//! - One snapshot per scope and day (`sk` = [`snap_sk`]): counts by stage +//! and turn, arrivals, merges, reviews asked and done, and the cycle-time +//! percentiles the thresholds come from ([`Percentiles`]). A repository +//! uses its own percentiles once it has [`MIN_MERGED_FOR_OWN`] merges in +//! 90 days, else the org's, and says so ([`Snapshot::inherited`]). +//! +//! Everything here is pure except the storage functions at the end, and +//! every read and write is keyed by the team. + +use std::collections::{BTreeMap, BTreeSet}; + +use aws_sdk_dynamodb::types::AttributeValue; +use aws_sdk_dynamodb::Client as DynamoClient; +use serde::{Deserialize, Serialize}; + +use crate::pr_needs::{self, Stage}; +use crate::pr_record::{ + is_bot, is_coderhelm, CheckTransition, Item, Link, PrRecord, RequestEvent, ReviewEvent, Span, +}; + +/// Sort-key prefix of the history rows. +pub const HIST_PREFIX: &str = "PRHIST#"; +/// Sort-key prefix of the daily snapshots. +pub const SNAP_PREFIX: &str = "PRSNAP#"; +/// How long a history row and a snapshot are kept. +pub const HISTORY_KEEP_SECS: i64 = 400 * 86_400; +/// A repository uses its own percentiles from this many merges in 90 days. +pub const MIN_MERGED_FOR_OWN: usize = 30; +/// Weeks of history before the org's own percentiles stand on their own. +pub const MIN_WEEKS_OWN: i64 = 8; +/// A revert or a follow-up within this long of the merge counts as rework. +pub const REWORK_WINDOW_SECS: i64 = 14 * 86_400; +/// Most repositories one snapshot run covers per team. +pub const MAX_SNAPSHOT_REPOS: usize = 300; +/// Most history rows one snapshot run reads per team. +pub const MAX_HISTORY_READ: usize = 25_000; + +const DAY: i64 = 86_400; + +pub fn hist_sk(repo: &str, number: u64) -> String { + format!("{HIST_PREFIX}{repo}#{number:06}") +} + +/// `org` for the org scope, `org/repo` for a repository. +pub fn snap_sk(scope: &str, day: &str) -> String { + format!("{SNAP_PREFIX}{scope}#{day}") +} + +/// Who wrote it. +pub fn author_type(login: &str) -> &'static str { + if is_coderhelm(login) { + "coderhelm" + } else if is_bot(login) { + "bot" + } else { + "person" + } +} + +/// A merged or closed pull request. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct History { + pub repo: String, + pub number: u64, + pub title: String, + pub author: String, + /// `person`, `coderhelm` or `bot`. + pub author_type: String, + pub created_at: i64, + pub ready_at: i64, + pub first_human_review_at: i64, + pub first_coderhelm_review_at: i64, + pub final_approval_at: i64, + pub merged: bool, + pub merged_at: i64, + pub closed_at: i64, + pub merged_by: String, + /// People's rounds of changes requested. + pub changes_rounds: u32, + pub additions: u32, + pub deletions: u32, + /// CoderHelm's part: `author`, `fixer`, `reviewer` or `none`. + pub coderhelm_role: String, + pub run_ids: Vec, + pub session_ids: Vec, + /// The person who asked CoderHelm for it. + pub requester: String, + pub spans: Vec, + pub review_log: Vec, + pub request_log: Vec, + pub check_log: Vec, + pub links: Vec, + /// The pull request that reverted it, and when. + pub reverted_by: Option<(String, u64, i64)>, + /// Pull requests that named it after it merged (fix-ups), and when. + pub follow_ups: Vec<(String, u64, i64)>, +} + +impl History { + pub fn from_record(r: &PrRecord) -> History { + let role = if r.author_is_coderhelm() { + "author" + } else if !r.coderhelm.run_ids.is_empty() || !r.coderhelm.run_id.is_empty() { + "fixer" + } else if r.first_coderhelm_review_at().is_some() || !r.coderhelm.session_id.is_empty() { + "reviewer" + } else { + "none" + }; + let mut run_ids = r.coderhelm.run_ids.clone(); + if !r.coderhelm.run_id.is_empty() && !run_ids.contains(&r.coderhelm.run_id) { + run_ids.push(r.coderhelm.run_id.clone()); + } + let mut session_ids = r.coderhelm.session_ids.clone(); + if !r.coderhelm.session_id.is_empty() && !session_ids.contains(&r.coderhelm.session_id) { + session_ids.push(r.coderhelm.session_id.clone()); + } + let merged = r.status == "merged"; + History { + repo: r.repo.clone(), + number: r.number, + title: r.title.clone(), + author: r.author.clone(), + author_type: author_type(&r.author).into(), + created_at: r.created_at, + ready_at: r.ready_or_created(), + first_human_review_at: r.first_human_review_at().unwrap_or(0), + first_coderhelm_review_at: r.first_coderhelm_review_at().unwrap_or(0), + final_approval_at: r.final_approval_at().unwrap_or(0), + merged, + merged_at: if merged { r.closed_at } else { 0 }, + closed_at: r.closed_at, + merged_by: r.merged_by.clone(), + changes_rounds: r.changes_rounds(), + additions: r.additions, + deletions: r.deletions, + coderhelm_role: role.into(), + run_ids, + session_ids, + requester: r.requester.clone(), + spans: r.spans.clone(), + review_log: r.review_log.clone(), + request_log: r.request_log.clone(), + check_log: r.check_log.clone(), + links: r.links.clone(), + reverted_by: None, + follow_ups: Vec::new(), + } + } + + /// Ready to merged, in seconds. + pub fn cycle_secs(&self) -> Option { + (self.merged && self.merged_at > 0 && self.ready_at > 0) + .then(|| (self.merged_at - self.ready_at).max(0)) + } + + /// Ready to the first human review, in seconds. + pub fn first_review_secs(&self) -> Option { + (self.first_human_review_at > 0 && self.ready_at > 0) + .then(|| (self.first_human_review_at - self.ready_at).max(0)) + } + + /// Seconds a person held the turn, from ready to the end. + pub fn waiting_on_person_secs(&self) -> i64 { + waiting_on_person( + &self.spans, + self.ready_at, + self.closed_at.max(self.merged_at), + ) + } + + /// Reverted, or fixed by a later pull request, within 14 days of its + /// merge (a proxy for a failed change, labeled as one). + pub fn reworked(&self) -> bool { + let within = |t: i64| { + self.merged_at > 0 && t >= self.merged_at && t - self.merged_at <= REWORK_WINDOW_SECS + }; + self.reverted_by + .as_ref() + .is_some_and(|(_, _, t)| within(*t)) + || self.follow_ups.iter().any(|(_, _, t)| within(*t)) + } +} + +/// Seconds the turn was a person's between `start` and `end`. +pub fn waiting_on_person(spans: &[Span], start: i64, end: i64) -> i64 { + let mut total = 0; + for (i, s) in spans.iter().enumerate() { + let to = spans.get(i + 1).map(|n| n.from).unwrap_or(end); + let from = s.from.max(start); + if s.turn == "person" && to > from { + total += to - from; + } + } + total +} + +/// The value at percentile `p` (0 to 100) of `v`, nearest rank; `None` +/// when empty. +pub fn percentile(v: &[i64], p: u32) -> Option { + if v.is_empty() { + return None; + } + let mut s = v.to_vec(); + s.sort_unstable(); + let rank = ((p as usize * s.len()).div_ceil(100)).max(1); + Some(s[rank.min(s.len()) - 1]) +} + +/// The percentiles a scope's thresholds come from. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Percentiles { + /// Ready to merged over the last 90 days: p50, p85, p95 (seconds). + pub cycle: Vec, + /// Ready to first human review over the last 8 weeks: p50, p85. + pub first_review: Vec, + /// Time in each stage before leaving it, p85, over 90 days. + pub stage_p85: BTreeMap, + /// Merges they come from. + pub merged: usize, +} + +/// One scope's day. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Snapshot { + /// `acme` (the org) or `acme/web`. + pub scope: String, + pub day: String, + /// Open pull requests by stage and by turn. + pub stages: BTreeMap, + pub turns: BTreeMap, + pub open: u32, + /// Open pull requests past the scope's p85 cycle time. + pub past_p85: u32, + /// In the 7 days to the snapshot. + pub arrivals: u32, + pub merges: u32, + pub closed_unmerged: u32, + pub review_requests: u32, + pub reviews_done: u32, + pub reverts: u32, + /// Merges by author type. + pub merges_by: BTreeMap, + pub pct: Percentiles, + /// The scope had too few merges and uses the org's percentiles. + pub inherited: bool, + /// The org has less than 8 weeks of history: external bands stand in. + pub young: bool, +} + +fn stage_durations(spans: &[Span], end: i64) -> BTreeMap> { + let mut out: BTreeMap> = BTreeMap::new(); + for (i, s) in spans.iter().enumerate() { + if s.stage.is_empty() { + continue; + } + let to = spans.get(i + 1).map(|n| n.from).unwrap_or(end); + out.entry(s.stage.clone()) + .or_default() + .push((to - s.from).max(0)); + } + out +} + +fn pct_of(hist: &[&History], now: i64) -> Percentiles { + let cycles: Vec = hist + .iter() + .filter(|h| h.merged_at > now - 90 * DAY) + .filter_map(|h| h.cycle_secs()) + .collect(); + let first: Vec = hist + .iter() + .filter(|h| h.closed_at > now - 56 * DAY) + .filter_map(|h| h.first_review_secs()) + .collect(); + let mut stages: BTreeMap> = BTreeMap::new(); + for h in hist.iter().filter(|h| h.closed_at > now - 90 * DAY) { + for (k, v) in stage_durations(&h.spans, h.closed_at) { + stages.entry(k).or_default().extend(v); + } + } + Percentiles { + cycle: [50, 85, 95] + .iter() + .filter_map(|p| percentile(&cycles, *p)) + .collect(), + first_review: [50, 85] + .iter() + .filter_map(|p| percentile(&first, *p)) + .collect(), + stage_p85: stages + .into_iter() + .filter_map(|(k, v)| percentile(&v, 85).map(|p| (k, p))) + .collect(), + merged: cycles.len(), + } +} + +/// Every scope's snapshot for the day of `now`: the org of each owner and +/// each repository (the first [`MAX_SNAPSHOT_REPOS`]). +pub fn snapshots(open: &[(PrRecord, Stage, String)], hist: &[History], now: i64) -> Vec { + let day = chrono::DateTime::from_timestamp(now, 0) + .map(|d| d.format("%Y-%m-%d").to_string()) + .unwrap_or_default(); + let week = now - 7 * DAY; + let mut scopes: BTreeSet = BTreeSet::new(); + for (r, _, _) in open { + scopes.insert(r.org().to_string()); + scopes.insert(r.repo.clone()); + } + for h in hist { + scopes.insert(h.repo.split('/').next().unwrap_or("").to_string()); + scopes.insert(h.repo.clone()); + } + let first_seen = hist + .iter() + .map(|h| h.created_at) + .chain(open.iter().map(|(r, _, _)| r.created_at)) + .filter(|t| *t > 0) + .min() + .unwrap_or(now); + let young = now - first_seen < MIN_WEEKS_OWN * 7 * DAY; + let in_scope = |scope: &str, repo: &str| { + if scope.contains('/') { + repo.eq_ignore_ascii_case(scope) + } else { + repo.split('/') + .next() + .is_some_and(|o| o.eq_ignore_ascii_case(scope)) + } + }; + let mut orgs: BTreeMap = BTreeMap::new(); + let mut out = Vec::new(); + let mut repos = 0; + // Orgs first, so a repository can inherit its org's percentiles. + let ordered: Vec = scopes + .iter() + .filter(|s| !s.contains('/')) + .chain(scopes.iter().filter(|s| s.contains('/'))) + .cloned() + .collect(); + for scope in ordered { + if scope.is_empty() { + continue; + } + if scope.contains('/') { + repos += 1; + if repos > MAX_SNAPSHOT_REPOS { + break; + } + } + let h: Vec<&History> = hist.iter().filter(|h| in_scope(&scope, &h.repo)).collect(); + let own = pct_of(&h, now); + let org = scope.split('/').next().unwrap_or("").to_string(); + let (pct, inherited) = if scope.contains('/') && own.merged < MIN_MERGED_FOR_OWN { + (orgs.get(&org).cloned().unwrap_or(own), true) + } else { + (own, false) + }; + if !scope.contains('/') { + orgs.insert(scope.clone(), pct.clone()); + } + let mut s = Snapshot { + scope: scope.clone(), + day: day.clone(), + pct: pct.clone(), + inherited, + young, + ..Default::default() + }; + for st in pr_needs::STAGES { + s.stages.insert(st.code().into(), 0); + } + let p85 = pct.cycle.get(1).copied(); + for (r, stage, turn) in open.iter().filter(|(r, _, _)| in_scope(&scope, &r.repo)) { + *s.stages.entry(stage.code().into()).or_default() += 1; + *s.turns.entry(turn.clone()).or_default() += 1; + s.open += 1; + let age = now - r.ready_or_created(); + if *stage != Stage::Draft && p85.is_some_and(|p| age > p) { + s.past_p85 += 1; + } + if r.ready_or_created() > week { + s.arrivals += 1; + } + s.review_requests += r.request_log.iter().filter(|q| q.at > week).count() as u32; + s.reviews_done += r + .review_log + .iter() + .filter(|q| q.human && q.at > week) + .count() as u32; + } + for h in &h { + if h.ready_at > week { + s.arrivals += 1; + } + if h.merged && h.merged_at > week { + s.merges += 1; + *s.merges_by.entry(h.author_type.clone()).or_default() += 1; + } else if !h.merged && h.closed_at > week { + s.closed_unmerged += 1; + } + if h.reverted_by.as_ref().is_some_and(|(_, _, t)| *t > week) { + s.reverts += 1; + } + s.review_requests += h.request_log.iter().filter(|q| q.at > week).count() as u32; + s.reviews_done += h + .review_log + .iter() + .filter(|q| q.human && q.at > week) + .count() as u32; + } + out.push(s); + } + out +} + +// ─── Storage ──────────────────────────────────────────────────────────────── + +type Err = Box; + +/// Write a closed pull request's history (again, when it closes again). +/// A revert or follow-up already recorded on the row is kept. +pub async fn put( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + h: &History, + now: i64, +) -> Result<(), Err> { + let mut h = h.clone(); + if let Some(old) = load(dynamo, table, team_id, &h.repo, h.number).await? { + h.reverted_by = h.reverted_by.or(old.reverted_by); + for f in old.follow_ups { + if !h.follow_ups.contains(&f) { + h.follow_ups.push(f); + } + } + } + dynamo + .put_item() + .table_name(table) + .item("pk", AttributeValue::S(team_id.into())) + .item("sk", AttributeValue::S(hist_sk(&h.repo, h.number))) + .item("doc", AttributeValue::S(serde_json::to_string(&h)?)) + .item("closed_at", AttributeValue::N(h.closed_at.to_string())) + .item( + "ttl", + AttributeValue::N((h.closed_at.max(now) + HISTORY_KEEP_SECS).to_string()), + ) + .send() + .await?; + Ok(()) +} + +pub async fn load( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + repo: &str, + number: u64, +) -> Result, Err> { + let out = dynamo + .get_item() + .table_name(table) + .key("pk", AttributeValue::S(team_id.into())) + .key("sk", AttributeValue::S(hist_sk(repo, number))) + .send() + .await?; + Ok(out + .item() + .and_then(|i| i.get("doc")) + .and_then(|v| v.as_s().ok()) + .and_then(|d| serde_json::from_str(d).ok())) +} + +/// A merged pull request reverting or following up an earlier one. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Rework<'a> { + /// The earlier pull request. + pub target: (&'a str, u64), + /// The later one, and when it merged. + pub by: (&'a str, u64), + pub at: i64, + pub revert: bool, +} + +/// Mark the earlier pull request reverted or followed up: only a merged +/// pull request of the same team, and a follow-up within the rework window. +pub async fn mark( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + w: &Rework<'_>, + now: i64, +) -> Result { + let (target, by, at, revert) = (w.target, w.by, w.at, w.revert); + let Some(mut h) = load(dynamo, table, team_id, target.0, target.1).await? else { + return Ok(false); + }; + if !h.merged || at < h.merged_at || (!revert && at - h.merged_at > REWORK_WINDOW_SECS) { + return Ok(false); + } + let link = (by.0.to_string(), by.1, at); + if revert { + h.reverted_by = Some(link); + } else if !h.follow_ups.contains(&link) { + h.follow_ups.push(link); + } else { + return Ok(false); + } + put(dynamo, table, team_id, &h, now).await?; + Ok(true) +} + +/// Every history row of a team closed after `since` (bounded). +pub async fn all_since( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + since: i64, +) -> Result, Err> { + let mut out = Vec::new(); + let mut start: Option = None; + loop { + let page = dynamo + .query() + .table_name(table) + .key_condition_expression("pk = :pk AND begins_with(sk, :p)") + .filter_expression("closed_at >= :s") + .expression_attribute_values(":pk", AttributeValue::S(team_id.into())) + .expression_attribute_values(":p", AttributeValue::S(HIST_PREFIX.into())) + .expression_attribute_values(":s", AttributeValue::N(since.to_string())) + .set_exclusive_start_key(start) + .send() + .await?; + for item in page.items() { + if let Some(h) = item + .get("doc") + .and_then(|v| v.as_s().ok()) + .and_then(|d| serde_json::from_str::(d).ok()) + { + out.push(h); + } + } + start = page.last_evaluated_key().cloned(); + if start.is_none() || out.len() >= MAX_HISTORY_READ { + return Ok(out); + } + } +} + +/// Write the day's snapshots. +pub async fn put_snapshots( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + snaps: &[Snapshot], + now: i64, +) -> Result { + let mut n = 0; + for s in snaps { + dynamo + .put_item() + .table_name(table) + .item("pk", AttributeValue::S(team_id.into())) + .item("sk", AttributeValue::S(snap_sk(&s.scope, &s.day))) + .item("doc", AttributeValue::S(serde_json::to_string(s)?)) + .item( + "ttl", + AttributeValue::N((now + HISTORY_KEEP_SECS).to_string()), + ) + .send() + .await?; + n += 1; + } + Ok(n) +} + +/// A scope's snapshots from `since_day` (`YYYY-MM-DD`) on, oldest first. +pub async fn snapshots_of( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + scope: &str, + since_day: &str, +) -> Result, Err> { + let out = dynamo + .query() + .table_name(table) + .key_condition_expression("pk = :pk AND sk BETWEEN :a AND :b") + .expression_attribute_values(":pk", AttributeValue::S(team_id.into())) + .expression_attribute_values(":a", AttributeValue::S(snap_sk(scope, since_day))) + .expression_attribute_values(":b", AttributeValue::S(snap_sk(scope, "9999"))) + .send() + .await?; + Ok(out + .items() + .iter() + .filter_map(|i| i.get("doc").and_then(|v| v.as_s().ok())) + .filter_map(|d| serde_json::from_str(d).ok()) + .collect()) +} + +/// The open records of a team with their stage and turn, for a snapshot. +pub fn open_with_stage(recs: Vec) -> Vec<(PrRecord, Stage, String)> { + recs.into_iter() + .filter(PrRecord::is_open) + .filter_map(|r| { + let n = pr_needs::decide(&r.repo, &r.facts()); + let stage = pr_needs::stage_of(n.state, r.first_human_review_at().is_some())?; + Some((r, stage, n.turn.code().to_string())) + }) + .collect() +} + +/// `pr_record` is the source of every history row. +pub fn from_records(recs: &[PrRecord]) -> Vec { + recs.iter() + .filter(|r| !r.is_open()) + .map(History::from_record) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + const NOW: i64 = 1_800_000_000; + + fn merged(repo: &str, n: u64, ready_ago: i64, merged_ago: i64) -> History { + History { + repo: repo.into(), + number: n, + author: "octocat".into(), + author_type: "person".into(), + created_at: NOW - ready_ago, + ready_at: NOW - ready_ago, + merged: true, + merged_at: NOW - merged_ago, + closed_at: NOW - merged_ago, + ..Default::default() + } + } + + #[test] + fn durations_start_at_ready_and_human_review_leaves_out_bots_and_the_author() { + let mut r = PrRecord::new("acme/web", 1); + r.author = "octocat".into(); + r.created_at = NOW - 10 * DAY; + r.ready_at = NOW - 4 * DAY; + r.status = "merged".into(); + r.closed_at = NOW; + for (who, at, human) in [ + ("coderhelm[bot]", NOW - 3 * DAY, false), + ("octocat", NOW - 3 * DAY + 1, false), + ("mara", NOW - 2 * DAY, true), + ] { + r.review_log.push(ReviewEvent { + who: who.into(), + state: "APPROVED".into(), + at, + human, + ..Default::default() + }); + } + let h = History::from_record(&r); + assert_eq!(h.cycle_secs(), Some(4 * DAY)); + assert_eq!(h.first_review_secs(), Some(2 * DAY)); + assert_eq!(h.coderhelm_role, "reviewer"); + assert_eq!(h.first_coderhelm_review_at, NOW - 3 * DAY); + } + + #[test] + fn waiting_on_a_person_sums_the_person_turns_from_ready() { + let spans = vec![ + Span { + who: "nobody".into(), + state: "draft".into(), + from: 0, + turn: "person".into(), + stage: "draft".into(), + }, + Span { + who: "person:mara".into(), + state: "needs_review".into(), + from: 100, + turn: "person".into(), + stage: "first_review".into(), + }, + Span { + who: "ci".into(), + state: "checks_running".into(), + from: 300, + turn: "machines".into(), + stage: "approved".into(), + }, + ]; + assert_eq!(waiting_on_person(&spans, 100, 400), 200); + } + + #[test] + fn percentiles_are_nearest_rank() { + let v: Vec = (1..=100).collect(); + assert_eq!(percentile(&v, 50), Some(50)); + assert_eq!(percentile(&v, 85), Some(85)); + assert_eq!(percentile(&v, 95), Some(95)); + assert_eq!(percentile(&[], 50), None); + } + + #[test] + fn a_small_repository_inherits_its_orgs_percentiles_and_says_so() { + let mut hist: Vec = (0..40) + .map(|i| merged("acme/web", i, (i as i64 + 1) * 3600, 0)) + .collect(); + hist.extend((0..5).map(|i| merged("acme/api", 100 + i, 10 * DAY, 0))); + let snaps = snapshots(&[], &hist, NOW); + let org = snaps.iter().find(|s| s.scope == "acme").unwrap(); + let web = snaps.iter().find(|s| s.scope == "acme/web").unwrap(); + let api = snaps.iter().find(|s| s.scope == "acme/api").unwrap(); + assert!(!web.inherited); + assert!(api.inherited); + assert_eq!(api.pct, org.pct); + assert_eq!(org.merges, 45); + assert!(org.young, "less than 8 weeks of history"); + } + + #[test] + fn rework_counts_only_inside_the_window() { + let mut h = merged("acme/web", 1, DAY, 20 * DAY); + h.follow_ups.push(("acme/web".into(), 2, NOW - 19 * DAY)); + assert!(h.reworked()); + h.follow_ups = vec![("acme/web".into(), 2, NOW)]; + assert!(!h.reworked()); + } + + #[test] + fn a_revert_names_what_it_reverts() { + assert_eq!( + crate::pr_record::reverted( + "Revert \"Round cart totals\"", + "Reverts acme/web#318", + "acme/web" + ), + Some(("acme/web".to_string(), 318)) + ); + assert_eq!( + crate::pr_record::reverted("Round cart totals", "Reverts acme/web#318", "acme/web"), + None + ); + assert_eq!( + crate::pr_record::references("Follow-up to #318 and acme/api#12.", "acme/web"), + vec![("acme/web".to_string(), 318), ("acme/api".to_string(), 12)] + ); + } +} diff --git a/services/common/src/pr_needs.rs b/services/common/src/pr_needs.rs index 4823cd85f..573b37499 100644 --- a/services/common/src/pr_needs.rs +++ b/services/common/src/pr_needs.rs @@ -162,6 +162,91 @@ impl State { } } +/// The six stages of the overview's strip, mutually exclusive, mapped from +/// the state ([`stage_of`]). +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +pub enum Stage { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "first_review")] + FirstReview, + #[serde(rename = "in_review")] + InReview, + #[serde(rename = "blocked")] + Blocked, + #[serde(rename = "coderhelm_working")] + CoderHelmWorking, + #[serde(rename = "approved")] + Approved, +} + +/// Every stage, in the strip's order. +pub const STAGES: &[Stage] = &[ + Stage::Draft, + Stage::FirstReview, + Stage::InReview, + Stage::Blocked, + Stage::CoderHelmWorking, + Stage::Approved, +]; + +impl Stage { + pub fn code(self) -> &'static str { + match self { + Stage::Draft => "draft", + Stage::FirstReview => "first_review", + Stage::InReview => "in_review", + Stage::Blocked => "blocked", + Stage::CoderHelmWorking => "coderhelm_working", + Stage::Approved => "approved", + } + } + + pub fn label(self) -> &'static str { + match self { + Stage::Draft => "Draft", + Stage::FirstReview => "Waiting for first review", + Stage::InReview => "In review", + Stage::Blocked => "Blocked", + Stage::CoderHelmWorking => "CoderHelm working", + Stage::Approved => "Approved, not merged", + } + } + + pub fn from_code(code: &str) -> Option { + STAGES.iter().copied().find(|s| s.code() == code) + } +} + +/// The stage of an open pull request in `state`; `None` once it is merged +/// or closed. `reviewed`: a person other than the author has reviewed it, +/// which tells a first review from a later one. A pull request whose facts +/// aren't known yet, and one that waits on a person's decision, are +/// blocked. +pub fn stage_of(state: State, reviewed: bool) -> Option { + Some(match state { + State::Merged | State::Closed => return None, + State::Draft => Stage::Draft, + State::NeedsReviewer | State::NeedsReview if !reviewed => Stage::FirstReview, + State::NeedsReviewer + | State::NeedsReview + | State::ChangesRequested + | State::ReReview + | State::NeedsCodeOwner + | State::OpenThreads => Stage::InReview, + State::Conflicts + | State::ChecksFailing + | State::WaitingOnPr + | State::LeftQueue + | State::NeedsDecision + | State::Unknown => Stage::Blocked, + State::CoderHelmWorking => Stage::CoderHelmWorking, + State::InQueue | State::ChecksRunning | State::ReadyAutoMerge | State::ReadyToMerge => { + Stage::Approved + } + }) +} + /// Who holds the next move. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] pub enum Turn { diff --git a/services/common/src/pr_record.rs b/services/common/src/pr_record.rs index aa1e85f4d..f3bf7d548 100644 --- a/services/common/src/pr_record.rs +++ b/services/common/src/pr_record.rs @@ -130,6 +130,62 @@ pub struct CoderHelmLink { /// The reviewer's latest session on it. #[serde(default)] pub session_id: String, + /// Every run on it, oldest first (its findings and cost are the runs' + /// and the review sessions'). + #[serde(default)] + pub run_ids: Vec, + /// Every review session on it, oldest first. + #[serde(default)] + pub session_ids: Vec, +} + +/// One review submitted, as it happened (people's and CoderHelm's). +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct ReviewEvent { + pub who: String, + /// `APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`, `DISMISSED`. + pub state: String, + pub sha: String, + pub at: i64, + /// A person who isn't the author: CoderHelm, other bots and the author + /// never count as human review. + pub human: bool, + /// The review carried words of its own. + pub has_body: bool, +} + +/// One review request: who, when asked, when taken back (0 never). +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct RequestEvent { + /// A login, or `org/slug` for a team. + pub who: String, + pub at: i64, + pub removed_at: i64, +} + +/// The head's checks turning `red`, `pending` or `green`. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct CheckTransition { + pub rollup: String, + pub at: i64, +} + +/// Most review, request and check transitions kept on a record. +pub const MAX_LOG: usize = 150; + +/// A login is a bot's (GitHub apps end in `[bot]`). +pub fn is_bot(login: &str) -> bool { + login.ends_with("[bot]") || is_coderhelm(login) +} + +fn bounded(v: &mut Vec) { + if v.len() > MAX_LOG { + let cut = v.len() - MAX_LOG; + v.drain(..cut); + } } /// One timeline event. @@ -155,6 +211,12 @@ pub struct Span { pub who: String, pub state: String, pub from: i64, + /// The turn and the stage of the overview strip, for time in stage and + /// time waiting on a person. + #[serde(default)] + pub turn: String, + #[serde(default)] + pub stage: String, } /// The record's body. @@ -176,6 +238,9 @@ pub struct PrRecord { pub head_ref: String, pub base_ref: String, pub created_at: i64, + /// When it was first ready for review: its creation when it never was + /// a draft, else when it left draft. Every duration starts here. + pub ready_at: i64, pub updated_at: i64, pub closed_at: i64, pub merged_by: String, @@ -215,6 +280,11 @@ pub struct PrRecord { pub coderhelm: CoderHelmLink, pub events: Vec, pub spans: Vec, + /// Every review, request and check transition (the newest + /// [`MAX_LOG`]): what the history and the overview's durations read. + pub review_log: Vec, + pub request_log: Vec, + pub check_log: Vec, /// When the sync last read it (epoch seconds; 0 never). pub synced_at: i64, /// When an event last changed it. @@ -281,6 +351,49 @@ pub fn compatibility_links(body: &str) -> Vec<(String, u64)> { out } +/// The pull request a revert reverts: GitHub's own revert writes "Reverts +/// owner/repo#n" in the description. +pub fn reverted(title: &str, body: &str, repo: &str) -> Option<(String, u64)> { + if !title.trim_start().starts_with("Revert") { + return None; + } + references(body, repo) + .into_iter() + .find(|_| body.contains("Reverts ")) +} + +/// Pull requests a description names (`owner/repo#n`, or `#n` in the same +/// repository), the first few. +pub fn references(body: &str, repo: &str) -> Vec<(String, u64)> { + let mut out: Vec<(String, u64)> = Vec::new(); + for word in body.split(|c: char| c.is_whitespace() || "()[],;`:".contains(c)) { + let word = word + .trim_start_matches("https://github.com/") + .replace("/pull/", "#") + .trim_end_matches('.') + .to_string(); + let Some((r, n)) = word.rsplit_once('#') else { + continue; + }; + let Ok(n) = n.parse::() else { continue }; + let r = if r.is_empty() { + repo.to_string() + } else { + r.to_string() + }; + let ok = r.split('/').count() == 2 + && r.chars() + .all(|c| c.is_ascii_alphanumeric() || "-_./".contains(c)); + if ok && !out.contains(&(r.clone(), n)) { + out.push((r, n)); + } + if out.len() >= 5 { + break; + } + } + out +} + impl PrRecord { pub fn new(repo: &str, number: u64) -> PrRecord { PrRecord { @@ -424,6 +537,24 @@ impl PrRecord { self.auto_merge = !pr["auto_merge"].is_null(); } if let Some(body) = pr["body"].as_str() { + self.links.retain(|l| l.kind != "reverts"); + if let Some((repo, n)) = reverted(&self.title, body, &self.repo) { + self.links.push(Link { + kind: "reverts".into(), + repo, + number: n, + }); + } + self.links.retain(|l| l.kind != "references"); + for (repo, n) in references(body, &self.repo) { + if repo != self.repo || n != self.number { + self.links.push(Link { + kind: "references".into(), + repo, + number: n, + }); + } + } self.links.retain(|l| l.kind != "contract"); for (repo, n) in compatibility_links(body) { self.links.push(Link { @@ -454,6 +585,13 @@ impl PrRecord { let before = self.head_sha.clone(); self.take_pr(pr); let when = at(&pr["updated_at"]); + if self.ready_at == 0 { + if action == "ready_for_review" { + self.ready_at = when; + } else if !self.draft && self.created_at > 0 { + self.ready_at = self.created_at; + } + } match action { "opened" => self.event( at(&pr["created_at"]), @@ -503,14 +641,42 @@ impl PrRecord { .map(|t| format!("@{}/{t}", self.org())) }) .unwrap_or_default(); + let key = who.trim_start_matches('@').to_string(); + if !key.is_empty() { + self.request_log.push(RequestEvent { + who: key, + at: when, + removed_at: 0, + }); + bounded(&mut self.request_log); + } self.event(when, &sender, "reviewers", format!("asked {who} to review")) } - "review_request_removed" => self.event( - when, - &sender, - "reviewers", - "removed a review request".into(), - ), + "review_request_removed" => { + let who = payload["requested_reviewer"]["login"] + .as_str() + .map(str::to_string) + .or_else(|| { + payload["requested_team"]["slug"] + .as_str() + .map(|t| format!("{}/{t}", self.org())) + }) + .unwrap_or_default(); + if let Some(r) = self + .request_log + .iter_mut() + .rev() + .find(|r| r.who.eq_ignore_ascii_case(&who) && r.removed_at == 0) + { + r.removed_at = when; + } + self.event( + when, + &sender, + "reviewers", + "removed a review request".into(), + ) + } "labeled" => self.event( when, &sender, @@ -627,6 +793,19 @@ impl PrRecord { } self.requested.retain(|p| !p.eq_ignore_ascii_case(&who)); } + self.review_log.push(ReviewEvent { + who: who.clone(), + state: if action == "dismissed" { + "DISMISSED".into() + } else { + state.clone() + }, + sha: s(&r["commit_id"]), + at: when, + human: !is_bot(&who) && !who.eq_ignore_ascii_case(&self.author), + has_body: r["body"].as_str().is_some_and(|b| !b.trim().is_empty()), + }); + bounded(&mut self.review_log); self.role(&who, "reviewer"); let words = match (action, state.as_str()) { ("dismissed", _) => "had a review dismissed".to_string(), @@ -686,6 +865,7 @@ impl PrRecord { self.event(c.at, "ci", "check", format!("`{name}` failed")); } self.put_check(name, c); + self.note_checks(now); self.event_at = now; true } @@ -717,6 +897,7 @@ impl PrRecord { format!("a check suite finished: {concl}"), ); } + self.note_checks(now); self.event_at = now; true } @@ -740,6 +921,7 @@ impl PrRecord { at: at(&payload["updated_at"]), }, ); + self.note_checks(now); self.event_at = now; true } @@ -771,6 +953,75 @@ impl PrRecord { } } + /// The head's checks as one word: `red`, `pending` or `green`. + pub fn check_rollup(&self) -> &'static str { + if self.checks.is_empty() { + return "pending"; + } + if self.checks.values().any(Check::failed) { + "red" + } else if self.checks.values().any(Check::running) { + "pending" + } else { + "green" + } + } + + fn note_checks(&mut self, at: i64) { + let rollup = self.check_rollup(); + if self.check_log.last().is_none_or(|c| c.rollup != rollup) { + self.check_log.push(CheckTransition { + rollup: rollup.into(), + at, + }); + bounded(&mut self.check_log); + } + } + + /// The first review by a person who isn't the author (bots never count). + pub fn first_human_review_at(&self) -> Option { + self.review_log + .iter() + .filter(|r| r.human && r.state != "DISMISSED") + .map(|r| r.at) + .min() + } + + /// CoderHelm's first review. + pub fn first_coderhelm_review_at(&self) -> Option { + self.review_log + .iter() + .filter(|r| is_coderhelm(&r.who)) + .map(|r| r.at) + .min() + } + + /// The last approval by a person who isn't the author. + pub fn final_approval_at(&self) -> Option { + self.review_log + .iter() + .filter(|r| r.human && r.state == "APPROVED") + .map(|r| r.at) + .max() + } + + /// Rounds of changes requested by people. + pub fn changes_rounds(&self) -> u32 { + self.review_log + .iter() + .filter(|r| r.human && r.state == "CHANGES_REQUESTED") + .count() as u32 + } + + /// When every duration starts: ready for review, else its creation. + pub fn ready_or_created(&self) -> i64 { + if self.ready_at > 0 { + self.ready_at + } else { + self.created_at + } + } + fn take_check_sha(&mut self, sha: &str) -> bool { if sha.is_empty() { return false; @@ -834,6 +1085,11 @@ impl PrRecord { self.base_ref = s(&n["baseRefName"]); self.created_at = ts(&n["createdAt"]); self.updated_at = ts(&n["updatedAt"]); + if self.ready_at == 0 && !self.draft { + // The search carries no ready time: the creation stands in + // until an event says better. + self.ready_at = self.created_at; + } self.additions = n["additions"].as_u64().unwrap_or(0) as u32; self.deletions = n["deletions"].as_u64().unwrap_or(0) as u32; self.labels = n["labels"]["nodes"] @@ -1083,7 +1339,16 @@ impl PrRecord { } else { now }; - self.spans.push(Span { who, state, from }); + let stage = pr_needs::stage_of(n.state, self.first_human_review_at().is_some()) + .map(|s| s.code().to_string()) + .unwrap_or_default(); + self.spans.push(Span { + who, + state, + from, + turn: n.turn.code().to_string(), + stage, + }); if self.spans.len() > MAX_SPANS { let cut = self.spans.len() - MAX_SPANS; self.spans.drain(..cut); @@ -1432,7 +1697,11 @@ mod tests { assert_eq!(r.author, "octocat"); assert_eq!(r.requested, vec!["mara"]); assert_eq!( - r.links, + r.links + .iter() + .filter(|l| l.kind == "contract") + .cloned() + .collect::>(), vec![Link { kind: "contract".into(), repo: "acme/api".into(), diff --git a/services/common/src/pr_view.rs b/services/common/src/pr_view.rs index d055b96e4..c969dd63a 100644 --- a/services/common/src/pr_view.rs +++ b/services/common/src/pr_view.rs @@ -150,6 +150,10 @@ pub struct Row { pub updated_at: Option, pub state: String, pub state_label: String, + /// The overview's stage (`common::pr_needs::Stage`), null once closed. + pub stage: Option, + /// Ready for review (every age is measured from here). + pub ready_at: Option, pub turn: String, pub next: NextOut, pub modifiers: Vec, @@ -570,6 +574,9 @@ fn row( updated_at: rfc3339(r.updated_at.max(r.event_at)), state: n.state.code().into(), state_label: n.state.label().into(), + stage: pr_needs::stage_of(n.state, r.first_human_review_at().is_some()) + .map(|s| s.code().to_string()), + ready_at: rfc3339(r.ready_or_created()), turn: turn.clone(), next: NextOut { code: n.next.code.clone(), diff --git a/services/gateway/src/routes/prs.rs b/services/gateway/src/routes/prs.rs index 238b9db29..1e6734c67 100644 --- a/services/gateway/src/routes/prs.rs +++ b/services/gateway/src/routes/prs.rs @@ -102,6 +102,9 @@ pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, paylo if let Err(e) = pr_record::point(&state.dynamo, table, team_id, &rec, t).await { warn!(repo, number, error = %e, "Pull request record: pointer not written"); } + if !rec.is_open() { + record_history(state, team_id, &rec, t).await; + } } // CoderHelm's run on it, found once. let asks = rec.author_is_coderhelm() || !rec.requester.is_empty(); @@ -115,6 +118,9 @@ pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, paylo return false; } r.coderhelm.run_id = run_id.clone(); + if !r.coderhelm.run_ids.contains(&run_id) { + r.coderhelm.run_ids.push(run_id.clone()); + } true }) .await; @@ -123,6 +129,52 @@ pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, paylo } } +/// A pull request closed: its history row (kept over a year), and on a +/// merge the revert or follow-up links to the merged pull requests it +/// names. +async fn record_history(state: &AppState, team_id: &str, rec: &PrRecord, now: i64) { + let table = &state.config.settings_table_name; + let h = common::pr_history::History::from_record(rec); + if let Err(e) = common::pr_history::put(&state.dynamo, table, team_id, &h, now).await { + warn!(repo = %rec.repo, number = rec.number, error = %e, "Pull request history not written"); + return; + } + if rec.status != "merged" { + return; + } + let reverts = rec + .links + .iter() + .find(|l| l.kind == "reverts") + .map(|l| (l.repo.clone(), l.number)); + let mut targets: Vec<((String, u64), bool)> = + reverts.clone().map(|t| (t, true)).into_iter().collect(); + for l in rec.links.iter().filter(|l| l.kind == "references") { + let t = (l.repo.clone(), l.number); + if Some(&t) != reverts.as_ref() && (t.0 != rec.repo || t.1 != rec.number) { + targets.push((t, false)); + } + } + for ((repo, n), revert) in targets.into_iter().take(5) { + let marked = common::pr_history::mark( + &state.dynamo, + table, + team_id, + &common::pr_history::Rework { + target: (&repo, n), + by: (&rec.repo, rec.number), + at: rec.closed_at.max(1), + revert, + }, + now, + ) + .await; + if let Err(e) = marked { + warn!(repo, n, error = %e, "Revert or follow-up link not written"); + } + } +} + // ─── The reads ────────────────────────────────────────────────────────────── fn s(item: &Item, k: &str) -> String { diff --git a/services/worker/src/main.rs b/services/worker/src/main.rs index 53056b38e..080a944fc 100644 --- a/services/worker/src/main.rs +++ b/services/worker/src/main.rs @@ -818,6 +818,10 @@ async fn handle_message_inner(state: Arc, message: models::WorkerMe pages = prs.pages, "Pull request records sync done" ); + // The overview's nightly snapshot and percentiles, per org and + // repository: once a day per team, no GitHub requests. + let snaps = passes::pr_records::nightly(&state).await; + info!(snapshots = snaps, "Pull request snapshots done"); // Stale pull requests: each repository at most once an hour. let stale = as_sweep(who::SWEEP_STALE_PRS, passes::stale_prs::sweep(&state)).await; info!( diff --git a/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs index 348e869bd..3e9bf79a5 100644 --- a/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs +++ b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs @@ -122,6 +122,11 @@ fn every_open_pull_request_appears_whoever_opened_it() { assert_eq!(r.ttl(), None); r.status = "closed".into(); assert!(r.ttl().is_some()); + // A closed pull request's history outlives a year, and the gateway + // writes it when the pull request closes. + const _: () = assert!(common::pr_history::HISTORY_KEEP_SECS >= 400 * 86_400); + let prs = src("gateway/src/routes/prs.rs"); + assert!(prs.contains("record_history(state, team_id, &rec, t).await;")); } #[test] diff --git a/services/worker/src/passes/pr_records.rs b/services/worker/src/passes/pr_records.rs index bda8dce40..ad5ca8e20 100644 --- a/services/worker/src/passes/pr_records.rs +++ b/services/worker/src/passes/pr_records.rs @@ -52,6 +52,49 @@ pub async fn sweep(state: &WorkerState) -> SweepReport { report } +/// The nightly snapshot of every org and repository of each team: counts +/// by stage and turn, arrivals, merges, reviews, and the percentiles the +/// thresholds come from (`common::pr_history::snapshots`). Once a day per +/// team, reading only the team's own records and history (bounded), and no +/// GitHub requests. +pub async fn nightly(state: &WorkerState) -> usize { + use common::pr_history; + let day = chrono::Utc::now().format("%Y%m%d").to_string(); + let table = &state.config.settings_table_name; + let mut written = 0; + for team in super::learning_wait::teams(state).await { + let claim = format!("PRSNAP_JOB#{day}"); + if !super::review_pr::claim_once_ttl(state, &team, &claim, 2 * 86_400).await { + continue; + } + let now = chrono::Utc::now().timestamp(); + let recs = match pr_record::all(&state.dynamo, table, &team).await { + Ok(r) => r, + Err(e) => { + warn!(team_id = %team, error = %e, "Pull request snapshot: records not read"); + continue; + } + }; + let hist = + match pr_history::all_since(&state.dynamo, table, &team, now - 120 * 86_400).await { + Ok(h) => h, + Err(e) => { + warn!(team_id = %team, error = %e, "Pull request snapshot: history not read"); + continue; + } + }; + if recs.is_empty() && hist.is_empty() { + continue; + } + let snaps = pr_history::snapshots(&pr_history::open_with_stage(recs), &hist, now); + match pr_history::put_snapshots(&state.dynamo, table, &team, &snaps, now).await { + Ok(n) => written += n, + Err(e) => warn!(team_id = %team, error = %e, "Pull request snapshot not written"), + } + } + written +} + /// One team, now (the install's first read). pub async fn sync_message(state: &WorkerState, msg: &common::messages::PrRecordsSyncMessage) { let mut gate = SweepGate::new(who::SWEEP_DASHBOARD_PRS); From afe30c70770403c4ee616efd45336dcc189554a0 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 14:51:40 -0500 Subject: [PATCH 04/19] Every pull request, whoever wrote it: history backfill and health signals A resumable 14-month backfill reads each organization's closed and merged pull requests into history under the shared budget, pausing on a held budget or rate limit and showing its progress per repository. Records keep separate author, reviewer and bot clocks, drift against the base, every check attempt (flaky reads as flaky), category and severity; history adds review coverage, bypass merges, suspect follow-ups with their reason, and CoderHelm's last run outcome and stop reason. --- docs/pull-requests.md | 4 +- docs/pull-requests/api_contract.md | 20 ++ services/common/src/github_budget.rs | 4 +- services/common/src/pr_history.rs | 279 +++++++++++++++++- services/common/src/pr_record.rs | 262 +++++++++++++++- services/gateway/src/routes/prs.rs | 97 +++++- .../xw_every_open_pr_has_one_state.rs | 74 +++++ services/worker/src/passes/pr_records.rs | 142 ++++++++- 8 files changed, 864 insertions(+), 18 deletions(-) diff --git a/docs/pull-requests.md b/docs/pull-requests.md index a79896e45..ea343c375 100644 --- a/docs/pull-requests.md +++ b/docs/pull-requests.md @@ -19,6 +19,8 @@ What the org overview reads, kept so the page never has to be migrated (`service - **The change log.** Each record keeps its turn changes (who held the turn, the state, the turn and the stage, and since when), every review submitted (people's and CoderHelm's, marked human or not), every review request with when it was taken back, and the head's checks turning red, pending or green. Time in a stage and time waiting on a person are read from it. - **History.** When a pull request merges or closes, its history row (`sk = PRHIST##`) is written and kept 400 days: ready, first human review, CoderHelm's first review, final approval, merge or close and who merged, rounds of changes requested, size, author type, CoderHelm's part (author, fixer, reviewer or none) with its runs and review sessions, the change log, and links. - **Reverts and follow-ups.** A merged revert ("Reverts owner/repo#n") marks the pull request it reverts; a merged pull request that names an earlier merged one within 14 days of its merge marks it as followed up. Both are labeled a proxy for a failed change. +- **Every pull request, whoever wrote it.** Nothing filters to CoderHelm's pull requests: the webhooks write people's, bots' and CoderHelm's alike, and the sync keeps every author in the team's connected repositories. +- **The history backfill.** At install and on every hourly reconcile, each organization's closed and merged pull requests of the last 14 months are read into history, a month at a time from the newest, at most 5 search pages per organization per sweep. A held budget or GitHub's rate limit pauses it with the reason and the time; the next sweep resumes from the stored page cursor. Once all 14 months are read, each sweep reads the pull requests closed since its last day. The list shows the progress per organization, with the history rows read per repository. - **The nightly snapshot** (`sk = PRSNAP##`, kept 400 days), once a day per team and per org and repository (the first 300): open pull requests by stage and turn, how many are past the scope's p85, arrivals, merges (by author type), closed without merging, reviews asked and done, reverts, and the percentiles: cycle time p50, p85 and p95 over 90 days, first human review p50 and p85 over 8 weeks, and each stage's p85. A repository with fewer than 30 merges in 90 days uses its org's percentiles and says so; an org with less than 8 weeks of history is marked young, so the page shows external bands instead. The job reads only the team's own records and history (at most 25,000 history rows) and makes no GitHub requests. ## One state per pull request @@ -39,5 +41,5 @@ Both need the "view" capability. The team is always the session's; a record of a ## Cost - Reading the list costs no GitHub requests: it reads the team's records, its runs on them (one batched read) and the reviewer's records, and reuses them for 10 seconds per installation and team. -- The sync spends from the installation's shared GitHub budget as `sweep:dashboard_prs`: at most 30 requests an hour, at most 10 pages of 30 pull requests per organization each time, once an hour per team and once at install. It runs only while the budget leaves the runs their share. +- The sync spends from the installation's shared GitHub budget as `sweep:dashboard_prs`: at most 60 requests an hour: at most 10 pages of 30 open pull requests and 5 pages of closed ones per organization each time, once an hour per team and once at install. It runs only while the budget leaves the runs their share. - Each webhook costs one read and one write of its record. diff --git a/docs/pull-requests/api_contract.md b/docs/pull-requests/api_contract.md index bfa99cc47..51fc77496 100644 --- a/docs/pull-requests/api_contract.md +++ b/docs/pull-requests/api_contract.md @@ -24,6 +24,7 @@ Team comes from the session only. 404 from an older backend means "not served ye "views": {"my_turn": 2, "coderhelm_working": 4, "needs_decision": 1, "ready": 3, "stale": 2} }, "viewer": "octocat", + "backfill": [{"owner": "acme", "months_read": 9, "months_total": 14, "done": false, "paused_until": null, "paused_why": null, "repos": {"acme/web": 212, "acme/api": 97}, "updated_at": "..."}], "synced_at": "2026-01-10T12:00:00Z", "sources": [{"name": "webhooks", "read": "ok", "detail": ""}, {"name": "reconcile", "read": "ok", "detail": "acme: 37 open pull requests read"}] } @@ -112,3 +113,22 @@ All settings-table rows, `pk` = team id, body JSON in `doc`. Types live in `serv `scope, day, stages {stage: n}, turns {turn: n}, open, past_p85, arrivals, merges, closed_unmerged, review_requests, reviews_done, reverts, merges_by {author_type: n}, pct {cycle: [p50,p85,p95] secs over 90 days, first_review: [p50,p85] over 8 weeks, stage_p85 {stage: secs}, merged}, inherited (repo under 30 merges uses the org's), young (org under 8 weeks: show external bands)`. Weekly counts are the 7 days to the snapshot. `pr_history::snapshots_of(team, scope, since_day)` reads them oldest first. + +## History backfill (every pull request, whoever wrote it) +At install and on every hourly reconcile, the worker reads each organization's closed and merged pull requests, a month at a time from the newest, 14 months back (`PRBACKFILL#` holds the progress, `pr_history::Backfill`), into history rows. People's, bots' and CoderHelm's pull requests alike: the only filter is the team's connected repositories. At most 5 search pages per organization per sweep under `sweep:dashboard_prs` (60 requests an hour); a held budget or GitHub's rate limit pauses it (`paused_until`, `paused_why`) and the next sweep resumes from the stored page cursor. `GET /api/prs` returns the progress as `backfill`, with history rows written per repository. + +## Health signals (from "Org pull request health signals") +On the current row (`PrRecord`): +- `last_author_action_at`, `last_reviewer_action_at`, `last_bot_event_at`: separate clocks. Bots, CI and CoderHelm move only the third, so a pull request only bots touch still reads idle. +- `files[]` (the sync reads up to 100 paths), `drift_behind`, `drift_overlap`: commits pushed to its base since its last push, and those touching its files (from the push's own file lists; reset by a push to the pull request). +- `check_attempts[] {name, sha, conclusion, at}`: every completed attempt; `pr_record::flaky_checks()` = failed then passed on the same commit. +- `category` (`feature` | `dependency` | `security`) and `severity` (`critical` | `high` | `moderate` | `low` | ""), from the author, labels and title. The SLA clock starts at `ready_at`. + +On the history row (`History`): +- `coverage`: `human_approved` | `ai_only` | `non_owner_on_owned` | `bypass_or_exempt` | `no_review` (`pr_history::coverage_of`). +- `bypass`: the rule a merge went past ("merged before the required review", "merged with changes requested", "merged with required checks failing: ...", "merged while the branch's rules blocked it") or null; `merged_by_type` (`person` | `coderhelm` | `bot`), so CoderHelm's own bypasses show. +- `follow_ups[] {repo, number, at, reason}`: suspects, never cause, each with its reason; `reverted_by` is the certain link. +- `category`, `severity`, `flaky_checks[]`, `drift_behind`, `drift_overlap`. +- `run_outcome` (the last run's status) and `stop_reason` (its hand-off code when a person had to act). + +Not stored yet (follow-ups): CODEOWNERS file versions and sensitive-path lists (so `non_owner_on_owned` reads only GitHub's review decision today), policy events from the rule-suites API and audit log, Dependabot and code-scanning alerts with KEV and EPSS, default-branch CI episodes, a nightly flaky-check index, review comment counts and comments followed by a change, run cost and findings per pull request, the event feed, and the SLA and working-agreement settings. diff --git a/services/common/src/github_budget.rs b/services/common/src/github_budget.rs index 526c44312..5438e146b 100644 --- a/services/common/src/github_budget.rs +++ b/services/common/src/github_budget.rs @@ -155,7 +155,7 @@ pub mod caller { (SWEEP_REVIEW, 120), (SWEEP_DRAFTS, 120), (SWEEP_PR_WATCH, 240), - (SWEEP_DEPLOYS, 240), + (SWEEP_DEPLOYS, 210), (SWEEP_REVIEW_REMINDER, 120), (SWEEP_PR_OUTCOMES, 120), (SWEEP_SKILLS, 60), @@ -170,7 +170,7 @@ pub mod caller { (SWEEP_WEEKLY, 100), (SWEEP_QUARANTINE, 90), (SWEEP_FOLLOWUP_DEDUPE, 30), - (SWEEP_DASHBOARD_PRS, 30), + (SWEEP_DASHBOARD_PRS, 60), ]; } diff --git a/services/common/src/pr_history.rs b/services/common/src/pr_history.rs index ba1069462..3e5d6301d 100644 --- a/services/common/src/pr_history.rs +++ b/services/common/src/pr_history.rs @@ -27,7 +27,8 @@ use serde::{Deserialize, Serialize}; use crate::pr_needs::{self, Stage}; use crate::pr_record::{ - is_bot, is_coderhelm, CheckTransition, Item, Link, PrRecord, RequestEvent, ReviewEvent, Span, + self, is_bot, is_coderhelm, CheckTransition, Item, Link, PrRecord, RequestEvent, ReviewEvent, + Span, }; /// Sort-key prefix of the history rows. @@ -103,10 +104,94 @@ pub struct History { pub request_log: Vec, pub check_log: Vec, pub links: Vec, - /// The pull request that reverted it, and when. + /// The pull request that reverted it, and when (certain). pub reverted_by: Option<(String, u64, i64)>, - /// Pull requests that named it after it merged (fix-ups), and when. - pub follow_ups: Vec<(String, u64, i64)>, + /// Later pull requests suspected of fixing it, each with its reason + /// (suspect, never cause). + pub follow_ups: Vec, + /// How it was reviewed: `human_approved`, `ai_only`, + /// `non_owner_on_owned`, `bypass_or_exempt` or `no_review` + /// ([`coverage_of`]). + pub coverage: String, + /// Merged past a rule that still held it, and which: CoderHelm's own + /// merges included (`merged_by_type`). + pub bypass: Option, + pub merged_by_type: String, + /// `feature`, `dependency` or `security`, its severity, and when its + /// clock started (ready for review). + pub category: String, + pub severity: String, + /// Checks that failed and then passed on the same commit. + pub flaky_checks: Vec, + /// How far the base had moved under it at the end. + pub drift_behind: u32, + pub drift_overlap: u32, + /// CoderHelm's last run on it: how it ended, and why it stopped when a + /// person had to act (`handback` code). + pub run_outcome: String, + pub stop_reason: String, +} + +/// A later pull request suspected of fixing an earlier one. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Suspect { + pub repo: String, + pub number: u64, + pub at: i64, + /// Why it is suspected, in words ("names it in its description", + /// "labeled hotfix and names it"). + pub reason: String, +} + +/// How a closed pull request was reviewed, one of five. +pub fn coverage_of(r: &PrRecord) -> &'static str { + let human = r + .review_log + .iter() + .any(|v| v.human && v.state == "APPROVED"); + let bot = r + .review_log + .iter() + .any(|v| !v.human && v.state == "APPROVED" && is_bot(&v.who)); + let held = matches!( + r.review_decision.as_deref(), + Some("REVIEW_REQUIRED") | Some("CHANGES_REQUESTED") + ); + if human && held && r.codeowners_required { + "non_owner_on_owned" + } else if human { + "human_approved" + } else if r.status == "merged" && (held || r.approvals_required > 0) { + "bypass_or_exempt" + } else if bot { + "ai_only" + } else { + "no_review" + } +} + +/// The rule a merge went past, when GitHub still held it at the merge. +pub fn bypass_of(r: &PrRecord) -> Option { + if r.status != "merged" { + return None; + } + let f = r.facts(); + let (failing, _) = f.checks.blocking(); + if matches!(r.review_decision.as_deref(), Some("CHANGES_REQUESTED")) { + Some("merged with changes requested".into()) + } else if matches!(r.review_decision.as_deref(), Some("REVIEW_REQUIRED")) { + Some("merged before the required review".into()) + } else if !failing.is_empty() && !f.checks.required.is_empty() { + Some(format!( + "merged with required checks failing: {}", + failing.join(", ") + )) + } else if r.merge_state == "blocked" { + Some("merged while the branch's rules blocked it".into()) + } else { + None + } } impl History { @@ -158,6 +243,20 @@ impl History { links: r.links.clone(), reverted_by: None, follow_ups: Vec::new(), + coverage: coverage_of(r).into(), + bypass: bypass_of(r), + merged_by_type: if r.merged_by.is_empty() { + String::new() + } else { + author_type(&r.merged_by).into() + }, + category: r.category.clone(), + severity: r.severity.clone(), + flaky_checks: pr_record::flaky_checks(&r.check_attempts), + drift_behind: r.drift_behind, + drift_overlap: r.drift_overlap, + run_outcome: String::new(), + stop_reason: String::new(), } } @@ -191,7 +290,7 @@ impl History { self.reverted_by .as_ref() .is_some_and(|(_, _, t)| within(*t)) - || self.follow_ups.iter().any(|(_, _, t)| within(*t)) + || self.follow_ups.iter().any(|f| within(f.at)) } } @@ -430,6 +529,114 @@ pub fn snapshots(open: &[(PrRecord, Stage, String)], hist: &[History], now: i64) out } +// ─── The history backfill ─────────────────────────────────────────────────── + +/// Sort-key prefix of each organization's backfill progress. +pub const BACKFILL_PREFIX: &str = "PRBACKFILL#"; +/// Months of closed pull requests the backfill reads (over 400 days). +pub const BACKFILL_MONTHS: u32 = 14; + +pub fn backfill_sk(owner: &str) -> String { + format!("{BACKFILL_PREFIX}{owner}") +} + +/// How far one organization's history backfill has read: a month at a time, +/// newest first, resumed from its page cursor after a pause. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Backfill { + pub owner: String, + /// Months fully read (0 is the current month). + pub months_read: u32, + /// The page cursor inside the month being read. + pub cursor: Option, + pub done: bool, + /// The budget held it until then (epoch seconds; 0 not held). + pub paused_until: i64, + /// Why it is held, in words. + pub paused_why: String, + /// History rows written, by repository. + pub repos: BTreeMap, + pub pages: u32, + pub started_at: i64, + pub updated_at: i64, + /// The last day the reconcile read after the backfill was done. + pub reconciled_to: String, +} + +impl Backfill { + /// The window of month `i` back from `now` (`YYYY-MM-DD` inclusive). + pub fn window(now: i64, i: u32) -> (String, String) { + use chrono::{Datelike, Duration, NaiveDate}; + let today = chrono::DateTime::from_timestamp(now, 0) + .map(|d| d.date_naive()) + .unwrap_or_default(); + let mut y = today.year(); + let mut m = today.month() as i32 - i as i32; + while m <= 0 { + m += 12; + y -= 1; + } + let first = NaiveDate::from_ymd_opt(y, m as u32, 1).unwrap_or(today); + let next = if m == 12 { + NaiveDate::from_ymd_opt(y + 1, 1, 1) + } else { + NaiveDate::from_ymd_opt(y, m as u32 + 1, 1) + } + .unwrap_or(today); + let last = (next - Duration::days(1)).min(today); + ( + first.format("%Y-%m-%d").to_string(), + last.format("%Y-%m-%d").to_string(), + ) + } +} + +pub async fn load_backfill( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + owner: &str, +) -> Result, Err> { + let out = dynamo + .get_item() + .table_name(table) + .key("pk", AttributeValue::S(team_id.into())) + .key("sk", AttributeValue::S(backfill_sk(owner))) + .send() + .await?; + Ok(out + .item() + .and_then(|i| i.get("doc")) + .and_then(|v| v.as_s().ok()) + .and_then(|d| serde_json::from_str(d).ok())) +} + +pub async fn save_backfill( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + b: &Backfill, +) -> Result<(), Err> { + dynamo + .put_item() + .table_name(table) + .item("pk", AttributeValue::S(team_id.into())) + .item("sk", AttributeValue::S(backfill_sk(&b.owner))) + .item("doc", AttributeValue::S(serde_json::to_string(b)?)) + .send() + .await?; + Ok(()) +} + +/// A closed pull request from the sync's search, as its history row. +pub fn history_of_node(repo: &str, node: &serde_json::Value, now: i64) -> Option { + let number = node["number"].as_u64()?; + let mut r = PrRecord::new(repo, number); + r.apply_node(node, now); + (!r.is_open()).then(|| History::from_record(&r)) +} + // ─── Storage ──────────────────────────────────────────────────────────────── type Err = Box; @@ -498,6 +705,8 @@ pub struct Rework<'a> { pub by: (&'a str, u64), pub at: i64, pub revert: bool, + /// Why a follow-up is suspected. + pub reason: String, } /// Mark the earlier pull request reverted or followed up: only a merged @@ -516,11 +725,19 @@ pub async fn mark( if !h.merged || at < h.merged_at || (!revert && at - h.merged_at > REWORK_WINDOW_SECS) { return Ok(false); } - let link = (by.0.to_string(), by.1, at); if revert { - h.reverted_by = Some(link); - } else if !h.follow_ups.contains(&link) { - h.follow_ups.push(link); + h.reverted_by = Some((by.0.to_string(), by.1, at)); + } else if !h + .follow_ups + .iter() + .any(|f| f.repo == by.0 && f.number == by.1) + { + h.follow_ups.push(Suspect { + repo: by.0.to_string(), + number: by.1, + at, + reason: w.reason.clone(), + }); } else { return Ok(false); } @@ -743,9 +960,14 @@ mod tests { #[test] fn rework_counts_only_inside_the_window() { let mut h = merged("acme/web", 1, DAY, 20 * DAY); - h.follow_ups.push(("acme/web".into(), 2, NOW - 19 * DAY)); + h.follow_ups.push(Suspect { + repo: "acme/web".into(), + number: 2, + at: NOW - 19 * DAY, + reason: "names it in its description".into(), + }); assert!(h.reworked()); - h.follow_ups = vec![("acme/web".into(), 2, NOW)]; + h.follow_ups[0].at = NOW; assert!(!h.reworked()); } @@ -768,4 +990,39 @@ mod tests { vec![("acme/web".to_string(), 318), ("acme/api".to_string(), 12)] ); } + + #[test] + fn coverage_and_bypass_are_named_for_every_merge() { + let mut r = PrRecord::new("acme/web", 7); + r.author = "octocat".into(); + r.status = "merged".into(); + r.merged_by = "coderhelm[bot]".into(); + r.review_decision = Some("REVIEW_REQUIRED".into()); + r.approvals_required = 1; + let h = History::from_record(&r); + assert_eq!(h.coverage, "bypass_or_exempt"); + assert_eq!( + h.bypass.as_deref(), + Some("merged before the required review") + ); + assert_eq!( + h.merged_by_type, "coderhelm", + "CoderHelm's own merges count too" + ); + r.review_decision = None; + r.approvals_required = 0; + r.review_log.push(ReviewEvent { + who: "coderhelm[bot]".into(), + state: "APPROVED".into(), + ..Default::default() + }); + assert_eq!(coverage_of(&r), "ai_only"); + r.review_log.push(ReviewEvent { + who: "mara".into(), + state: "APPROVED".into(), + human: true, + ..Default::default() + }); + assert_eq!(coverage_of(&r), "human_approved"); + } } diff --git a/services/common/src/pr_record.rs b/services/common/src/pr_record.rs index f3bf7d548..e624318d8 100644 --- a/services/common/src/pr_record.rs +++ b/services/common/src/pr_record.rs @@ -173,6 +173,57 @@ pub struct CheckTransition { pub at: i64, } +/// One completed attempt of a check on a commit. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct CheckAttempt { + pub name: String, + pub sha: String, + pub conclusion: String, + pub at: i64, +} + +/// Checks that failed and then passed on the same commit. +pub fn flaky_checks(attempts: &[CheckAttempt]) -> Vec { + let mut out: Vec = Vec::new(); + for (i, a) in attempts.iter().enumerate() { + let failed = matches!(a.conclusion.as_str(), "failure" | "timed_out" | "error"); + if failed + && attempts[i + 1..] + .iter() + .any(|b| b.name == a.name && b.sha == a.sha && b.conclusion == "success") + && !out.contains(&a.name) + { + out.push(a.name.clone()); + } + } + out +} + +/// The pull request's kind from its author, labels and title. +pub fn category_of(author: &str, labels: &[String], title: &str) -> (&'static str, &'static str) { + let t = title.to_ascii_lowercase(); + let has = |w: &str| labels.iter().any(|l| l.to_ascii_lowercase().contains(w)) || t.contains(w); + let severity = ["critical", "high", "moderate", "low"] + .into_iter() + .find(|w| { + labels.iter().any(|l| l.to_ascii_lowercase().contains(w)) + || t.contains(&format!("[{w}]")) + || t.contains(&format!("{w} severity")) + }) + .unwrap_or(""); + let a = author.to_ascii_lowercase(); + let category = + if has("security") || has("vulnerab") || t.contains("cve-") || t.contains("ghsa-") { + "security" + } else if a.starts_with("dependabot") || a.starts_with("renovate") || has("dependenc") { + "dependency" + } else { + "feature" + }; + (category, severity) +} + /// Most review, request and check transitions kept on a record. pub const MAX_LOG: usize = 150; @@ -285,6 +336,25 @@ pub struct PrRecord { pub review_log: Vec, pub request_log: Vec, pub check_log: Vec, + /// Every completed attempt of each check on each head: a check that + /// failed and then passed on the same commit is flaky, not fixed. + pub check_attempts: Vec, + /// The last action of the author (a person), of a person reviewing, + /// and of any bot or CI. Bot and agent activity never moves the first + /// two, so a pull request only bots touch still reads as idle. + pub last_author_action_at: i64, + pub last_reviewer_action_at: i64, + pub last_bot_event_at: i64, + /// The files it changes (the sync reads them), and how far the base + /// moved under it since its last push: commits on the base, and those of + /// them touching its files. + pub files: Vec, + pub drift_behind: u32, + pub drift_overlap: u32, + /// `feature`, `dependency` or `security`, and a severity when the + /// labels or title name one (`critical`, `high`, `moderate`, `low`). + pub category: String, + pub severity: String, /// When the sync last read it (epoch seconds; 0 never). pub synced_at: i64, /// When an event last changed it. @@ -433,6 +503,13 @@ impl PrRecord { } fn event(&mut self, at: i64, actor: &str, kind: &str, text: String) { + if is_bot(actor) || actor == "ci" || actor.is_empty() { + self.last_bot_event_at = self.last_bot_event_at.max(at); + } else if actor.eq_ignore_ascii_case(&self.author) { + self.last_author_action_at = self.last_author_action_at.max(at); + } else { + self.last_reviewer_action_at = self.last_reviewer_action_at.max(at); + } let actor = if is_coderhelm(actor) { "coderhelm".to_string() } else { @@ -511,6 +588,9 @@ impl PrRecord { if let Some(labels) = pr["labels"].as_array() { self.labels = labels.iter().map(|l| s(&l["name"])).collect(); } + let (category, severity) = category_of(&self.author, &self.labels, &self.title); + self.category = category.into(); + self.severity = severity.into(); if let Some(r) = pr["requested_reviewers"].as_array() { self.requested = r.iter().map(login).filter(|l| !l.is_empty()).collect(); } @@ -623,6 +703,10 @@ impl PrRecord { if before != self.head_sha { self.checks.clear(); self.checks_sha = self.head_sha.clone(); + // A push brings the base in or rebases onto it, + // most of the time: the drift counts again. + self.drift_behind = 0; + self.drift_overlap = 0; } } "ready_for_review" => { @@ -861,6 +945,18 @@ impl PrRecord { conclusion: s(&run["conclusion"]), at: at(&run["completed_at"]).max(at(&run["started_at"])), }; + if c.status == "completed" && !c.conclusion.is_empty() { + let attempt = CheckAttempt { + name: name.clone(), + sha: sha.clone(), + conclusion: c.conclusion.clone(), + at: c.at, + }; + if !self.check_attempts.contains(&attempt) { + self.check_attempts.push(attempt); + bounded(&mut self.check_attempts); + } + } if c.failed() && self.checks.get(&name).is_none_or(|p| !p.failed()) { self.event(c.at, "ci", "check", format!("`{name}` failed")); } @@ -953,6 +1049,34 @@ impl PrRecord { } } + /// A push to its base branch: commits it is now behind, and those that + /// touch its files (from the push's own file lists). True when this + /// pull request is based on the pushed branch. + pub fn note_base_push(&mut self, branch: &str, payload: &Value, now: i64) -> bool { + if !self.is_open() || self.base_ref != branch { + return false; + } + for c in payload["commits"] + .as_array() + .into_iter() + .flatten() + .take(100) + { + self.drift_behind += 1; + let touched = ["added", "modified", "removed"].iter().any(|k| { + c[*k].as_array().into_iter().flatten().any(|f| { + f.as_str() + .is_some_and(|f| self.files.iter().any(|mine| mine == f)) + }) + }); + if touched { + self.drift_overlap += 1; + } + } + self.event_at = now; + true + } + /// The head's checks as one word: `red`, `pending` or `green`. pub fn check_rollup(&self) -> &'static str { if self.checks.is_empty() { @@ -1085,11 +1209,89 @@ impl PrRecord { self.base_ref = s(&n["baseRefName"]); self.created_at = ts(&n["createdAt"]); self.updated_at = ts(&n["updatedAt"]); + let files: Vec = n["files"]["nodes"] + .as_array() + .into_iter() + .flatten() + .filter_map(|f| f["path"].as_str().map(str::to_string)) + .take(300) + .collect(); + if !files.is_empty() { + self.files = files; + } + let (category, severity) = category_of(&self.author, &self.labels, &self.title); + self.category = category.into(); + self.severity = severity.into(); + let closed = [ts(&n["mergedAt"]), ts(&n["closedAt"])] + .into_iter() + .find(|t| *t > 0); + if let Some(t) = closed { + self.closed_at = t; + } + if let Some(by) = n["mergedBy"]["login"].as_str() { + self.merged_by = by.to_string(); + } + // Its timeline: when it left draft, and every review request. + let mut requests: Vec = Vec::new(); + for t in n["timelineItems"]["nodes"].as_array().into_iter().flatten() { + let at = ts(&t["createdAt"]); + let who = t["requestedReviewer"]["login"] + .as_str() + .map(str::to_string) + .or_else(|| { + t["requestedReviewer"]["slug"] + .as_str() + .map(|s| format!("{}/{s}", self.org())) + }) + .unwrap_or_default(); + match t["__typename"].as_str() { + Some("ReadyForReviewEvent") if self.ready_at == 0 || at < self.ready_at => { + self.ready_at = at + } + Some("ReviewRequestedEvent") if !who.is_empty() => requests.push(RequestEvent { + who, + at, + removed_at: 0, + }), + Some("ReviewRequestRemovedEvent") => { + if let Some(r) = requests + .iter_mut() + .rev() + .find(|r| r.who.eq_ignore_ascii_case(&who) && r.removed_at == 0) + { + r.removed_at = at; + } + } + _ => {} + } + } + if self.request_log.is_empty() { + self.request_log = requests; + } if self.ready_at == 0 && !self.draft { - // The search carries no ready time: the creation stands in - // until an event says better. + // Never a draft: ready from its creation. self.ready_at = self.created_at; } + // Every review, from GitHub, when no event recorded them. + if self.review_log.is_empty() { + let author = self.author.clone(); + for r in n["reviews"]["nodes"].as_array().into_iter().flatten() { + let who = login(&r["author"]); + if who.is_empty() { + continue; + } + self.review_log.push(ReviewEvent { + human: !is_bot(&who) && !who.eq_ignore_ascii_case(&author), + state: s(&r["state"]), + sha: s(&r["commit"]["oid"]), + at: ts(&r["submittedAt"]), + has_body: r["body"].as_str().is_some_and(|b| !b.trim().is_empty()), + who, + }); + } + self.review_log.sort_by_key(|r| r.at); + bounded(&mut self.review_log); + } self.additions = n["additions"].as_u64().unwrap_or(0) as u32; self.deletions = n["deletions"].as_u64().unwrap_or(0) as u32; self.labels = n["labels"]["nodes"] @@ -1392,7 +1594,11 @@ pub const SEARCH_QUERY: &str = "query($q: String!, $after: String) { autoMergeRequest { enabledAt } labels(first: 20) { nodes { name } } reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } ... on Team { slug } } } } + mergedAt closedAt mergedBy { login } + files(first: 100) { nodes { path } } latestOpinionatedReviews(first: 20) { nodes { state submittedAt author { login } commit { oid } } } + reviews(first: 40) { nodes { state submittedAt body author { login } commit { oid } } } + timelineItems(first: 40, itemTypes: [READY_FOR_REVIEW_EVENT, REVIEW_REQUESTED_EVENT, REVIEW_REQUEST_REMOVED_EVENT]) { nodes { __typename ... on ReadyForReviewEvent { createdAt } ... on ReviewRequestedEvent { createdAt requestedReviewer { ... on User { login } ... on Team { slug } } } ... on ReviewRequestRemovedEvent { createdAt requestedReviewer { ... on User { login } ... on Team { slug } } } } } participants(first: 20) { nodes { login } } reviewThreads(first: 50) { nodes { isResolved comments(first: 1) { nodes { author { login } } } } } baseRef { branchProtectionRule { requiredApprovingReviewCount requiresCodeOwnerReviews requiresConversationResolution requiredStatusCheckContexts } } @@ -1406,6 +1612,14 @@ pub const SEARCH_QUERY: &str = "query($q: String!, $after: String) { /// requests a page): the bound of one owner's sync. pub const MAX_PAGES: u32 = 10; +/// The search for an owner's pull requests closed or merged between two +/// days (`YYYY-MM-DD`, inclusive): the history backfill, a month at a time +/// so no window passes the search's 1,000 results. +pub fn closed_search_text(owner: &str, org: bool, from: &str, to: &str) -> String { + let q = if org { "org" } else { "user" }; + format!("is:pr is:closed {q}:{owner} closed:{from}..{to} sort:updated-desc") +} + /// The search for an owner's open pull requests. pub fn search_text(owner: &str, org: bool) -> String { let q = if org { "org" } else { "user" }; @@ -1811,4 +2025,48 @@ mod tests { r.closed_at = NOW; assert_eq!(r.ttl(), Some(NOW + CLOSED_KEEP_SECS)); } + + #[test] + fn health_signals_are_kept_for_every_author() { + let mut r = PrRecord::new("acme/web", 318); + r.apply_event("pull_request", &opened(), NOW); + // A bot's push never moves the people's clocks. + let author_at = r.last_author_action_at; + let mut bot = opened(); + bot["action"] = json!("synchronize"); + bot["sender"] = json!({"login": "coderhelm[bot]"}); + bot["pull_request"]["updated_at"] = json!("2026-01-10T15:00:00Z"); + r.apply_event("pull_request", &bot, NOW); + assert_eq!(r.last_author_action_at, author_at); + assert!(r.last_bot_event_at > author_at); + // A check that fails then passes on one commit is flaky. + for (c, t) in [ + ("failure", "2026-01-10T10:05:00Z"), + ("success", "2026-01-10T10:09:00Z"), + ] { + let run = json!({"check_run": {"name": "unit", "head_sha": r.head_sha, "status": "completed", + "conclusion": c, "completed_at": t}}); + r.apply_event("check_run", &run, NOW); + } + assert_eq!(flaky_checks(&r.check_attempts), vec!["unit"]); + // The base moving under it: behind, and touching its files. + r.files = vec!["cart/rounding.ts".into()]; + let push = json!({"ref": "refs/heads/main", "commits": [ + {"modified": ["cart/rounding.ts"]}, {"modified": ["README.md"]}]}); + assert!(r.note_base_push("main", &push, NOW)); + assert_eq!((r.drift_behind, r.drift_overlap), (2, 1)); + // Kinds and severities from the author, labels and title. + assert_eq!( + category_of("dependabot[bot]", &[], "Bump lodash"), + ("dependency", "") + ); + assert_eq!( + category_of( + "octocat", + &["security".into(), "severity: high".into()], + "Patch login" + ), + ("security", "high") + ); + } } diff --git a/services/gateway/src/routes/prs.rs b/services/gateway/src/routes/prs.rs index 1e6734c67..1136ddd13 100644 --- a/services/gateway/src/routes/prs.rs +++ b/services/gateway/src/routes/prs.rs @@ -73,6 +73,9 @@ pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, paylo .map(|b| pr_record::ref_sk(repo, b)), _ => None, }; + if event_type == "push" { + base_push(state, team_id, repo, payload).await; + } let Some(sk) = sk else { return }; match pr_record::pointed(&state.dynamo, table, team_id, &sk).await { Ok(Some(n)) => vec![n], @@ -129,12 +132,58 @@ pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, paylo } } +/// A push to a branch other pull requests are based on: their drift +/// (commits behind, and those touching their files). The repository's open +/// records only, at most 200. +async fn base_push(state: &AppState, team_id: &str, repo: &str, payload: &Value) { + let Some(branch) = payload["ref"] + .as_str() + .and_then(|r| r.strip_prefix("refs/heads/")) + else { + return; + }; + if payload["commits"].as_array().is_none_or(|c| c.is_empty()) { + return; + } + let table = &state.config.settings_table_name; + let prefix = format!("{}{repo}#", pr_record::SK_PREFIX); + let items = match items_under(state, team_id, &prefix).await { + Ok(i) => i, + Err(e) => { + warn!(repo, error = %e, "Drift: records not read"); + return; + } + }; + let t = now(); + for rec in pr_view::records_of(team_id, &items) + .into_iter() + .filter(|r| r.is_open() && r.base_ref == branch) + .take(200) + { + let _ = pr_record::update(&state.dynamo, table, team_id, repo, rec.number, t, |r| { + r.note_base_push(branch, payload, t) + }) + .await; + } +} + /// A pull request closed: its history row (kept over a year), and on a /// merge the revert or follow-up links to the merged pull requests it /// names. async fn record_history(state: &AppState, team_id: &str, rec: &PrRecord, now: i64) { let table = &state.config.settings_table_name; - let h = common::pr_history::History::from_record(rec); + let mut h = common::pr_history::History::from_record(rec); + if !h.run_ids.is_empty() { + let runs = runs_by_id(state, team_id, &h.run_ids).await; + if let Some(last) = h.run_ids.iter().rev().find_map(|id| runs.get(id)) { + h.run_outcome = last.status.clone(); + h.stop_reason = last + .stop + .as_ref() + .map(|s| s.code.clone()) + .unwrap_or_default(); + } + } if let Err(e) = common::pr_history::put(&state.dynamo, table, team_id, &h, now).await { warn!(repo = %rec.repo, number = rec.number, error = %e, "Pull request history not written"); return; @@ -165,6 +214,18 @@ async fn record_history(state: &AppState, team_id: &str, rec: &PrRecord, now: i6 by: (&rec.repo, rec.number), at: rec.closed_at.max(1), revert, + reason: if revert { + String::new() + } else if rec + .labels + .iter() + .any(|l| l.to_ascii_lowercase().contains("hotfix")) + || rec.title.to_ascii_lowercase().contains("hotfix") + { + "a hotfix that names it, merged within 14 days of it".into() + } else { + "names it in its description, merged within 14 days of it".into() + }, }, now, ) @@ -523,7 +584,9 @@ pub async fn list_prs( let rows = pr_view::rows(&claims.team_id, items, joins, viewer, now()); let synced = synced_at(items, &claims.team_id, &query); let page = pr_view::page(rows, &query, limit, cursor.as_deref()); + let backfill = backfill_progress(&state, &claims.team_id).await; Ok(Json(json!({ + "backfill": backfill, "prs": page.rows, "total": page.total, "next": page.next, @@ -534,6 +597,38 @@ pub async fn list_prs( }))) } +/// Pure: each organization's history backfill as the page shows it. +pub fn backfill_json(items: &[Item]) -> Vec { + use common::pr_history::{Backfill, BACKFILL_MONTHS}; + items + .iter() + .filter_map(|i| i.get("doc").and_then(|v| v.as_s().ok())) + .filter_map(|d| serde_json::from_str::(d).ok()) + .map(|b| { + json!({ + "owner": b.owner, + "months_read": b.months_read.min(BACKFILL_MONTHS), + "months_total": BACKFILL_MONTHS, + "done": b.done, + "paused_until": (b.paused_until > 0).then(|| pr_view::rfc3339(b.paused_until)).flatten(), + "paused_why": (!b.paused_why.is_empty()).then_some(b.paused_why), + "repos": b.repos, + "updated_at": pr_view::rfc3339(b.updated_at), + }) + }) + .collect() +} + +async fn backfill_progress(state: &AppState, team_id: &str) -> Vec { + match items_under(state, team_id, common::pr_history::BACKFILL_PREFIX).await { + Ok(items) => backfill_json(&items), + Err(e) => { + warn!(team_id, error = %e, "Pull requests: backfill progress not read"); + Vec::new() + } + } +} + #[derive(Deserialize)] pub struct DetailQuery { repo: String, diff --git a/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs index 3e9bf79a5..c33ca1404 100644 --- a/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs +++ b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs @@ -334,3 +334,77 @@ fn no_pull_request_of_another_team_reaches_a_row() { let perms = src("gateway/src/permissions.rs"); assert!(perms.contains("\"prs::list_prs\"") && perms.contains("\"prs::get_pr\"")); } + +#[test] +fn a_repository_with_only_peoples_pull_requests_gets_full_records_and_history() { + let team = "TEAM#bookstore"; + // A person's pull request, end to end from its events: opened, a review + // request, a person's review, a check, and the merge. + let mut r = PrRecord::new("acme/web", 21); + assert!(r.apply_event("pull_request", &opened(21, "octocat"), NOW)); + let mut asked = opened(21, "octocat"); + asked["action"] = serde_json::json!("review_requested"); + asked["requested_reviewer"] = serde_json::json!({"login": "mara"}); + assert!(r.apply_event("pull_request", &asked, NOW)); + let review = serde_json::json!({"action": "submitted", "pull_request": {"number": 21}, + "review": {"user": {"login": "mara"}, "state": "approved", "commit_id": HEAD, + "submitted_at": "2026-01-10T12:00:00Z", "body": "Looks right."}}); + assert!(r.apply_event("pull_request_review", &review, NOW)); + let check = serde_json::json!({"check_run": {"name": "unit", "head_sha": HEAD, + "status": "completed", "conclusion": "success", "completed_at": "2026-01-10T11:00:00Z"}}); + assert!(r.apply_event("check_run", &check, NOW)); + let rows = pr_view::rows(team, &[item(team, &r)], &Joins::default(), None, NOW); + assert_eq!(rows.len(), 1); + assert!(!rows[0].author.coderhelm); + assert_eq!(r.request_log.len(), 1); + assert!(r.review_log[0].human); + assert_eq!(r.check_log.last().map(|c| c.rollup.as_str()), Some("green")); + let mut merged = opened(21, "octocat"); + merged["action"] = serde_json::json!("closed"); + merged["pull_request"]["state"] = serde_json::json!("closed"); + merged["pull_request"]["merged"] = serde_json::json!(true); + merged["pull_request"]["merged_at"] = serde_json::json!("2026-01-11T10:00:00Z"); + assert!(r.apply_event("pull_request", &merged, NOW)); + let h = common::pr_history::History::from_record(&r); + assert!(h.merged && h.author_type == "person" && h.coderhelm_role == "none"); + assert_eq!(h.first_review_secs(), Some(2 * 3600)); + assert_eq!(h.cycle_secs(), Some(24 * 3600)); + + // A person's closed pull request from the backfill's search, with no + // events at all, becomes history too: reviews and ready time included. + let node = serde_json::json!({ + "number": 22, "title": "Bookstore shelf labels", "state": "MERGED", "isDraft": false, + "createdAt": "2026-01-01T09:00:00Z", "updatedAt": "2026-01-03T09:00:00Z", + "mergedAt": "2026-01-03T09:00:00Z", "closedAt": "2026-01-03T09:00:00Z", + "mergedBy": {"login": "mara"}, "author": {"login": "theo"}, + "repository": {"nameWithOwner": "acme/web"}, "headRefOid": HEAD, + "reviews": {"nodes": [{"state": "APPROVED", "submittedAt": "2026-01-02T09:00:00Z", + "body": "", "author": {"login": "mara"}, "commit": {"oid": HEAD}}]}, + "timelineItems": {"nodes": [{"__typename": "ReviewRequestedEvent", + "createdAt": "2026-01-01T10:00:00Z", "requestedReviewer": {"login": "mara"}}]} + }); + let h = common::pr_history::history_of_node("acme/web", &node, NOW).expect("history"); + assert_eq!(h.author_type, "person"); + assert_eq!(h.first_review_secs(), Some(86_400)); + assert_eq!(h.request_log.len(), 1); + + // Nothing on the way filters to CoderHelm's own pull requests: the + // writer, the sync and the backfill keep every author. + for file in [ + "gateway/src/routes/prs.rs", + "worker/src/passes/pr_records.rs", + "common/src/pr_history.rs", + ] { + let s = src(file); + let code = &s[..s.find("#[cfg(test)]").unwrap_or(s.len())]; + for filter in [ + "author_is_coderhelm() {\n continue", + "if !rec.author_is_coderhelm()", + "contains(\"coderhelm\") {\n return", + ] { + assert!(!code.contains(filter), "{file} filters by author"); + } + } + let sync = src("worker/src/passes/pr_records.rs"); + assert!(sync.contains("for owner in owners {\n backfill_owner(")); +} diff --git a/services/worker/src/passes/pr_records.rs b/services/worker/src/passes/pr_records.rs index ad5ca8e20..7adcc34e9 100644 --- a/services/worker/src/passes/pr_records.rs +++ b/services/worker/src/passes/pr_records.rs @@ -31,8 +31,14 @@ pub struct SweepReport { pub written: usize, pub removed: usize, pub pages: u32, + /// Closed and merged pull requests written to history. + pub history: usize, } +/// Pages of closed pull requests one sweep reads per organization: the +/// history backfill's share of the budget each hour. +pub const CLOSED_PAGES_PER_SWEEP: u32 = 5; + /// The sweep tick: each team at most once an hour. pub async fn sweep(state: &WorkerState) -> SweepReport { let mut report = SweepReport::default(); @@ -162,7 +168,7 @@ async fn sync_team( } }; let table = &state.config.settings_table_name; - for owner in owners { + for owner in owners.clone() { let mut seen: HashSet = HashSet::new(); let mut complete = false; let mut after: Option = None; @@ -250,6 +256,140 @@ async fn sync_team( } } } + // Every closed and merged pull request of the last 14 months, people's, + // bots' and CoderHelm's alike, into history: resumed where it stopped. + for owner in owners { + backfill_owner( + state, + team_id, + installation_id, + &github, + &owner, + &keep, + gate, + report, + ) + .await; + } +} + +/// One organization's history backfill, a month at a time from the newest, +/// at most [`CLOSED_PAGES_PER_SWEEP`] pages per sweep, under the shared +/// budget: a held budget pauses it with the reason and the time, and the +/// next sweep resumes from the stored page cursor. Once all 14 months are +/// read, each sweep reads the closed pull requests since its last day. +#[allow(clippy::too_many_arguments)] +async fn backfill_owner( + state: &WorkerState, + team_id: &str, + installation_id: u64, + github: &GitHubClient, + owner: &str, + keep: &HashSet, + gate: &mut SweepGate, + report: &mut SweepReport, +) { + use common::pr_history::{self, Backfill, BACKFILL_MONTHS}; + let table = &state.config.settings_table_name; + let now = chrono::Utc::now().timestamp(); + let mut b = match pr_history::load_backfill(&state.dynamo, table, team_id, owner).await { + Ok(Some(b)) => b, + Ok(None) => Backfill { + owner: owner.to_string(), + started_at: now, + ..Default::default() + }, + Err(e) => { + warn!(team_id, owner, error = %e, "History backfill: progress not read"); + return; + } + }; + if b.paused_until > now { + return; + } + b.paused_until = 0; + b.paused_why.clear(); + let today = chrono::Utc::now().format("%Y-%m-%d").to_string(); + let mut as_org = true; + let mut pages = 0; + while pages < CLOSED_PAGES_PER_SWEEP { + let (from, to) = if b.done { + if b.reconciled_to == today && b.cursor.is_none() { + break; + } + let from = if b.reconciled_to.is_empty() { + Backfill::window(now, 0).0 + } else { + b.reconciled_to.clone() + }; + (from, today.clone()) + } else { + Backfill::window(now, b.months_read) + }; + if !gate.allows(state, installation_id, 1).await { + b.paused_until = now + gate.retry_in().unwrap_or(3600) as i64; + b.paused_why = "GitHub's hourly budget is kept for runs and people now".into(); + break; + } + let q = pr_record::closed_search_text(owner, as_org, &from, &to); + let vars = json!({"q": q, "after": b.cursor}); + let data = match github.graphql_read(pr_record::SEARCH_QUERY, vars).await { + Ok(d) => d, + Err(_) if as_org && pages == 0 && b.cursor.is_none() => { + as_org = false; + continue; + } + Err(e) => { + let why = e.to_string(); + b.paused_until = now + 3600; + b.paused_why = if why.to_ascii_lowercase().contains("rate limit") { + "GitHub's rate limit was reached".into() + } else { + "GitHub's search didn't answer".into() + }; + warn!(team_id, owner, error = %why, "History backfill paused"); + break; + } + }; + pages += 1; + b.pages += 1; + report.pages += 1; + for node in data["search"]["nodes"].as_array().into_iter().flatten() { + let repo = node["repository"]["nameWithOwner"].as_str().unwrap_or(""); + if !keep.contains(&repo.to_ascii_lowercase()) { + continue; + } + let Some(h) = pr_history::history_of_node(repo, node, now) else { + continue; + }; + match pr_history::put(&state.dynamo, table, team_id, &h, now).await { + Ok(()) => { + report.history += 1; + *b.repos.entry(repo.to_string()).or_default() += 1; + } + Err(e) => warn!(team_id, repo, error = %e, "History row not written"), + } + } + let info = &data["search"]["pageInfo"]; + if info["hasNextPage"].as_bool() == Some(true) { + b.cursor = info["endCursor"].as_str().map(str::to_string); + continue; + } + b.cursor = None; + if b.done { + b.reconciled_to = today.clone(); + break; + } + b.months_read += 1; + if b.months_read >= BACKFILL_MONTHS { + b.done = true; + b.reconciled_to = today.clone(); + } + } + b.updated_at = now; + if let Err(e) = pr_history::save_backfill(&state.dynamo, table, team_id, &b).await { + warn!(team_id, owner, error = %e, "History backfill: progress not written"); + } } #[cfg(test)] From 053806e7654f73c70b1b61f7909926ff83d45e6e Mon Sep 17 00:00:00 2001 From: Nam Bok Rodriguez Date: Sat, 5 Dec 2026 17:10:02 -0500 Subject: [PATCH 05/19] The org's pull requests in one answer: GET /api/prs/overview (#988) * The org's pull requests in one answer: GET /api/prs/overview Every pull request in the team's repositories counts, people's, CoderHelm's and other bots'; CoderHelm's are one slice. Computed facts only, with thresholds from the scope's own percentiles, no rate on fewer than 10 events, and what isn't stored yet named in `missing`. No per-person ranking, count or duration; a login appears only as one item's owner. The summary's numbers are all facts. GET /api/prs takes the overview's drill-down (stage, past p85/p95). Incident case xz pins it. * Overview: clippy's shapes, and words without hand-off phrases or loose numbers The stability line says "over the last month" so every number in the summary is a fact; the incident case reads the route's source without whitespace, so formatting can't hide a read. * A reopened change and a later alert recovery reach their waiting runs at once (#986) A run stopped because the change it built on closed now goes back to waiting as soon as GitHub reports the change reopened, not at the 15-minute sweep. The pull request handler sends the team's change check for a close or a reopen before any return a reopen reaches, naming the change, and the worker reads the runs that change's close stopped (the sweep stays the backstop for every team). A recovery posted after an alert route's quiet window now closes the run waiting on a person for that alert, through the same path a recovery posted at once uses (common::run_wake::alert_cleared, which the gateway's alert_delivery now calls too). Incident case xx_waits_never_outlive_their_event. --- .../xx_waits_never_outlive_their_event.md | 5 + docs/incidents/xz_org_overview_facts_only.md | 5 + services/common/src/change_wait.rs | 34 + services/common/src/lib.rs | 1 + services/common/src/messages.rs | 14 +- services/common/src/pr_overview.rs | 2139 +++++++++++++++++ services/common/src/run_wake.rs | 143 ++ services/gateway/src/main.rs | 1 + services/gateway/src/permissions.rs | 1 + services/gateway/src/routes/alerts.rs | 5 +- services/gateway/src/routes/github_webhook.rs | 86 +- services/gateway/src/routes/mod.rs | 1 + services/gateway/src/routes/prs.rs | 112 +- services/gateway/src/routes/prs_overview.rs | 269 +++ services/gateway/src/routes/run_wake.rs | 91 +- services/worker/src/main.rs | 2 +- services/worker/src/passes/alert_episodes.rs | 10 + services/worker/src/passes/change_wait.rs | 41 +- .../passes/incidents/bm_teams_never_cross.rs | 4 + .../incidents/wz_waits_go_on_by_themselves.rs | 2 +- .../xx_waits_never_outlive_their_event.rs | 126 + .../incidents/xz_org_overview_facts_only.rs | 459 ++++ 22 files changed, 3450 insertions(+), 101 deletions(-) create mode 100644 docs/incidents/xx_waits_never_outlive_their_event.md create mode 100644 docs/incidents/xz_org_overview_facts_only.md create mode 100644 services/common/src/pr_overview.rs create mode 100644 services/gateway/src/routes/prs_overview.rs create mode 100644 services/worker/src/passes/incidents/xx_waits_never_outlive_their_event.rs create mode 100644 services/worker/src/passes/incidents/xz_org_overview_facts_only.rs diff --git a/docs/incidents/xx_waits_never_outlive_their_event.md b/docs/incidents/xx_waits_never_outlive_their_event.md new file mode 100644 index 000000000..c8bd46866 --- /dev/null +++ b/docs/incidents/xx_waits_never_outlive_their_event.md @@ -0,0 +1,5 @@ +# xx. `xx_waits_never_outlive_their_event` + +**What happened:** Two waits went on after what they waited for had happened. A run stopped because the change it built on closed without merging was told that reopening the change takes it back to waiting by itself. The change was reopened, and the run kept waiting on a person until the 15-minute sweep: the reopen webhook went on to the review triggers and returned, and the check a pull request event sent read only the runs still waiting for a merge, not the runs that change's close had stopped. On an alert route that waits out a quiet window before posting the recovery, the run waiting on a person for that alert stayed waiting after the recovery posted. Only a recovery posted at once closed it; the later post, made by the worker's episode check, never reached the run. + +**The guarantee:** A pull request closed or reopened sends the team's change check before any return a reopen reaches, and the check names that change. It reads the runs still waiting for a merge and the runs stopped by that change's close, so a reopen takes the stopped run back to waiting at once and a merge sends it on. The 15-minute sweep stays the backstop for every team. A recovery closes its waiting run through one path, `common::run_wake::alert_cleared`, whether it posts at once (the gateway's `alert_delivery`) or after the quiet window (the worker's episode check). diff --git a/docs/incidents/xz_org_overview_facts_only.md b/docs/incidents/xz_org_overview_facts_only.md new file mode 100644 index 000000000..5f925c561 --- /dev/null +++ b/docs/incidents/xz_org_overview_facts_only.md @@ -0,0 +1,5 @@ +# xz. `xz_org_overview_facts_only` + +**What happened:** A leader opened the pull requests page to understand the state of the org's pull requests and found only a list: nothing said what was stuck, on whom, or whether that was usual for the org. The overview above the list answers that, and it is the one place a page could rank people, print a number nothing computed, or mix two teams' pull requests. + +**The guarantee:** `GET /api/prs/overview` (`common::pr_overview::build`) covers every pull request in the team's repositories, people's, CoderHelm's and other bots', and returns computed facts only. No per-person ranking, count or duration is ever returned; a GitHub login appears only as the owner of one item under "Needs attention". Every number in the summary is the value of a fact in `facts`, and the words between them carry no numbers of their own. Thresholds are percentiles of the scope's own history (a repo's own from 30 merges in 90 days, else the org's), no rate is shown on fewer than 10 events, and what CoderHelm doesn't store yet is `null` and named in `missing`, never estimated. The Stale tile and the Stale panel's headline are one number. An org with no CoderHelm pull requests gets the whole overview. Every read is keyed by the session's team, and the short cache by the installation, the team and the scope, listed in `bm_teams_never_cross`. diff --git a/services/common/src/change_wait.rs b/services/common/src/change_wait.rs index 4b18ced3e..c37e6888b 100644 --- a/services/common/src/change_wait.rs +++ b/services/common/src/change_wait.rs @@ -294,6 +294,20 @@ pub fn waits_on_close(action: &str) -> bool { a.starts_with("Reopen ") && a.contains(CLOSED_ASK) } +/// Whether the pull request `pr` of `repo` that moved (a merge, a close, a +/// reopen as GitHub reports it) is the change `dep` waits on. An empty repo +/// or no number (the sweep) reads every dependency. +pub fn moved_is(dep: &Dependency, repo: &str, pr: u64) -> bool { + repo.is_empty() || pr == 0 || (dep.pr == pr && dep.repo.eq_ignore_ascii_case(repo)) +} + +/// Whether a pull request event `action` asks the team's waiting runs to +/// read their change again: a close (merged or not) settles a wait, and a +/// reopen takes a run stopped by that close back to waiting at once. +pub fn event_moves_change(action: &str) -> bool { + matches!(action, "closed" | "reopened") +} + /// The reason a run stops when its dependency closed without merging. pub fn closed_reason(dep: &Dependency) -> String { format!( @@ -328,6 +342,26 @@ mod after_close_tests { assert_eq!(crate::rendered::person_text(&a), None, "{a}"); } + #[test] + fn a_reopen_or_close_reaches_only_the_runs_of_that_change() { + assert!(event_moves_change("reopened")); + assert!(event_moves_change("closed")); + for other in ["opened", "synchronize", "edited", "labeled", ""] { + assert!(!event_moves_change(other), "{other}"); + } + let dep = Dependency { + ticket: "WEB-7".into(), + repo: "acme/bookstore-web".into(), + pr: 12, + ..Default::default() + }; + assert!(moved_is(&dep, "Acme/Bookstore-Web", 12)); + assert!(!moved_is(&dep, "acme/bookstore-web", 13)); + assert!(!moved_is(&dep, "acme/other", 12)); + // The sweep names no change: every dependency is read. + assert!(moved_is(&dep, "", 0)); + } + #[test] fn only_the_closed_change_stop_is_read_as_its_change_closing() { let dep = Dependency { diff --git a/services/common/src/lib.rs b/services/common/src/lib.rs index 32f2da030..4566f7905 100644 --- a/services/common/src/lib.rs +++ b/services/common/src/lib.rs @@ -279,6 +279,7 @@ pub mod pr_layout; pub mod pr_needs; /// What happened to a PR CoderHelm opened, read from GitHub. pub mod pr_outcome; +pub mod pr_overview; /// The last read of a description before it is saved, verified. pub mod pr_reader; pub mod pr_record; diff --git a/services/common/src/messages.rs b/services/common/src/messages.rs index cc0cb05f7..ad3d78a26 100644 --- a/services/common/src/messages.rs +++ b/services/common/src/messages.rs @@ -238,9 +238,11 @@ pub enum WorkerMessage { /// sends one too). #[serde(rename = "role_reads_wait")] RoleReadsWait(RoleReadsWaitMessage), - /// A pull request of the team merged or closed: its runs waiting for - /// another change (`awaiting_change`, `crate::change_wait`) read their - /// dependency again (the self-heal sweep checks every 15 minutes too). + /// A pull request of the team merged, closed or reopened: its runs + /// waiting for another change (`awaiting_change`, `crate::change_wait`) + /// read their dependency again, and a run stopped because that change + /// closed waits for it again (the self-heal sweep checks every 15 + /// minutes too). #[serde(rename = "change_wait_check")] ChangeWaitCheck(ChangeWaitCheckMessage), /// Read a team's open pull requests into their records @@ -965,6 +967,12 @@ pub struct PrRecordsSyncMessage { #[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)] pub struct ChangeWaitCheckMessage { pub team_id: String, + /// `owner/repo` of the pull request that moved (empty: any). + #[serde(default, skip_serializing_if = "String::is_empty")] + pub repo: String, + /// The pull request that moved (0: any). + #[serde(default)] + pub pr: u64, } /// Re-check the role of a run waiting for the install's "AWS role reads" diff --git a/services/common/src/pr_overview.rs b/services/common/src/pr_overview.rs new file mode 100644 index 000000000..7cf3dd90a --- /dev/null +++ b/services/common/src/pr_overview.rs @@ -0,0 +1,2139 @@ +//! The org's pull requests in one answer: the overview page's summary, +//! stage strip, aging dots, repos, the stale, failure, review and security +//! panels, this week's events and CoderHelm's slice. +//! +//! Every number covers every pull request in the team's repositories: +//! people's, CoderHelm's and other bots'. CoderHelm's are one slice, in +//! `coderhelm` only. +//! +//! - Computed facts only. Thresholds are percentiles of the scope's own +//! history (`pr_history`): a repository uses its own once it has +//! [`pr_history::MIN_MERGED_FOR_OWN`] merges in 90 days, else the org's. +//! Before 8 weeks of history (or while the backfill runs) the external +//! bands stand beside them, labeled as external. +//! - No rate is shown on fewer than [`MIN_EVENTS`] events. +//! - What isn't stored yet is `null` and named in `missing`, with +//! `history` (the store is younger than the comparison) or +//! `not_recorded` (CoderHelm doesn't keep it yet). Nothing is estimated. +//! - No per-person count, ranking or duration is ever returned. A GitHub +//! login appears only as `summary.attention[].owner`, the owner of one +//! pull request's next move ([`owner_of`]). +//! - The summary's sentences are fixed templates over [`Fact`]s; every +//! number in them is a fact's value ([`Builder::num`]). +//! +//! Pure: the gateway reads the rows and calls [`build`]. + +use std::collections::{BTreeMap, BTreeSet}; + +use serde_json::{json, Value}; + +use crate::pr_history::{self, Backfill, History, Snapshot, MIN_MERGED_FOR_OWN, MIN_WEEKS_OWN}; +use crate::pr_record::{is_bot, is_coderhelm, PrRecord}; +use crate::pr_view::{rfc3339, Row}; + +const HOUR: i64 = 3_600; +const DAY: i64 = 86_400; + +/// No rate on fewer events than this. +pub const MIN_EVENTS: usize = 10; +/// A stale clock never fires under one day, so tiny repos still signal. +pub const STALE_FLOOR_SECS: i64 = DAY; +/// Abandoned candidates: no author action for at least this long. +pub const ABANDONED_FLOOR_SECS: i64 = 14 * DAY; +/// Archive candidates: idle this long. +pub const ARCHIVE_SECS: i64 = 30 * DAY; +/// Most aging dots sent (the oldest). +pub const MAX_DOTS: usize = 400; +/// Most repositories in the table. +pub const MAX_REPOS: usize = 300; +/// Large PR: more changed lines than this. +pub const LARGE_LINES: u32 = 400; +/// A wait is mentioned only past this. +pub const WAIT_FLOOR_SECS: i64 = DAY; + +/// Security deadlines by severity (days). Known-exploited counts as critical. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Sla { + pub critical: i64, + pub high: i64, + pub medium: i64, + pub low: i64, +} + +impl Default for Sla { + fn default() -> Self { + Sla { + critical: 7, + high: 30, + medium: 90, + low: 180, + } + } +} + +impl Sla { + pub fn days(&self, severity: &str) -> i64 { + match severity { + "critical" | "kev" => self.critical, + "high" => self.high, + "medium" | "moderate" => self.medium, + _ => self.low, + } + } +} + +/// One open pull request: its record and its row (the same decision the +/// list shows). +pub struct Open { + pub rec: PrRecord, + pub row: Row, +} + +/// Everything the overview reads, already scoped to the team. +pub struct Input<'a> { + pub open: &'a [Open], + /// History rows closed in the last ~400 days. + pub hist: &'a [History], + /// The scope's daily snapshots, oldest first (org, or the repo). + pub snaps: &'a [Snapshot], + /// Each repository's snapshots, oldest first (those read). + pub repo_snaps: &'a BTreeMap>, + pub backfill: &'a [Backfill], + pub org: Option<&'a str>, + pub repo: Option<&'a str>, + pub window_days: i64, + pub sla: Sla, + pub now: i64, +} + +/// One computed fact the summary may be written from. +#[derive(Debug, Clone, PartialEq)] +pub struct Fact { + pub id: String, + pub scope: String, + pub value: f64, + pub prev: Option, + pub weight: f64, + pub link: Value, +} + +/// The windows' parsing: `7d`, `14d`, `28d`; anything else is 7. +pub fn window_days(w: Option<&str>) -> Option { + match w.unwrap_or("7d") { + "7d" => Some(7), + "14d" => Some(14), + "28d" => Some(28), + _ => None, + } +} + +fn in_scope(org: Option<&str>, repo: Option<&str>, name: &str) -> bool { + if let Some(r) = repo { + return name.eq_ignore_ascii_case(r); + } + match org { + Some(o) => name + .split('/') + .next() + .is_some_and(|x| x.eq_ignore_ascii_case(o)), + None => true, + } +} + +fn pct(v: &[i64], p: u32) -> Option { + pr_history::percentile(v, p) +} + +fn share(n: usize, d: usize) -> Option { + (d >= MIN_EVENTS).then(|| n as f64 / d as f64) +} + +fn round3(v: f64) -> f64 { + (v * 1000.0).round() / 1000.0 +} + +fn median(v: &[i64]) -> Option { + pct(v, 50) +} + +/// The scope's cycle-time percentiles and where they came from. +#[derive(Debug, Clone, Default)] +struct Lines { + cycle: Option<[i64; 3]>, + first_review: Option<[i64; 2]>, + stage_p85: BTreeMap, + merged: usize, + inherited: bool, +} + +fn lines_of(hist: &[&History], now: i64) -> Lines { + let cycles: Vec = hist + .iter() + .filter(|h| h.merged_at > now - 90 * DAY) + .filter_map(|h| h.cycle_secs()) + .collect(); + let first: Vec = hist + .iter() + .filter(|h| h.closed_at > now - 56 * DAY) + .filter_map(|h| h.first_review_secs()) + .collect(); + let mut stages: BTreeMap> = BTreeMap::new(); + for h in hist.iter().filter(|h| h.closed_at > now - 90 * DAY) { + for (i, s) in h.spans.iter().enumerate() { + if s.stage.is_empty() { + continue; + } + let to = h + .spans + .get(i + 1) + .map(|n| n.from) + .unwrap_or(h.closed_at.max(h.merged_at)); + stages + .entry(s.stage.clone()) + .or_default() + .push((to - s.from).max(0)); + } + } + Lines { + cycle: match (pct(&cycles, 50), pct(&cycles, 85), pct(&cycles, 95)) { + (Some(a), Some(b), Some(c)) => Some([a, b, c]), + _ => None, + }, + first_review: match (pct(&first, 50), pct(&first, 85)) { + (Some(a), Some(b)) => Some([a, b]), + _ => None, + }, + stage_p85: stages + .into_iter() + .filter_map(|(k, v)| pct(&v, 85).map(|p| (k, p))) + .collect(), + merged: cycles.len(), + inherited: false, + } +} + +/// The org's lines, or a repository's own once it has enough merges. +fn scope_lines(all: &[&History], org: Option<&str>, repo: Option<&str>, now: i64) -> Lines { + let org_name = repo + .and_then(|r| r.split('/').next()) + .or(org) + .map(str::to_string); + let org_hist: Vec<&History> = all + .iter() + .copied() + .filter(|h| in_scope(org_name.as_deref(), None, &h.repo)) + .collect(); + let org_lines = lines_of(&org_hist, now); + let Some(r) = repo else { return org_lines }; + let own_hist: Vec<&History> = org_hist + .iter() + .copied() + .filter(|h| h.repo.eq_ignore_ascii_case(r)) + .collect(); + let own = lines_of(&own_hist, now); + if own.merged >= MIN_MERGED_FOR_OWN { + own + } else { + Lines { + inherited: true, + ..org_lines + } + } +} + +/// Age since ready (drafts from creation). +fn age(o: &Open, now: i64) -> i64 { + let start = if o.rec.draft { + o.rec.created_at + } else { + o.rec.ready_or_created() + }; + (now - start).max(0) +} + +fn stage(o: &Open) -> &str { + o.row.stage.as_deref().unwrap_or("") +} + +/// The login or team whose move a pull request is, when one person or +/// team holds it: the only place a name appears. +pub fn owner_of(row: &Row) -> (Option, Option<&'static str>) { + for f in &row.next.from { + if let Some(p) = f.strip_prefix("person:") { + if !is_bot(p) { + return (Some(p.to_string()), Some("person")); + } + } + if let Some(t) = f.strip_prefix("team:") { + return (Some(t.to_string()), Some("team")); + } + if f == "author" && !is_bot(&row.author.login) { + return (Some(row.author.login.clone()), Some("person")); + } + } + (None, None) +} + +/// Who holds the turn and how long they have been idle: only people's +/// actions reset the clock, and the author's and reviewers' clocks are +/// kept apart. +fn idle_of(o: &Open, now: i64) -> Option<(&'static str, i64)> { + if o.row.turn != "person" && o.row.turn != "you" { + return None; + } + let on_author = o + .row + .next + .from + .iter() + .any(|f| f == "author" || f == &format!("person:{}", o.rec.author)); + let clock = if on_author { + o.rec.last_author_action_at + } else { + o.rec.last_reviewer_action_at + }; + let since = clock.max(o.rec.ready_or_created()); + Some(( + if on_author { "author" } else { "reviewer" }, + (now - since).max(0), + )) +} + +fn stale_threshold(lines: &Lines, stage: &str) -> i64 { + lines + .stage_p85 + .get(stage) + .copied() + .unwrap_or(STALE_FLOOR_SECS) + .max(STALE_FLOOR_SECS) +} + +fn is_stale(o: &Open, lines: &Lines, now: i64) -> Option<&'static str> { + let st = stage(o); + if st.is_empty() || st == "draft" || st == "blocked" { + return None; + } + let (who, idle) = idle_of(o, now)?; + (idle > stale_threshold(lines, st)).then_some(who) +} + +fn is_abandoned(o: &Open, lines: &Lines, now: i64) -> bool { + if o.rec.draft { + return false; + } + let floor = lines + .cycle + .map(|c| c[2]) + .unwrap_or(0) + .max(ABANDONED_FLOOR_SECS); + let last_author = o.rec.last_author_action_at.max(o.rec.ready_or_created()); + let unanswered = o + .rec + .review_log + .iter() + .any(|r| r.human && r.state == "CHANGES_REQUESTED" && r.at > last_author); + now - last_author > floor && unanswered +} + +fn is_zombie(o: &Open, lines: &Lines, now: i64) -> bool { + let Some(c) = lines.cycle else { return false }; + let last_human = o + .rec + .last_author_action_at + .max(o.rec.last_reviewer_action_at); + age(o, now) > c[2] && now - last_human > c[1] && o.rec.last_bot_event_at > now - c[1] +} + +fn band(age: i64, lines: &Lines) -> Value { + match lines.cycle { + Some([_, _, p95]) if age > p95 => json!("p95"), + Some([_, p85, _]) if age > p85 => json!("p85"), + Some([p50, _, _]) if age > p50 => json!("p50"), + _ => Value::Null, + } +} + +fn past_p85(o: &Open, lines: &Lines, now: i64) -> bool { + !o.rec.draft && lines.cycle.is_some_and(|c| age(o, now) > c[1]) +} + +/// The snapshot nearest to `days` ago, when one exists within two days. +fn snap_at(snaps: &[Snapshot], now: i64, days: i64) -> Option<&Snapshot> { + let want = now - days * DAY; + snaps + .iter() + .filter_map(|s| { + let t = chrono::NaiveDate::parse_from_str(&s.day, "%Y-%m-%d") + .ok()? + .and_hms_opt(12, 0, 0)? + .and_utc() + .timestamp(); + Some((s, (t - want).abs())) + }) + .filter(|(_, d)| *d <= 2 * DAY) + .min_by_key(|(_, d)| *d) + .map(|(s, _)| s) +} + +/// Eight weekly values of a snapshot field, oldest first, when at least two +/// weeks have one. +fn weekly(snaps: &[Snapshot], now: i64, f: impl Fn(&Snapshot) -> u32) -> Option> { + let v: Vec = (0..8) + .rev() + .filter_map(|w| snap_at(snaps, now, w * 7).map(&f)) + .collect(); + (v.len() >= 2).then_some(v) +} + +/// The previous 8 weekly values (not this week), min and max, when all 8 exist. +fn range8(snaps: &[Snapshot], now: i64, f: impl Fn(&Snapshot) -> u32) -> Option<(u32, u32)> { + let v: Vec = (1..=8) + .filter_map(|w| snap_at(snaps, now, w * 7).map(&f)) + .collect(); + (v.len() == 8).then(|| (*v.iter().min().unwrap(), *v.iter().max().unwrap())) +} + +fn author_kind(login: &str) -> &'static str { + pr_history::author_type(login) +} + +fn day_of(t: i64) -> String { + chrono::DateTime::from_timestamp(t, 0) + .map(|d| d.format("%Y-%m-%d").to_string()) + .unwrap_or_default() +} + +fn gh_search(org: &str, q: &str) -> Value { + let query = format!("is:pr org:{org} {q}"); + json!({"github": format!("https://github.com/pulls?q={}", urlencode(&query))}) +} + +fn urlencode(s: &str) -> String { + s.bytes() + .map(|b| match b { + b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => { + (b as char).to_string() + } + _ => format!("%{b:02X}"), + }) + .collect() +} + +fn list(q: &str) -> Value { + json!({"list": q}) +} + +/// Collects facts while the summary is written, so every number in a +/// sentence is a fact's value. +#[derive(Default)] +pub struct Builder { + pub facts: Vec, +} + +impl Builder { + /// A number in a sentence: records the fact and returns the part. + pub fn num(&mut self, id: &str, scope: &str, value: f64, unit: &str, link: Value) -> Value { + self.fact(id, scope, value, None, 0.0, link.clone()); + json!({"n": value, "unit": unit, "fact": id, "link": link}) + } + + pub fn fact( + &mut self, + id: &str, + scope: &str, + value: f64, + prev: Option, + weight: f64, + link: Value, + ) { + if let Some(f) = self + .facts + .iter_mut() + .find(|f| f.id == id && f.scope == scope) + { + f.weight = f.weight.max(weight); + if prev.is_some() { + f.prev = prev; + } + return; + } + self.facts.push(Fact { + id: id.into(), + scope: scope.into(), + value, + prev, + weight, + link, + }); + } +} + +fn t(s: impl Into) -> Value { + json!({"t": s.into()}) +} + +/// "11h", "3.1d": the words a sentence uses for a duration. +pub fn dur_words(secs: i64) -> String { + if secs < HOUR { + format!("{}m", (secs / 60).max(1)) + } else if secs < DAY { + format!("{}h", (secs + HOUR / 2) / HOUR) + } else { + let d = secs as f64 / DAY as f64; + if d < 10.0 { + format!("{:.1}d", d) + } else { + format!("{}d", d.round() as i64) + } + } +} + +/// The whole overview. +pub fn build(i: &Input) -> Value { + let now = i.now; + let w = i.window_days.max(1) * DAY; + let since = now - w; + let prev_since = now - 2 * w; + let scope_name = i + .repo + .map(str::to_string) + .or(i.org.map(str::to_string)) + .unwrap_or_else(|| "all".into()); + let org_name = i + .repo + .and_then(|r| r.split('/').next()) + .or(i.org) + .unwrap_or("") + .to_string(); + let mut missing: Vec = Vec::new(); + let mut miss = |path: &str, reason: &str, text: &str| { + missing.push(json!({"path": path, "reason": reason, "text": text})); + }; + + let all_hist: Vec<&History> = i.hist.iter().collect(); + let hist: Vec<&History> = i + .hist + .iter() + .filter(|h| in_scope(i.org, i.repo, &h.repo)) + .collect(); + let open: Vec<&Open> = i + .open + .iter() + .filter(|o| in_scope(i.org, i.repo, &o.rec.repo) && o.rec.is_open()) + .collect(); + let lines = scope_lines(&all_hist, i.org, i.repo, now); + + // ── History: how much there is, and whether the backfill is done ── + let first_seen = hist + .iter() + .map(|h| h.created_at) + .chain(open.iter().map(|o| o.rec.created_at)) + .filter(|t| *t > 0) + .min() + .unwrap_or(now); + let backfills: Vec<&Backfill> = i + .backfill + .iter() + .filter(|b| org_name.is_empty() || b.owner.eq_ignore_ascii_case(&org_name)) + .collect(); + let backfill_done = !backfills.is_empty() && backfills.iter().all(|b| b.done); + let history_secs = (now - first_seen).max(0); + let young = !backfill_done || history_secs < MIN_WEEKS_OWN * 7 * DAY; + let bf_repos: BTreeSet = backfills + .iter() + .flat_map(|b| b.repos.keys().cloned()) + .collect(); + let backfill = if backfills.is_empty() { + Value::Null + } else { + let months = pr_history::BACKFILL_MONTHS; + let read = backfills + .iter() + .map(|b| b.months_read.min(months)) + .min() + .unwrap_or(0); + json!({ + "repos": bf_repos.len().max(1), + "repos_read": if backfill_done { bf_repos.len().max(1) } else { bf_repos.len() }, + "months": months, + "months_read": read, + "done": backfill_done, + "days": (months as i64) * 30, + "held": backfills.iter().any(|b| b.paused_until > now), + }) + }; + if !backfill_done { + miss( + "history", + "history", + "Not enough history yet: CoderHelm is still reading merged and closed pull requests back from GitHub.", + ); + } + + // ── Thresholds ── + if lines.cycle.is_none() { + miss( + "thresholds.cycle", + "history", + "Not enough history yet: no merged pull requests in 90 days to take percentiles from.", + ); + } + let thresholds = json!({ + "scope": if i.repo.is_some() && !lines.inherited { "repo" } else { "org" }, + "inherited": lines.inherited, + "min_merged": MIN_MERGED_FOR_OWN, + "min_weeks": MIN_WEEKS_OWN, + "external": young, + "cycle": lines.cycle.map(|c| json!({"p50": c[0], "p85": c[1], "p95": c[2]})), + "first_review": lines.first_review.map(|c| json!({"p50": c[0], "p85": c[1]})), + "bands": [ + {"key": "linearb_elite_cycle", "label": "LinearB elite cycle time (p75)", "secs": 25 * HOUR, "source": "LinearB benchmarks"}, + {"key": "google_review", "label": "Google whole review (median)", "secs": 4 * HOUR, "source": "Sadowski et al."} + ], + "rule": format!("p85 of ready-to-merge over 90 days; a repo with fewer than {MIN_MERGED_FOR_OWN} merges uses the org's; before {MIN_WEEKS_OWN} weeks of history the external bands stand beside it, labeled as external."), + }); + + // ── Strip ── + const STAGES: [(&str, &str); 6] = [ + ("draft", "Draft"), + ("first_review", "Waiting for first review"), + ("in_review", "In review"), + ("blocked", "Blocked"), + ("coderhelm_working", "CoderHelm working"), + ("approved", "Approved, not merged"), + ]; + let week_ago = snap_at(i.snaps, now, 7); + let mut strip = Vec::new(); + for (code, label) in STAGES { + let n = open.iter().filter(|o| stage(o) == code).count() as u32; + let delta = week_ago.map(|s| n as i64 - *s.stages.get(code).unwrap_or(&0) as i64); + if delta.is_none() { + miss(&format!("strip.{code}.delta"), "history", "Not enough history yet: the week-over-week change needs a snapshot from 7 days ago."); + } + strip.push(json!({ + "stage": code, + "label": label, + "count": n, + "delta": delta, + "spark": weekly(i.snaps, now, |s| *s.stages.get(code).unwrap_or(&0)), + "past_p85": open.iter().filter(|o| stage(o) == code && past_p85(o, &lines, now)).count(), + "link": list(&format!("stage={code}")), + })); + } + let open_n = open.iter().filter(|o| !o.rec.draft).count(); + let drafts = open.len() - open_n; + let nobody = open + .iter() + .filter(|o| o.row.next.from.is_empty() || o.row.next.from.iter().all(|f| f == "nobody")) + .count(); + let turns = json!({ + "person": open.iter().filter(|o| o.row.turn == "person" || o.row.turn == "you").count(), + "coderhelm": open.iter().filter(|o| o.row.turn == "coderhelm").count(), + "machines": open.iter().filter(|o| o.row.turn == "machines").count(), + "nobody": nobody, + }); + let decisions: Vec<&&Open> = open + .iter() + .filter(|o| o.row.state == "needs_decision") + .collect(); + let needs_decision = json!({ + "count": decisions.len(), + "oldest_secs": decisions.iter().map(|o| age(o, now)).max(), + "link": list("view=needs_decision"), + }); + + // ── Conditions and the Stale panel ── + let stale: Vec<(&&Open, &str)> = open + .iter() + .filter_map(|o| is_stale(o, &lines, now).map(|w| (o, w))) + .collect(); + let abandoned: Vec<&&Open> = open + .iter() + .filter(|o| is_abandoned(o, &lines, now)) + .collect(); + let zombie = lines + .cycle + .map(|_| open.iter().filter(|o| is_zombie(o, &lines, now)).count()); + if zombie.is_none() { + miss( + "conditions.zombie", + "history", + "Not enough history yet: a zombie is open past the p95 cycle time.", + ); + miss( + "stale.zombie", + "history", + "Not enough history yet: a zombie is open past the p95 cycle time.", + ); + } + let overlaps: Vec = hist + .iter() + .filter(|h| h.merged && h.drift_overlap > 0) + .map(|h| h.drift_overlap as i64) + .collect(); + let drift_p85 = (overlaps.len() >= MIN_EVENTS) + .then(|| pct(&overlaps, 85)) + .flatten(); + let mut drifting: Vec<&&Open> = match drift_p85 { + Some(p) => open + .iter() + .filter(|o| (o.rec.drift_overlap as i64) >= p && o.rec.drift_overlap > 0) + .collect(), + None => Vec::new(), + }; + drifting.sort_by_key(|o| std::cmp::Reverse(o.rec.drift_overlap)); + if drift_p85.is_none() { + miss("conditions.high_drift", "history", "Not enough history yet: drift is judged against the p85 at merge, over 10 or more merges."); + miss("stale.drift", "history", "Not enough history yet: drift is judged against the p85 at merge, over 10 or more merges."); + } + miss( + "conditions.blocked_by_main", + "not_recorded", + "Not recorded yet: CoderHelm doesn't keep the default branch's check history yet.", + ); + let stale_prev = week_ago.map(|_| Value::Null); + let _ = stale_prev; + let on_author = stale.iter().filter(|(_, w)| *w == "author").count(); + let conditions = json!({ + "stale": {"count": stale.len(), "delta": Value::Null, "author": on_author, "reviewer": stale.len() - on_author}, + "abandoned": abandoned.len(), + "zombie": zombie, + "high_drift": drift_p85.map(|_| drifting.len()), + "blocked_by_main": Value::Null, + }); + let drafts_ages: Vec = open + .iter() + .filter(|o| o.rec.draft) + .map(|o| age(o, now)) + .collect(); + let past_usual = open.iter().filter(|o| past_p85(o, &lines, now)).count(); + let stale_panel = json!({ + "stale": stale.len(), + "past_usual": lines.cycle.map(|_| past_usual), + "on_author": on_author, + "on_reviewer": stale.len() - on_author, + "abandoned": {"count": abandoned.len(), "oldest_secs": abandoned.iter().map(|o| age(o, now)).max()}, + "zombie": zombie, + "drift": drift_p85.map(|_| drifting.iter().take(3).map(|o| json!({"key": o.row.key, "overlapping": o.rec.drift_overlap})).collect::>()), + "draft_p85_secs": pct(&drafts_ages, 85), + "archive_candidates": open.iter().filter(|o| !o.rec.draft && idle_of(o, now).is_some_and(|(_, s)| s >= ARCHIVE_SECS)).count(), + }); + + // ── Aging dots ── + let mut by_age: Vec<&&Open> = open.iter().collect(); + by_age.sort_by_key(|o| std::cmp::Reverse(age(o, now))); + let dots: Vec = by_age + .iter() + .take(MAX_DOTS) + .map(|o| { + let a = age(o, now); + json!({ + "key": o.row.key, + "repo": o.rec.repo, + "number": o.rec.number, + "title": o.rec.title, + "stage": stage(o), + "state": o.row.state, + "state_label": o.row.state_label, + "age_secs": a, + "coderhelm": o.rec.author_is_coderhelm(), + "author_type": author_kind(&o.rec.author), + "band": band(a, &lines), + "idle": is_stale(o, &lines, now).is_some(), + "main_blocked": false, + }) + }) + .collect(); + + // ── Windows over history ── + let merged_in = |h: &&History, a: i64, b: i64| h.merged && h.merged_at > a && h.merged_at <= b; + let merged_w: Vec<&History> = hist + .iter() + .copied() + .filter(|h| merged_in(h, since, now)) + .collect(); + let merged_prev: Vec<&History> = hist + .iter() + .copied() + .filter(|h| merged_in(h, prev_since, since)) + .collect(); + let human_share = |v: &[&History]| { + share( + v.iter().filter(|h| h.coverage == "human_approved").count(), + v.len(), + ) + }; + + // ── Repos ── + let mut repo_names: BTreeSet = BTreeSet::new(); + for o in &open { + repo_names.insert(o.rec.repo.clone()); + } + for h in &hist { + if h.closed_at > now - 56 * DAY { + repo_names.insert(h.repo.clone()); + } + } + for r in &bf_repos { + if in_scope(i.org, i.repo, r) { + repo_names.insert(r.clone()); + } + } + let total_open = open.len().max(1); + let mut repos: Vec = Vec::new(); + let mut org_health = ("quiet", 0u8); + let mut obligation_anywhere = false; + let rank = |h: &str| match h { + "slipping" => 3u8, + "at_risk" => 2, + "healthy" => 1, + _ => 0, + }; + for name in repo_names.iter().take(MAX_REPOS) { + let ro: Vec<&&Open> = open + .iter() + .filter(|o| o.rec.repo.eq_ignore_ascii_case(name)) + .collect(); + let rh: Vec<&History> = all_hist + .iter() + .copied() + .filter(|h| h.repo.eq_ignore_ascii_case(name)) + .collect(); + let rl = scope_lines(&all_hist, None, Some(name), now); + let mut stages = BTreeMap::new(); + for o in &ro { + *stages.entry(stage(o).to_string()).or_insert(0u32) += 1; + } + let past = ro.iter().filter(|o| past_p85(o, &rl, now)).count() as u32; + let snaps = i.repo_snaps.get(name).map(Vec::as_slice).unwrap_or(&[]); + let past_delta = snap_at(snaps, now, 7).map(|s| past as i64 - s.past_p85 as i64); + let first: Vec = rh + .iter() + .filter(|h| h.closed_at > now - 56 * DAY) + .filter_map(|h| h.first_review_secs()) + .collect(); + let arrivals = ro + .iter() + .filter(|o| o.rec.ready_or_created() > since) + .count() + + rh.iter().filter(|h| h.ready_at > since).count(); + let rm: Vec<&History> = rh + .iter() + .copied() + .filter(|h| merged_in(h, since, now)) + .collect(); + let rm_prev: Vec<&History> = rh + .iter() + .copied() + .filter(|h| merged_in(h, prev_since, since)) + .collect(); + let reverts = rh + .iter() + .filter(|h| { + h.reverted_by + .as_ref() + .is_some_and(|(_, _, t)| *t > now - 14 * DAY) + }) + .count(); + let reworked = rm.iter().filter(|h| h.reworked()).count(); + let ci_n: Vec<&History> = rh + .iter() + .copied() + .filter(|h| h.closed_at > since && !h.check_log.is_empty()) + .collect(); + let ci_first = share( + ci_n.iter().filter(|h| first_try_green(h)).count(), + ci_n.len(), + ); + let large = share( + rm.iter() + .filter(|h| h.additions + h.deletions > LARGE_LINES) + .count(), + rm.len(), + ); + let sec: Vec<(&str, i64)> = ro + .iter() + .filter(|o| o.rec.category == "security") + .filter(|o| age(o, now) > i.sla.days(&o.rec.severity) * DAY) + .map(|o| (o.rec.severity.as_str(), age(o, now))) + .collect(); + let worst = ["critical", "high", "medium", "low"].into_iter().find(|s| { + sec.iter().any(|(x, _)| { + x == s || (*s == "low" && !["critical", "high", "medium"].contains(x)) + }) + }); + let bypass_unreviewed = rm + .iter() + .filter(|h| h.bypass.is_some() && !reviewed_after(h)) + .count(); + let quiet = ro.is_empty() && arrivals == 0 && rm.is_empty(); + let past_range = range8(snaps, now, |s| s.past_p85); + let merges_range = range8(snaps, now, |s| s.merges); + let obligation = sec.iter().any(|(s, _)| *s == "critical") || bypass_unreviewed > 0; + let out_of_range = past_range.is_some_and(|(_, hi)| past > hi) + || merges_range.is_some_and(|(lo, _)| (rm.len() as u32) < lo); + let health = if quiet { + "quiet" + } else if obligation { + "slipping" + } else if out_of_range { + "at_risk" + } else { + "healthy" + }; + let mut flags: Vec = Vec::new(); + if let Some(wst) = worst { + flags.push(format!("{} {wst} past SLA", sec.len())); + } + if bypass_unreviewed > 0 { + flags.push(format!("{bypass_unreviewed} bypass, no review after")); + } + if reverts > 0 { + flags.push(format!( + "{reverts} revert{}", + if reverts == 1 { "" } else { "s" } + )); + } + if let Some(p) = past_range.filter(|(_, hi)| past > *hi) { + flags.push(format!("{past} past usual (8 wk {} to {})", p.0, p.1)); + } + let short = name.split('/').nth(1).unwrap_or(name); + let why = if quiet { + format!("No pull request activity in {short} in the window.") + } else if flags.is_empty() { + if past_range.is_none() { + format!("Nothing breached; {short} has no 8-week range yet to judge against.") + } else { + format!("Nothing breached, and every number is inside {short}'s 8-week range.") + } + } else { + flags.join("; ") + }; + if obligation { + obligation_anywhere = true; + } + if ro.len() * 10 >= total_open && rank(health) > org_health.1 { + org_health = (health, rank(health)); + } + repos.push(json!({ + "repo": name, + "open": ro.len(), + "stages": stages, + "past_p85": past, + "past_p85_delta": past_delta, + "first_review": match (pct(&first, 50), pct(&first, 85)) { (Some(a), Some(b)) => json!({"p50": a, "p85": b}), _ => Value::Null }, + "arrivals": arrivals, + "merges": rm.len(), + "spark": weekly(snaps, now, |s| s.open), + "oldest_secs": ro.iter().map(|o| age(o, now)).max(), + "reworked": reworked, + "stale": ro.iter().filter(|o| is_stale(o, &rl, now).is_some()).count(), + "abandoned": ro.iter().filter(|o| is_abandoned(o, &rl, now)).count(), + "human_reviewed": human_share(&rm).map(round3), + "human_reviewed_delta": match (human_share(&rm), human_share(&rm_prev)) { (Some(a), Some(b)) => json!(round3(a - b)), _ => Value::Null }, + "ci_first_try": ci_first.map(round3), + "main_red_secs": Value::Null, + "reverts": reverts, + "large_share": large.map(round3), + "security_past_sla": worst.map(|w| json!({"count": sec.len(), "worst": w})), + "bypasses_unreviewed": bypass_unreviewed, + "flags": flags, + "health": health, + "why": why, + "inherited": rl.inherited, + "link": {"overview": format!("repo={name}")}, + })); + } + let hrank = |v: &Value| rank(v["health"].as_str().unwrap_or("")); + repos.sort_by(|a, b| { + hrank(b) + .cmp(&hrank(a)) + .then(b["past_p85"].as_u64().cmp(&a["past_p85"].as_u64())) + .then(b["oldest_secs"].as_i64().cmp(&a["oldest_secs"].as_i64())) + }); + if obligation_anywhere { + org_health = ("slipping", 3); + } + miss( + "repos.main_red_secs", + "not_recorded", + "Not recorded yet: CoderHelm doesn't keep the default branch's check history yet.", + ); + + // ── Review health ── + let human_reviews_in = |a: i64, b: i64| -> Vec<(String, i64)> { + let mut v = Vec::new(); + for (log, _repo) in open + .iter() + .map(|o| (&o.rec.review_log, &o.rec.repo)) + .chain(hist.iter().map(|h| (&h.review_log, &h.repo))) + { + for r in log.iter().filter(|r| r.human && r.at > a && r.at <= b) { + v.push((r.who.to_ascii_lowercase(), r.at)); + } + } + v + }; + let top20 = |rev: &[(String, i64)]| -> Option<(f64, usize)> { + let mut per: BTreeMap<&str, usize> = BTreeMap::new(); + for (who, _) in rev { + *per.entry(who.as_str()).or_default() += 1; + } + if rev.len() < MIN_EVENTS || per.len() < 5 { + return None; + } + let mut counts: Vec = per.values().copied().collect(); + counts.sort_unstable_by(|a, b| b.cmp(a)); + let k = (counts.len() as f64 * 0.2).ceil() as usize; + Some(( + counts.iter().take(k).sum::() as f64 / rev.len() as f64, + per.len(), + )) + }; + let rev30 = human_reviews_in(now - 30 * DAY, now); + let rev30_prev = human_reviews_in(now - 60 * DAY, now - 30 * DAY); + let conc = top20(&rev30); + let conc_prev = top20(&rev30_prev); + if conc.is_none() { + miss("review.concentration", "history", "Not enough history yet: concentration needs 10 or more reviews by people, from 5 or more reviewers, in 30 days."); + } + miss("review.concentration.where", "not_recorded", "Not recorded yet: CoderHelm doesn't keep which paths or CODEOWNERS entries a review covered."); + let requests_w = open + .iter() + .flat_map(|o| o.rec.request_log.iter()) + .chain(hist.iter().flat_map(|h| h.request_log.iter())) + .filter(|r| r.at > since) + .count() as i64; + let done_w = human_reviews_in(since, now).len() as i64; + let flow = weekly(i.snaps, now, |s| s.review_requests).zip(weekly(i.snaps, now, |s| s.reviews_done)).map(|(a, b)| { + a.iter() + .zip(b.iter()) + .enumerate() + .map(|(k, (r, d))| json!({"week": day_of(now - (a.len() as i64 - 1 - k as i64) * 7 * DAY), "requests": r, "done": d})) + .collect::>() + }); + if flow.is_none() { + miss( + "review.flow", + "history", + "Not enough history yet: the weekly flow needs 2 weeks of nightly snapshots.", + ); + } + let mut cov = BTreeMap::from([ + ("human_approved", 0usize), + ("ai_only", 0), + ("non_owner_on_owned", 0), + ("bypass_or_exempt", 0), + ("no_review", 0), + ]); + for h in &merged_w { + *cov.entry(match h.coverage.as_str() { + "human_approved" => "human_approved", + "ai_only" => "ai_only", + "non_owner_on_owned" => "non_owner_on_owned", + "bypass_or_exempt" => "bypass_or_exempt", + _ => "no_review", + }) + .or_default() += 1; + } + let any_first: Vec = hist + .iter() + .filter(|h| h.closed_at > now - 56 * DAY && h.ready_at > 0) + .filter_map(|h| { + h.review_log + .iter() + .filter(|r| r.who != h.author) + .map(|r| r.at) + .min() + .map(|t| (t - h.ready_at).max(0)) + }) + .collect(); + let size_bucket = |n: u32| { + if n < 50 { + "small" + } else if n <= LARGE_LINES { + "medium" + } else { + "large" + } + }; + let mut stamp: BTreeMap<&str, (usize, usize)> = BTreeMap::new(); + let mut waits: BTreeMap<&str, Vec> = BTreeMap::new(); + for h in hist.iter().filter(|h| h.closed_at > now - 90 * DAY) { + for r in h + .review_log + .iter() + .filter(|r| r.human && r.state == "APPROVED") + { + if let Some(req) = h + .request_log + .iter() + .filter(|q| q.at <= r.at) + .map(|q| q.at) + .max() + { + waits + .entry(size_bucket(h.additions + h.deletions)) + .or_default() + .push(r.at - req); + } + } + } + for h in &merged_w { + let b = size_bucket(h.additions + h.deletions); + let p10 = waits + .get(b) + .and_then(|v| (v.len() >= MIN_EVENTS).then(|| pct(v, 10)).flatten()); + for r in h + .review_log + .iter() + .filter(|r| r.human && r.state == "APPROVED") + { + let e = stamp.entry(b).or_default(); + e.1 += 1; + let req = h + .request_log + .iter() + .filter(|q| q.at <= r.at) + .map(|q| q.at) + .max(); + if let (Some(p), Some(q)) = (p10, req) { + if !r.has_body && r.at - q < p { + e.0 += 1; + } + } + } + } + let stamp_of = |b: &str| stamp.get(b).and_then(|(n, d)| share(*n, *d)).map(round3); + let queue_open: Vec = open + .iter() + .filter(|o| stage(o) == "first_review") + .map(|o| age(o, now)) + .collect(); + let sizes = |v: &[&History]| -> Vec { + v.iter() + .map(|h| (h.additions + h.deletions) as i64) + .collect() + }; + let review = json!({ + "flow": flow, + "gap": requests_w - done_w, + "concentration": { + "top_share": conc.map(|c| round3(c.0)), + "reviewers": conc.map(|c| c.1).unwrap_or(0), + "delta": conc.zip(conc_prev).map(|(a, b)| round3(a.0 - b.0)), + "where": Value::Null, + }, + "depth": { + "merged_without_review": share(cov["no_review"], merged_w.len()).map(round3), + "rubber_stamp": Value::Null, + "median_size": median(&sizes(&merged_w)), + "median_size_delta": median(&sizes(&merged_w)).zip(median(&sizes(&merged_prev))).map(|(a, b)| a - b), + }, + "coverage": (!merged_w.is_empty()).then(|| json!({ + "merged": merged_w.len(), + "human": cov["human_approved"], + "ai_only": cov["ai_only"], + "non_owner": cov["non_owner_on_owned"], + "bypass": cov["bypass_or_exempt"], + "none": cov["no_review"], + })), + "first_review_human": lines.first_review.map(|c| json!({"p50": c[0], "p85": c[1]})), + "first_review_any": pct(&any_first, 50).zip(pct(&any_first, 85)).map(|(a, b)| json!({"p50": a, "p85": b})), + "rubber_stamp_by_size": if stamp.is_empty() { Value::Null } else { json!({"small": stamp_of("small"), "medium": stamp_of("medium"), "large": stamp_of("large")}) }, + "queue": { + "under_4h": queue_open.iter().filter(|a| **a < 4 * HOUR).count(), + "h4_24": queue_open.iter().filter(|a| **a >= 4 * HOUR && **a < DAY).count(), + "d1_3": queue_open.iter().filter(|a| **a >= DAY && **a < 3 * DAY).count(), + "over_3d": queue_open.iter().filter(|a| **a >= 3 * DAY).count(), + }, + "single_reviewer_paths": Value::Null, + "funnel": Value::Null, + }); + if merged_w.is_empty() { + miss( + "review.coverage", + "history", + "Not enough history yet: no merges in the window.", + ); + } + if stamp.is_empty() { + miss( + "review.rubber_stamp_by_size", + "history", + "Not enough history yet: fewer than 10 qualifying approvals.", + ); + } + miss( + "review.funnel", + "not_recorded", + "Not recorded yet: CoderHelm's findings aren't joined to pull requests yet.", + ); + + // ── Failures ── + let ci_hist: Vec<&History> = hist + .iter() + .copied() + .filter(|h| h.closed_at > now - 56 * DAY && !h.check_log.is_empty()) + .collect(); + let (red, green) = hist + .iter() + .filter(|h| h.closed_at > now - 56 * DAY) + .flat_map(|h| h.check_log.iter()) + .chain( + open.iter() + .flat_map(|o| o.rec.check_log.iter()) + .filter(|c| c.at > now - 56 * DAY), + ) + .fold((0usize, 0usize), |(r, g), c| match c.rollup.as_str() { + "red" => (r + 1, g), + "green" => (r, g + 1), + _ => (r, g), + }); + let mut flaky: BTreeMap<(String, String), (usize, i64)> = BTreeMap::new(); + for h in hist.iter().filter(|h| h.closed_at > now - 30 * DAY) { + for c in &h.flaky_checks { + let e = flaky + .entry((c.clone(), h.repo.clone())) + .or_insert((0, h.closed_at)); + e.0 += 1; + e.1 = e.1.min(h.closed_at); + } + } + for o in &open { + for c in crate::pr_record::flaky_checks(&o.rec.check_attempts) { + let e = flaky.entry((c, o.rec.repo.clone())).or_insert((0, now)); + e.0 += 1; + } + } + let flaky_runs = ci_hist.len() + open.len(); + let flaky_value = (flaky_runs >= MIN_EVENTS).then(|| { + let mut top: Vec<_> = flaky.iter().filter(|(_, (n, _))| *n >= 2).collect(); + top.sort_by_key(|(_, (n, _))| std::cmp::Reverse(*n)); + json!({ + "count": top.len(), + "new": top.iter().filter(|(_, (_, first))| *first > since).count(), + "top": top.iter().take(3).map(|((c, r), (n, _))| json!({"check": c, "repo": r, "retries": n})).collect::>(), + }) + }); + if flaky_value.is_none() { + miss( + "failures.flaky", + "history", + "Not enough history yet: a flaky check needs 10 or more runs.", + ); + } + let reverted_14: Vec<&History> = hist + .iter() + .copied() + .filter(|h| { + h.reverted_by + .as_ref() + .is_some_and(|(_, _, t)| *t > now - 14 * DAY) + }) + .collect(); + let merged_30: Vec<&History> = hist + .iter() + .copied() + .filter(|h| merged_in(h, now - 30 * DAY, now)) + .collect(); + let ch_merged = merged_w + .iter() + .filter(|h| h.author_type == "coderhelm") + .count(); + let failures = json!({ + "ci_first_try": share(ci_hist.iter().filter(|h| first_try_green(h)).count(), ci_hist.len()).map(|s| json!({"share": round3(s), "lo": Value::Null, "hi": Value::Null, "n": ci_hist.len()})), + "ci_fail_rate": share(red, red + green).map(|s| json!({"share": round3(s), "n": red + green})), + "flaky": flaky_value, + "main_red": Value::Null, + "reverts": { + "count": reverted_14.len(), + "coderhelm": reverted_14.iter().filter(|h| h.author_type == "coderhelm").count(), + "coderhelm_merged": ch_merged, + "people": reverted_14.iter().filter(|h| h.author_type != "coderhelm").count(), + "people_merged": merged_w.len() - ch_merged, + }, + "proxy": share(merged_30.iter().filter(|h| h.reworked()).count(), merged_30.len()).map(round3), + "suspects": hist.iter().filter(|h| h.merged_at > now - 30 * DAY).flat_map(|h| h.follow_ups.iter().map(move |f| json!({"kind": "hotfix", "target": format!("{}#{}", h.repo, h.number), "by": format!("{}#{}", f.repo, f.number), "reason": f.reason}))).take(3).collect::>(), + "queue_p95_secs": Value::Null, + }); + miss( + "failures.main_red", + "not_recorded", + "Not recorded yet: CoderHelm doesn't keep the default branch's check history yet.", + ); + miss( + "failures.queue_p95_secs", + "not_recorded", + "Not recorded yet: runner queue times aren't kept.", + ); + if ci_hist.len() < MIN_EVENTS { + miss( + "failures.ci_first_try", + "history", + "Not enough history yet: fewer than 10 closed PRs with checks in 8 weeks.", + ); + } + + // ── Security and policy ── + let sec_open: Vec<&&Open> = open + .iter() + .filter(|o| o.rec.category == "security") + .collect(); + let mut sev = BTreeMap::from([("critical", 0usize), ("high", 0), ("medium", 0), ("low", 0)]); + for o in &sec_open { + let k = match o.rec.severity.as_str() { + "critical" | "kev" => "critical", + "high" => "high", + "medium" | "moderate" => "medium", + _ => "low", + }; + *sev.entry(k).or_default() += 1; + } + let mut past_sla: Vec<(&&Open, i64)> = sec_open + .iter() + .map(|o| (*o, age(o, now))) + .filter(|(o, a)| *a > i.sla.days(&o.rec.severity) * DAY) + .collect(); + past_sla.sort_by_key(|(o, a)| (sev_rank(&o.rec.severity), std::cmp::Reverse(*a))); + let bypass_w: Vec<&History> = merged_w + .iter() + .copied() + .filter(|h| h.bypass.is_some()) + .collect(); + let no_human: Vec<&History> = merged_w + .iter() + .copied() + .filter(|h| { + !h.review_log + .iter() + .any(|r| r.human && r.state == "APPROVED") + }) + .collect(); + let dep_group = |g: &str| -> Value { + let resolved: Vec<&History> = hist + .iter() + .copied() + .filter(|h| { + h.closed_at > now - 30 * DAY + && (h.category == "dependency" || h.category == "security") + }) + .filter(|h| match g { + "Dependabot" => h.author.to_ascii_lowercase().starts_with("dependabot"), + "Renovate" => h.author.to_ascii_lowercase().starts_with("renovate"), + _ => is_coderhelm(&h.author), + }) + .collect(); + let merged = resolved.iter().filter(|h| h.merged).count(); + let superseded = resolved + .iter() + .filter(|h| !h.merged && is_bot(&h.merged_by.clone())) + .count(); + json!({"group": g, "merge_rate": share(merged, resolved.len()).map(round3), "superseded": share(superseded, resolved.len()).map(round3)}) + }; + let security = json!({ + "sla_days": {"critical": i.sla.critical, "high": i.sla.high, "medium": i.sla.medium, "low": i.sla.low}, + "open": sev, + "past_sla": past_sla.iter().take(10).map(|(o, a)| json!({"key": o.row.key, "severity": o.rec.severity, "age_secs": a})).collect::>(), + "bypasses": {"count": bypass_w.len(), "reviewed_after": bypass_w.iter().filter(|h| reviewed_after(h)).count()}, + "exempt_by_coderhelm": merged_w.iter().filter(|h| h.merged_by_type == "coderhelm" && h.bypass.is_some()).count(), + "no_human_approval": { + "total": no_human.len(), + "person": no_human.iter().filter(|h| h.author_type == "person").count(), + "coderhelm": no_human.iter().filter(|h| h.author_type == "coderhelm").count(), + "bot": no_human.iter().filter(|h| h.author_type == "bot").count(), + }, + "sensitive_without_owner": Value::Null, + "dependency": [dep_group("Dependabot"), dep_group("Renovate"), dep_group("CoderHelm")], + }); + miss( + "security.sensitive_without_owner", + "not_recorded", + "Not recorded yet: the org's sensitive-path list isn't set.", + ); + miss("security.alerts", "not_recorded", "Not recorded yet: open security alerts with no pull request aren't read; the counts are security-fix pull requests."); + + // ── Events ── + let mut events: Vec<(u8, i64, Value)> = Vec::new(); + for h in &reverted_14 { + if let Some((by_repo, by_n, at)) = &h.reverted_by { + if *at > since { + events.push((2, *at, json!({"at": rfc3339(*at), "repo": h.repo, "kind": "revert", "text": format!("Revert merged: {by_repo}#{by_n} reverted #{} ({}'s PR), {} after it merged", h.number, match h.author_type.as_str() { "coderhelm" => "CoderHelm", "bot" => "a bot", _ => "a person" }, dur_words((at - h.merged_at).max(0))), "link": list(&format!("pr={}#{}", h.repo, h.number)), "severity": 2}))); + } + } + } + for h in &bypass_w { + events.push((3, h.merged_at, json!({"at": rfc3339(h.merged_at), "repo": h.repo, "kind": "bypass", "text": format!("Bypass merge #{} ({}){}", h.number, h.bypass.clone().unwrap_or_default(), if reviewed_after(h) { ", reviewed after" } else { ", no review after" }), "link": list(&format!("pr={}#{}", h.repo, h.number)), "severity": 3}))); + } + for (o, a) in &past_sla { + let crossed = now - a + i.sla.days(&o.rec.severity) * DAY; + if crossed > since { + events.push((3, crossed, json!({"at": rfc3339(crossed), "repo": o.rec.repo, "kind": "sla", "text": format!("{} security fix #{} passed its {}-day SLA", o.rec.severity, o.rec.number, i.sla.days(&o.rec.severity)), "link": list(&format!("pr={}", o.row.key)), "severity": 3}))); + } + } + for ((c, r), (n, first)) in &flaky { + if *first > since && *n >= 2 { + events.push((1, *first, json!({"at": rfc3339(*first), "repo": r, "kind": "flaky", "text": format!("New flaky check {c}: failed then passed on the same commit {n} times"), "link": list(&format!("repo={r}&state=checks_failing")), "severity": 1}))); + } + } + for h in hist + .iter() + .filter(|h| h.closed_at > since && matches!(h.run_outcome.as_str(), "gave_up" | "stopped")) + { + events.push((2, h.closed_at, json!({"at": rfc3339(h.closed_at), "repo": h.repo, "kind": "agent_stopped", "text": format!("CoderHelm {} on #{}{}", if h.run_outcome == "stopped" { "was stopped" } else { "gave up" }, h.number, if h.stop_reason.is_empty() { String::new() } else { format!(": {}", h.stop_reason) }), "link": list(&format!("pr={}#{}", h.repo, h.number)), "severity": 2}))); + } + events.sort_by(|a, b| b.0.cmp(&a.0).then(b.1.cmp(&a.1))); + let events: Vec = events.into_iter().take(20).map(|e| e.2).collect(); + + // ── CoderHelm's slice ── + let ch_open: Vec<&&Open> = open + .iter() + .filter(|o| o.rec.author_is_coderhelm()) + .collect(); + let ch_hist_w: Vec<&History> = hist + .iter() + .copied() + .filter(|h| h.author_type == "coderhelm" && h.closed_at > since) + .collect(); + let ch_opened = ch_open.iter().filter(|o| o.rec.created_at > since).count() + + hist + .iter() + .filter(|h| h.author_type == "coderhelm" && h.created_at > since) + .count(); + let ch_merged_n = ch_hist_w.iter().filter(|h| h.merged).count(); + let ch_closed = ch_hist_w.len() - ch_merged_n; + let ch_cycles: Vec = ch_hist_w.iter().filter_map(|h| h.cycle_secs()).collect(); + let (wait, open_time) = ch_open.iter().fold((0i64, 0i64), |(w, t), o| { + let start = o.rec.ready_or_created(); + ( + w + pr_history::waiting_on_person(&o.rec.spans, start, now), + t + (now - start).max(0), + ) + }); + let fixer: Vec<&History> = hist + .iter() + .copied() + .filter(|h| h.coderhelm_role == "fixer" && h.closed_at > since) + .collect(); + let fixer_open = open + .iter() + .filter(|o| { + !o.rec.author_is_coderhelm() + && (!o.rec.coderhelm.run_id.is_empty() || !o.rec.coderhelm.run_ids.is_empty()) + }) + .count(); + let reviewed: Vec<&History> = hist + .iter() + .copied() + .filter(|h| h.first_coderhelm_review_at > since) + .collect(); + let looks: Vec = reviewed + .iter() + .map(|h| (h.first_coderhelm_review_at - h.ready_at).max(0)) + .collect(); + let outcomes: Vec<&History> = hist + .iter() + .copied() + .filter(|h| h.closed_at > since && !h.run_outcome.is_empty()) + .collect(); + let runs = (!outcomes.is_empty()).then(|| { + let c = |k: &str| outcomes.iter().filter(|h| h.run_outcome == k).count(); + let mut reasons: BTreeMap<&str, usize> = BTreeMap::new(); + for h in outcomes.iter().filter(|h| !h.stop_reason.is_empty()) { + *reasons.entry(h.stop_reason.as_str()).or_default() += 1; + } + json!({ + "first_try": c("first_try"), "after_fixes": c("after_fixes"), "rerun_only": c("rerun_only"), + "gave_up": c("gave_up"), "blocked": c("blocked"), "stopped": c("stopped"), + "reasons": reasons.iter().map(|(r, n)| json!({"reason": r, "count": n})).collect::>(), + }) + }); + if runs.is_none() { + miss( + "coderhelm.runs", + "not_recorded", + "Not recorded yet: run end states aren't joined to pull requests yet.", + ); + } + miss( + "coderhelm.reviewer.findings", + "not_recorded", + "Not recorded yet: CoderHelm's findings aren't joined to pull requests yet.", + ); + miss( + "coderhelm.reviewer.verified_rate", + "not_recorded", + "Not recorded yet: CoderHelm's findings aren't joined to pull requests yet.", + ); + miss( + "coderhelm.exceptions.cost_per_merged", + "not_recorded", + "Not recorded yet: run cost isn't joined to pull requests yet.", + ); + let ch_merged_w: Vec<&History> = merged_w + .iter() + .copied() + .filter(|h| h.author_type == "coderhelm") + .collect(); + let people_merged_w: Vec<&History> = merged_w + .iter() + .copied() + .filter(|h| h.author_type != "coderhelm") + .collect(); + let ch_decisions: Vec<&&Open> = ch_open + .iter() + .copied() + .filter(|o| o.row.state == "needs_decision") + .collect(); + let coderhelm = json!({ + "author": { + "opened": ch_opened, + "merged": ch_merged_n, + "closed_unmerged": ch_closed, + "open": ch_open.len(), + "merge_rate": share(ch_merged_n, ch_hist_w.len()).map(round3), + "p50_merge_secs": median(&ch_cycles), + "waiting_on_people": (open_time > 0).then(|| round3(wait as f64 / open_time as f64)), + "rule": "Merged / (merged + closed unmerged) for PRs resolved in the window; open PRs excluded; shown on 10 or more.", + }, + "fixer": {"fixed": fixer.len() + fixer_open, "merged": fixer.iter().filter(|h| h.merged).count(), "closed_unmerged": fixer.iter().filter(|h| !h.merged).count(), "open": fixer_open}, + "reviewer": {"reviewed": reviewed.len(), "findings": Value::Null, "verified_rate": Value::Null, "p50_first_look_secs": median(&looks)}, + "runs": runs, + "exceptions": { + "needs_decision": ch_decisions.len(), + "oldest_secs": ch_decisions.iter().map(|o| age(o, now)).max(), + "reworked": { + "coderhelm": ch_merged_w.iter().filter(|h| h.reworked()).count(), + "people": people_merged_w.iter().filter(|h| h.reworked()).count(), + "coderhelm_merged": ch_merged_w.len(), + "people_merged": people_merged_w.len(), + }, + "merges": { + "on_approval": ch_merged_w.iter().filter(|h| h.review_log.iter().any(|r| r.human && r.state == "APPROVED")).count(), + "own_authority": ch_merged_w.iter().filter(|h| h.merged_by_type == "coderhelm" && !h.review_log.iter().any(|r| r.human && r.state == "APPROVED")).count(), + "exempt": ch_merged_w.iter().filter(|h| h.merged_by_type == "coderhelm" && h.bypass.is_some()).count(), + }, + "cost_per_merged": Value::Null, + } + }); + + // ── Summary ── + let ctx = SummaryCtx { + org: &org_name, + scope: &scope_name, + repos_n: repos.len(), + open: &open, + open_n, + stale: &stale, + past_usual, + lines: &lines, + merged_w: &merged_w, + merged_prev: &merged_prev, + merges_range: range8(i.snaps, now, |s| s.merges), + merges_median: { + let v: Vec = (1..=8) + .filter_map(|w| snap_at(i.snaps, now, w * 7).map(|s| s.merges as i64)) + .collect(); + (v.len() == 8).then(|| median(&v)).flatten() + }, + past_range: range8(i.snaps, now, |s| s.past_p85), + past_sla: &past_sla, + bypass_w: &bypass_w, + reverted_14: &reverted_14, + merged_30: &merged_30, + strip: &strip, + decisions: &ch_decisions, + ch_opened, + ch_merged: ch_merged_n, + ch_reverted: ch_merged_w + .iter() + .filter(|h| h.reverted_by.is_some()) + .count(), + ch_outcomes: &outcomes, + ch_reviewed: reviewed.len(), + human_now: human_share(&merged_w), + human_prev: human_share(&merged_prev), + org_health: org_health.0, + sla: i.sla, + since, + now, + window_days: i.window_days, + }; + let mut b = Builder::default(); + let summary = summary(&ctx, &mut b); + let facts: Vec = b + .facts + .iter() + .map(|f| json!({"id": f.id, "kind": "count", "scope": f.scope, "value": f.value, "prev": f.prev, "delta": f.prev.map(|p| f.value - p), "unusual": false, "weight": f.weight, "link": f.link})) + .collect(); + + json!({ + "scope": {"org": if org_name.is_empty() { Value::Null } else { json!(org_name) }, "repo": i.repo, "window": format!("{}d", i.window_days), "vs": "8w", "repos": repos.len(), "repos_read": repos.len()}, + "generated_at": rfc3339(now), + "history": { + "days": history_secs / DAY, + "weeks": history_secs / (7 * DAY), + "young": young, + "merged_90d": hist.iter().filter(|h| h.merged && h.merged_at > now - 90 * DAY).count(), + "since": rfc3339(first_seen), + "backfill": backfill, + }, + "thresholds": thresholds, + "open": open_n, + "drafts": drafts, + "strip": strip, + "turns": turns, + "conditions": conditions, + "needs_decision": needs_decision, + "aging": {"dots": dots, "total": open.len(), "shown": open.len().min(MAX_DOTS)}, + "repos": repos, + "rollup": {"health": org_health.0, "repo": Value::Null, "rule": ROLLUP_RULE}, + "review": review, + "stale": stale_panel, + "failures": failures, + "security": security, + "events": events, + "coderhelm": coderhelm, + "facts": facts, + "summary": summary, + "missing": missing, + }) +} + +/// The verdict's printed roll-up rule. +pub const ROLLUP_RULE: &str = "Slipping: any obligation breached (a critical security fix past its SLA, an unreviewed bypass) or main red now. At risk: a headline number outside its 8-week range in the bad direction. Quiet: merges under a quarter of the 8-week median and nothing past usual. Healthy otherwise. The org takes the worst state of any repo holding 10% or more of open PRs, plus any obligation breach anywhere."; + +const METHOD: &str = "Facts are computed from CoderHelm's records of every pull request in the installed repos, people's, CoderHelm's and other bots'. Each is ranked by its effect on the org total; a change is mentioned only when it is at least 2 and 10% of the week before, a wait only past 24 hours, and no rate on fewer than 10 events. Each line is a fixed template over one fact; no number is written that isn't in the facts."; + +fn sev_rank(s: &str) -> u8 { + match s { + "critical" | "kev" => 0, + "high" => 1, + "medium" | "moderate" => 2, + _ => 3, + } +} + +/// The first required-check rollup on the pull request turned green, not red. +fn first_try_green(h: &History) -> bool { + h.check_log + .iter() + .find(|c| c.rollup == "red" || c.rollup == "green") + .is_some_and(|c| c.rollup == "green") +} + +/// A person reviewed it after it merged (a bypass's after-review). +fn reviewed_after(h: &History) -> bool { + h.review_log + .iter() + .any(|r| r.human && r.at > h.merged_at && h.merged_at > 0) +} + +struct SummaryCtx<'a> { + org: &'a str, + scope: &'a str, + repos_n: usize, + open: &'a [&'a Open], + open_n: usize, + stale: &'a [(&'a &'a Open, &'a str)], + past_usual: usize, + lines: &'a Lines, + merged_w: &'a [&'a History], + merged_prev: &'a [&'a History], + merges_range: Option<(u32, u32)>, + merges_median: Option, + past_range: Option<(u32, u32)>, + past_sla: &'a [(&'a &'a Open, i64)], + bypass_w: &'a [&'a History], + reverted_14: &'a [&'a History], + merged_30: &'a [&'a History], + strip: &'a [Value], + decisions: &'a [&'a &'a Open], + ch_opened: usize, + ch_merged: usize, + ch_reverted: usize, + ch_outcomes: &'a [&'a History], + ch_reviewed: usize, + human_now: Option, + human_prev: Option, + org_health: &'a str, + sla: Sla, + since: i64, + now: i64, + window_days: i64, +} + +/// A change worth mentioning: at least 2 and at least 10% of before. +pub fn passes_floor(now: f64, prev: f64) -> bool { + let d = (now - prev).abs(); + d >= 2.0 && d >= 0.1 * prev.abs() +} + +fn summary(c: &SummaryCtx, b: &mut Builder) -> Value { + let scope = c.scope; + let merged_link = gh_search(c.org, &format!("is:merged merged:>={}", day_of(c.since))); + let merges = c.merged_w.len() as f64; + let unreviewed_bypass: Vec<&&History> = + c.bypass_w.iter().filter(|h| !reviewed_after(h)).collect(); + let critical: Vec<&(&&Open, i64)> = c + .past_sla + .iter() + .filter(|(o, _)| sev_rank(&o.rec.severity) == 0) + .collect(); + let quiet_week = c.merges_median.is_some_and(|m| (merges as i64) * 4 < m) && c.past_usual == 0; + let past_out = c.past_range.is_some_and(|(_, hi)| c.past_usual as u32 > hi); + let merges_out = c.merges_range.is_some_and(|(lo, _)| (merges as u32) < lo); + let state = + if !critical.is_empty() || !unreviewed_bypass.is_empty() || c.org_health == "slipping" { + "slipping" + } else if past_out || merges_out || c.org_health == "at_risk" { + "at_risk" + } else if quiet_week { + "quiet" + } else { + "healthy" + }; + b.fact( + "merges", + scope, + merges, + Some(c.merged_prev.len() as f64), + 0.2, + merged_link.clone(), + ); + let usual = |b: &mut Builder| -> Vec { + let mut v = vec![b.num("merges", scope, merges, "count", merged_link.clone())]; + match c.merges_range { + Some((lo, hi)) => { + v.push(t(" merged (usual ")); + v.push(b.num( + "merges_8w_low", + scope, + lo as f64, + "count", + merged_link.clone(), + )); + v.push(t(" to ")); + v.push(b.num( + "merges_8w_high", + scope, + hi as f64, + "count", + merged_link.clone(), + )); + v.push(t(").")); + } + None => v.push(t(" merged.")), + } + v + }; + let mut parts: Vec = Vec::new(); + match state { + "slipping" => { + if !critical.is_empty() { + parts.push(b.num( + "security_past_sla", + scope, + critical.len() as f64, + "count", + list("past=sla"), + )); + parts.push(t(format!( + " critical security {} past the ", + if critical.len() == 1 { + "fix is" + } else { + "fixes are" + } + ))); + parts.push(b.num( + "sla_critical_days", + scope, + c.sla.critical as f64, + "count", + list("past=sla"), + )); + parts.push(t("-day SLA")); + parts.push(t(if unreviewed_bypass.is_empty() { + ". " + } else { + ", and " + })); + } + if !unreviewed_bypass.is_empty() { + parts.push(b.num( + "bypass_unreviewed", + scope, + unreviewed_bypass.len() as f64, + "count", + list("view=needs_decision"), + )); + parts.push(t(format!( + " {} through a bypass with no review after. ", + if unreviewed_bypass.len() == 1 { + "merge went" + } else { + "merges went" + } + ))); + } + if critical.is_empty() && unreviewed_bypass.is_empty() { + parts.push(t("A repo holding 10% or more of open PRs is slipping. ")); + } + parts.extend(usual(b)); + } + "at_risk" => { + if past_out { + let (lo, hi) = c.past_range.unwrap_or((0, 0)); + parts.push(b.num( + "past_p85", + scope, + c.past_usual as f64, + "count", + list("past=p85"), + )); + parts.push(t(" open PRs are past usual (8-week range ")); + parts.push(b.num( + "past_p85_8w_low", + scope, + lo as f64, + "count", + list("past=p85"), + )); + parts.push(t(" to ")); + parts.push(b.num( + "past_p85_8w_high", + scope, + hi as f64, + "count", + list("past=p85"), + )); + parts.push(t("). ")); + } else if merges_out { + parts.push(t("Merges fell below their 8-week range: ")); + } else { + parts.push(t( + "A repo holding 10% or more of open PRs is outside its 8-week range. ", + )); + } + parts.extend(usual(b)); + } + "quiet" => { + parts.extend(usual(b)); + parts.push(t(" Nothing is past usual.")); + } + _ => { + parts.extend(usual(b)); + if let Some([p50, _, _]) = c.lines.cycle { + parts.push(t(" Half of merged PRs take under ")); + parts.push(b.num("cycle_p50", scope, p50 as f64, "secs", merged_link.clone())); + parts.push(t("; nothing is past a deadline.")); + } else { + parts.push(t(" Nothing is past a deadline.")); + } + } + } + let word = match state { + "slipping" => "Slipping", + "at_risk" => "At risk", + "quiet" => "Quiet", + _ => "Healthy", + }; + + // Three fixed tiles. + let human_link = gh_search( + c.org, + &format!("is:merged review:approved merged:>={}", day_of(c.since)), + ); + let stale_n = c.stale.len() as f64; + b.fact("stale", scope, stale_n, None, 0.3, list("view=stale")); + if let Some(h) = c.human_now { + b.fact( + "reviewed", + scope, + round3(h), + c.human_prev.map(round3), + 0.2, + human_link.clone(), + ); + } + let reverts = c + .reverted_14 + .iter() + .filter(|h| h.reverted_by.as_ref().is_some_and(|(_, _, t)| *t > c.since)) + .count(); + b.fact( + "reverts", + scope, + reverts as f64, + None, + 0.1, + gh_search(c.org, "is:merged revert in:title"), + ); + let tiles = json!([ + {"fact": "stale", "label": "Stale: idle past the stage p85", "value": c.stale.len(), "unit": "count", "delta": Value::Null, "link": list("view=stale")}, + {"fact": "failures", "label": "Failures: main red this week", "value": Value::Null, "unit": "secs", "delta": Value::Null, + "second": {"value": reverts, "unit": "count", "label": if reverts == 1 { "revert" } else { "reverts" }, "link": gh_search(c.org, "is:merged revert in:title")}, + "link": list("state=checks_failing")}, + {"fact": "reviewed", "label": "Reviewed: human-approved merges", "value": c.human_now.map(round3), "unit": "share", + "delta": c.human_now.zip(c.human_prev).map(|(a, p)| round3(a - p)), "link": human_link}, + ]); + + // Needs attention: obligations, then stale by age, then decisions. + let mut items: Vec<(u8, i64, Value)> = Vec::new(); + for (o, a) in c.past_sla.iter().take(3) { + let (owner, kind) = owner_of(&o.row); + items.push((0, *a, json!({ + "fact": "security_past_sla", "owner": owner, "owner_kind": kind, + "owner_note": if owner.is_none() { json!("no owner on the fix yet") } else { Value::Null }, + "age_secs": a, "link": list(&format!("pr={}", o.row.key)), + "parts": [t(format!("{} is a {} security fix past its SLA", short_key(&o.row.key), o.rec.severity))], + }))); + } + for h in unreviewed_bypass.iter().take(2) { + items.push((1, c.now - h.merged_at, json!({ + "fact": "bypass", "owner": Value::Null, "owner_kind": Value::Null, "owner_note": "no reviewer after the merge", + "age_secs": c.now - h.merged_at, "link": list(&format!("pr={}#{}", h.repo, h.number)), + "parts": [t(format!("{}#{} merged through a bypass ({}), no review after", h.repo.split('/').nth(1).unwrap_or(&h.repo), h.number, h.bypass.clone().unwrap_or_default()))], + }))); + } + let mut stale_sorted: Vec<&(&&Open, &str)> = c.stale.iter().collect(); + stale_sorted + .sort_by_key(|(o, _)| std::cmp::Reverse(idle_of(o, c.now).map(|x| x.1).unwrap_or(0))); + for (o, who) in stale_sorted.iter().take(5) { + let idle = idle_of(o, c.now).map(|x| x.1).unwrap_or(0); + if idle < WAIT_FLOOR_SECS { + continue; + } + let (owner, kind) = owner_of(&o.row); + items.push((3, idle, json!({ + "fact": "stale", "owner": owner, "owner_kind": kind, + "owner_note": if owner.is_none() { json!(if *who == "reviewer" { "no reviewer assigned" } else { "nobody holds it" }) } else { Value::Null }, + "age_secs": idle, "link": list(&format!("pr={}", o.row.key)), + // The state's words, never the needs sentence: that one can + // name people, and a name appears only as the owner. + "parts": [t(format!("{}: {}, nobody acting on it", short_key(&o.row.key), o.row.state_label.to_lowercase()))], + }))); + } + for o in c.decisions.iter().take(1) { + let (owner, kind) = owner_of(&o.row); + items.push(( + 2, + age(o, c.now), + json!({ + "fact": "needs_decision", "owner": owner, "owner_kind": kind, + "owner_note": if owner.is_none() { json!("nobody asked yet") } else { Value::Null }, + "age_secs": age(o, c.now), "link": list(&format!("pr={}", o.row.key)), + "parts": [t(format!("CoderHelm needs a decision on {}", short_key(&o.row.key)))], + }), + )); + } + items.sort_by(|a, b| a.0.cmp(&b.0).then(b.1.cmp(&a.1))); + let total_items = items.len(); + let attention: Vec = items + .into_iter() + .take(5) + .enumerate() + .map(|(k, (_, _, mut v))| { + v["rank"] = json!(k + 1); + v + }) + .collect(); + let more = + (total_items > 5).then(|| json!({"count": total_items - 5, "link": list("view=stale")})); + let quiet = attention.is_empty().then(|| { + let mut p = vec![t("Nothing needs you. Checked ")]; + p.push(b.num( + "repos", + scope, + c.repos_n as f64, + "count", + json!({"overview": ""}), + )); + p.push(t(" repos and ")); + p.push(b.num("open", scope, c.open_n as f64, "count", list(""))); + p.push(t( + " open PRs: none stale past a day, no security fix past SLA, no bypasses, no reverts.", + )); + json!({"repos": c.repos_n, "open": c.open_n, "parts": p}) + }); + + // What changed: the largest stage change past the floor. + let mut changed: Option = None; + let mut best = 0.0; + for s in c.strip { + if let (Some(n), Some(d)) = (s["count"].as_f64(), s["delta"].as_f64()) { + let prev = n - d; + if passes_floor(n, prev) && d.abs() > best { + best = d.abs(); + let label = s["label"].as_str().unwrap_or("").to_string(); + let code = s["stage"].as_str().unwrap_or("").to_string(); + let id = format!("stage_{code}"); + b.fact( + &id, + scope, + n, + Some(prev), + d.abs() / (c.open_n.max(1) as f64), + list(&format!("stage={code}")), + ); + let before = format!("{id}_before"); + b.fact( + &before, + scope, + prev, + None, + 0.0, + list(&format!("stage={code}")), + ); + let pp = b.num( + &before, + scope, + prev, + "count", + list(&format!("stage={code}")), + ); + let pn = b.num(&id, scope, n, "count", list(&format!("stage={code}"))); + changed = Some( + json!({"fact": id, "parts": [t(format!("{label} {} from ", if d > 0.0 { "rose" } else { "fell" })), pp, t(" to "), pn, t(".")]}), + ); + } + } + } + + // Stability: always. + let mut st = vec![b.num( + "reverts", + scope, + reverts as f64, + "count", + gh_search(c.org, "is:merged revert in:title"), + )]; + st.push(t(format!( + " revert{} this window", + if reverts == 1 { "" } else { "s" } + ))); + let reworked = c.merged_30.iter().filter(|h| h.reworked()).count(); + match share(reworked, c.merged_30.len()) { + Some(sh) => { + st.push(t( + "; merged PRs later reverted or hotfixed over the last month: ", + )); + st.push(b.num("proxy", scope, round3(sh), "share", merged_link.clone())); + st.push(t(".")); + } + None => st.push(t("; too few merges in the last month to give a rate.")), + } + + // CoderHelm: always, its failures first. + let ch_link = list("turn=coderhelm"); + let mut ch: Vec = Vec::new(); + let short_runs = c + .ch_outcomes + .iter() + .filter(|h| matches!(h.run_outcome.as_str(), "gave_up" | "blocked" | "stopped")) + .count(); + if c.ch_reverted > 0 { + ch.push(b.num( + "coderhelm_reverted", + scope, + c.ch_reverted as f64, + "count", + ch_link.clone(), + )); + ch.push(t(" of its merged PRs were reverted. ")); + } + if short_runs > 0 { + ch.push(b.num( + "coderhelm_stopped", + scope, + short_runs as f64, + "count", + ch_link.clone(), + )); + ch.push(t(" of its runs stopped short. ")); + } + if c.ch_opened == 0 && c.ch_merged == 0 && c.ch_reviewed == 0 { + ch.push(t("No PRs from CoderHelm in this window: opened ")); + ch.push(b.num("coderhelm_opened", scope, 0.0, "count", ch_link.clone())); + ch.push(t(", reviewed ")); + ch.push(b.num("coderhelm_reviewed", scope, 0.0, "count", ch_link.clone())); + ch.push(t(". Every number above is people's and other bots' work.")); + } else { + ch.push(t("Opened ")); + ch.push(b.num( + "coderhelm_opened", + scope, + c.ch_opened as f64, + "count", + ch_link.clone(), + )); + ch.push(t(", merged ")); + ch.push(b.num( + "coderhelm_merged", + scope, + c.ch_merged as f64, + "count", + gh_search( + c.org, + &format!( + "is:merged author:app/coderhelm merged:>={}", + day_of(c.since) + ), + ), + )); + ch.push(t(", reviewed ")); + ch.push(b.num( + "coderhelm_reviewed", + scope, + c.ch_reviewed as f64, + "count", + ch_link.clone(), + )); + ch.push(t(".")); + } + let _ = (c.open, c.window_days); + + json!({ + "window": {"from": rfc3339(c.since), "to": rfc3339(c.now)}, + "computed_at": rfc3339(c.now), + "verdict": {"state": state, "word": word, "parts": parts, "rule": ROLLUP_RULE}, + "tiles": tiles, + "attention": attention, + "more": more, + "quiet": quiet, + "changed": changed, + "stability": {"fact": "reverts", "parts": st}, + "coderhelm": {"fact": "coderhelm_opened", "parts": ch, "link": ch_link}, + "method": METHOD, + }) +} + +fn short_key(key: &str) -> String { + key.split('/').nth(1).unwrap_or(key).to_string() +} + +/// Every number in the summary, with the fact it names: for the tests and +/// the incident case. +pub fn summary_numbers(v: &Value) -> Vec<(String, f64)> { + fn walk(v: &Value, out: &mut Vec<(String, f64)>) { + match v { + Value::Object(m) => { + if let (Some(n), Some(f)) = ( + m.get("n").and_then(Value::as_f64), + m.get("fact").and_then(Value::as_str), + ) { + out.push((f.to_string(), n)); + } + for x in m.values() { + walk(x, out); + } + } + Value::Array(a) => a.iter().for_each(|x| walk(x, out)), + _ => {} + } + } + let mut out = Vec::new(); + walk(&v["summary"], &mut out); + out +} diff --git a/services/common/src/run_wake.rs b/services/common/src/run_wake.rs index a1f9e948f..881c0de2c 100644 --- a/services/common/src/run_wake.rs +++ b/services/common/src/run_wake.rs @@ -250,6 +250,125 @@ pub async fn put_back( } } +/// The ticket id of an alert's runs for its fingerprint (stable across +/// repeats), as the gateway gives it when the alert starts a run. +pub fn alert_ticket_id(fingerprint: &str) -> String { + format!( + "ALERT-{}", + crate::content_hash(fingerprint)[..8].to_uppercase() + ) +} + +fn text<'a>(item: &'a HashMap, k: &str) -> &'a str { + item.get(k) + .and_then(|v| v.as_s().ok()) + .map(String::as_str) + .unwrap_or("") +} + +/// The newest run of `ticket_id` for the team. +pub async fn newest_of_ticket( + dynamo: &aws_sdk_dynamodb::Client, + runs_table: &str, + team_id: &str, + ticket_id: &str, +) -> Option> { + let out = dynamo + .query() + .table_name(runs_table) + .index_name("ticket-index") + .key_condition_expression("team_id = :tid AND ticket_id = :ticket") + .expression_attribute_values(":tid", AttributeValue::S(team_id.to_string())) + .expression_attribute_values(":ticket", AttributeValue::S(ticket_id.to_string())) + .send() + .await + .ok()?; + out.items() + .iter() + .max_by(|a, b| text(a, "run_id").cmp(text(b, "run_id"))) + .cloned() +} + +/// Why a waiting alert run closes when its alert cleared. +pub const ALERT_CLEARED_WHY: &str = "the alert cleared by itself, so nothing is left to fix"; + +/// Closes the waiting alert run `item` whose alert cleared by itself (only +/// while it still waits). Returns whether it closed. +pub async fn close_cleared( + dynamo: &aws_sdk_dynamodb::Client, + runs_table: &str, + team_id: &str, + item: &HashMap, +) -> bool { + use crate::run_ending::EndWrite; + let run_id = text(item, "run_id").to_string(); + let why = ALERT_CLEARED_WHY; + let now = chrono::Utc::now().to_rfc3339(); + let closed = dynamo + .update_item() + .table_name(runs_table) + .key("team_id", AttributeValue::S(team_id.to_string())) + .key("run_id", AttributeValue::S(run_id.clone())) + .update_expression( + "SET #status = :s, status_run_id = :sri, updated_at = :t, \ + progress_notes = list_append(if_not_exists(progress_notes, :empty), :n)", + ) + .condition_expression("#status = :waiting") + .expression_attribute_names("#status", "status") + .run_status( + ":s", + &crate::run_ending::gate( + &run_id, + &crate::run_ending::RunEnd::Stopped(crate::run_ending::Stopped { + reason: crate::run_ending::Stop::ClosedBy { + who: "CoderHelm".into(), + why: why.into(), + }, + tried: Default::default(), + }), + ), + ) + .expression_attribute_values(":waiting", AttributeValue::S(WAITING.into())) + .expression_attribute_values(":empty", AttributeValue::L(vec![])) + .expression_attribute_values( + ":n", + AttributeValue::L(vec![AttributeValue::M(HashMap::from([ + ( + "message".to_string(), + AttributeValue::S(format!("Closed: {why}.")), + ), + ("timestamp".to_string(), AttributeValue::S(now.clone())), + ]))]), + ) + .expression_attribute_values(":t", AttributeValue::S(now)) + .send() + .await; + if closed.is_ok() { + tracing::info!(run_id, "Alert cleared: its waiting run closed"); + } + closed.is_ok() +} + +/// The alert whose runs' ticket is `ticket_id` cleared: its newest run, when +/// it waits on a person, closes ([`alert_wake`] with `cleared`, then +/// [`close_cleared`]). The one path every recovery takes, whether it posts +/// at once or after a route's quiet window. Returns whether a run closed. +pub async fn alert_cleared( + dynamo: &aws_sdk_dynamodb::Client, + runs_table: &str, + team_id: &str, + ticket_id: &str, +) -> bool { + let Some(item) = newest_of_ticket(dynamo, runs_table, team_id, ticket_id).await else { + return false; + }; + let wait = crate::run_wait::WaitingOn::of_item(&item).unwrap_or_default(); + match alert_wake(text(&item, "status"), &wait.handback, true) { + Some(AlertWake::Close) => close_cleared(dynamo, runs_table, team_id, &item).await, + _ => false, + } +} + #[cfg(test)] mod tests { use super::*; @@ -282,6 +401,30 @@ mod tests { ); } + /// A recovery closes its waiting run whatever the run waits on, and + /// whichever way it posts (at once, or after the route's quiet window): + /// both find the run by the same ticket. + #[test] + fn a_cleared_alert_closes_its_waiting_run_however_the_recovery_posts() { + for why in crate::handback::HUMAN_ONLY { + assert_eq!( + alert_wake(WAITING, why.code(), true), + Some(AlertWake::Close), + "{why:?}" + ); + } + assert_eq!(alert_wake(WAITING, "", true), Some(AlertWake::Close)); + // Only a run that waits: a finished or running one is left alone. + assert_eq!(alert_wake("completed", "", true), None); + assert_eq!(alert_wake("running", "", true), None); + let fp = "cloudwatch:example-alarm:eu-west-1"; + let t = alert_ticket_id(fp); + assert!(t.starts_with("ALERT-") && t.len() == 14, "{t}"); + assert_eq!(t, alert_ticket_id(fp)); + assert_ne!(t, alert_ticket_id("cloudwatch:other-alarm:eu-west-1")); + assert_eq!(crate::rendered::person_text(ALERT_CLEARED_WHY), None); + } + #[test] fn a_wake_whose_run_was_not_queued_goes_back_to_waiting() { let s = |v: &str| AttributeValue::S(v.into()); diff --git a/services/gateway/src/main.rs b/services/gateway/src/main.rs index b02b645a1..a1d2da685 100644 --- a/services/gateway/src/main.rs +++ b/services/gateway/src/main.rs @@ -693,6 +693,7 @@ fn build_app(state: Arc) -> Router { .route("/reviewer/live", get(routes::reviewer::live_prs)) .route("/prs", get(routes::prs::list_prs)) .route("/prs/detail", get(routes::prs::get_pr)) + .route("/prs/overview", get(routes::prs_overview::get_overview)) .route("/reviewer/open-prs", get(routes::reviewer::open_prs)) .route( "/reviewer/gate", diff --git a/services/gateway/src/permissions.rs b/services/gateway/src/permissions.rs index 6f488995f..d5e269824 100644 --- a/services/gateway/src/permissions.rs +++ b/services/gateway/src/permissions.rs @@ -127,6 +127,7 @@ pub const CAPABILITIES: &[Capability] = &[ "reviewer::open_prs", "prs::list_prs", "prs::get_pr", + "prs_overview::get_overview", "review_lessons::list_lessons", "learning::get_learning", "learning::get_health", diff --git a/services/gateway/src/routes/alerts.rs b/services/gateway/src/routes/alerts.rs index 08fceabfe..49fa18fd3 100644 --- a/services/gateway/src/routes/alerts.rs +++ b/services/gateway/src/routes/alerts.rs @@ -387,10 +387,7 @@ pub fn ticket_body(topic_arn: &str, alert: &Alert, instructions: &str) -> String /// Pure: the run's ticket id for an alert fingerprint (stable across repeats). pub fn ticket_id(fingerprint: &str) -> String { - format!( - "ALERT-{}", - common::content_hash(fingerprint)[..8].to_uppercase() - ) + common::run_wake::alert_ticket_id(fingerprint) } /// Pure: `arn:aws:sns:::` → account, when well-formed. diff --git a/services/gateway/src/routes/github_webhook.rs b/services/gateway/src/routes/github_webhook.rs index acb99c2ac..4b03cb80e 100644 --- a/services/gateway/src/routes/github_webhook.rs +++ b/services/gateway/src/routes/github_webhook.rs @@ -2015,6 +2015,25 @@ pub(crate) fn rerequest_key(delivery_id: &str, payload: &Value) -> String { } /// Track PR merges for CoderHelm branches — updates run status to "merged". +/// The worker message that has a team's runs waiting on another change read +/// the pull request of `payload` again, for an event that moves it (a +/// close, merged or not, or a reopen). `None` for any other action. +pub fn change_wait_check(action: &str, payload: &Value, team_id: &str) -> Option { + if !common::change_wait::event_moves_change(action) { + return None; + } + Some(WorkerMessage::ChangeWaitCheck( + common::messages::ChangeWaitCheckMessage { + team_id: team_id.to_string(), + repo: payload["repository"]["full_name"] + .as_str() + .unwrap_or("") + .to_string(), + pr: payload["pull_request"]["number"].as_u64().unwrap_or(0), + }, + )) +} + async fn handle_pull_request( state: &AppState, payload: &Value, @@ -2096,6 +2115,17 @@ async fn handle_pull_request( return send_review_job(state, message, head, 0).await; } + // Runs waiting on this change read it again at once + // (`common::change_wait`): a merge resumes them, a close stops them for + // a person, and a reopen takes a run that close stopped back to waiting. + // Before the returns below, since a reopen goes on to the review + // triggers. The worker's 15-minute sweep is the backstop. + if let Some(check) = change_wait_check(action, payload, team_id) { + if let Err(e) = send_to_queue(state, &state.config.ticket_queue_url, &check).await { + warn!(error = ?e, "Could not ask waiting runs to read their change again"); + } + } + // The scorecard: one of CoderHelm's pull requests opened or reopened. if action == "opened" || action == "reopened" { super::scorecard::on_pull_request(state, team_id, payload, action, None).await; @@ -2140,15 +2170,6 @@ async fn handle_pull_request( if action != "closed" { return Ok(StatusCode::OK); } - // Runs waiting for another change to merge read their dependency again - // (`common::change_wait`): a merge resumes them, a close stops them for - // a person. The worker does nothing for a team with no waiting run. - let check = WorkerMessage::ChangeWaitCheck(common::messages::ChangeWaitCheckMessage { - team_id: team_id.to_string(), - }); - if let Err(e) = send_to_queue(state, &state.config.ticket_queue_url, &check).await { - warn!(error = ?e, "Could not ask waiting runs to read their dependency again"); - } // A merge: the open pull requests based on its branch move to its base // (the worker reads the pull request and the repository's setting). if let Some(m) = stack_merged_message(payload, installation_id, team_id, merged) { @@ -6940,3 +6961,50 @@ mod ci_wake_tests { assert!(prs_headed_at(&json!({"message": "Not Found"}), "c0ffee1").is_empty()); } } + +#[cfg(test)] +mod change_wait_check_tests { + use super::{change_wait_check, WorkerMessage}; + use serde_json::json; + + fn event(action: &str) -> serde_json::Value { + json!({ + "action": action, + "repository": {"full_name": "acme/bookstore-web", "name": "bookstore-web", + "owner": {"login": "acme"}}, + "pull_request": {"number": 12, "merged": false}, + }) + } + + /// A reopened change reaches the runs waiting on it as GitHub reports + /// it, not at the next sweep; a close (merged or not) does too. + #[test] + fn a_reopen_or_close_asks_the_waiting_runs_at_once() { + for action in ["reopened", "closed"] { + match change_wait_check(action, &event(action), "T1") { + Some(WorkerMessage::ChangeWaitCheck(m)) => { + assert_eq!(m.team_id, "T1"); + assert_eq!(m.repo, "acme/bookstore-web"); + assert_eq!(m.pr, 12); + } + other => panic!("{action}: {other:?}"), + } + } + for action in ["opened", "synchronize", "labeled", "edited"] { + assert!(change_wait_check(action, &event(action), "T1").is_none()); + } + } + + /// The check is sent before the reopen goes on to the review triggers + /// (which return), so no early return skips it. + #[test] + fn the_check_is_sent_before_any_return_a_reopen_reaches() { + let src = include_str!("github_webhook.rs"); + let handler = src.split("async fn handle_pull_request(").nth(1).unwrap(); + let check = handler + .find("change_wait_check(action, payload, team_id)") + .unwrap(); + let review = handler.find("return handle_review_trigger(").unwrap(); + assert!(check < review); + } +} diff --git a/services/gateway/src/routes/mod.rs b/services/gateway/src/routes/mod.rs index 541b684ed..7335d1de1 100644 --- a/services/gateway/src/routes/mod.rs +++ b/services/gateway/src/routes/mod.rs @@ -82,6 +82,7 @@ pub mod plugin_pkgs; pub mod plugins; pub mod preview_access; pub mod prs; +pub mod prs_overview; pub mod repo_setup; pub mod require_sso; #[cfg(test)] diff --git a/services/gateway/src/routes/prs.rs b/services/gateway/src/routes/prs.rs index 1136ddd13..050b5a355 100644 --- a/services/gateway/src/routes/prs.rs +++ b/services/gateway/src/routes/prs.rs @@ -249,7 +249,11 @@ fn n(item: &Item, k: &str) -> Option { item.get(k)?.as_n().ok()?.parse().ok() } -async fn items_under(state: &AppState, team_id: &str, prefix: &str) -> Result, String> { +pub(crate) async fn items_under( + state: &AppState, + team_id: &str, + prefix: &str, +) -> Result, String> { let mut out = Vec::new(); let mut start: Option = None; loop { @@ -427,7 +431,10 @@ async fn runs_by_id(state: &AppState, team_id: &str, ids: &[String]) -> HashMap< } /// The team's records and joins, from the short cache or the tables. -async fn read_all(state: &AppState, team_id: &str) -> Result<(Snapshot, Vec), StatusCode> { +pub(crate) async fn read_all( + state: &AppState, + team_id: &str, +) -> Result<(Snapshot, Vec), StatusCode> { let installation_id = super::api::get_team_installation_id(state, team_id) .await .unwrap_or(0); @@ -483,10 +490,41 @@ pub struct ListQuery { person: Option, q: Option, view: Option, + /// The overview's drill-down: one stage, or open past a cycle-time percentile. + stage: Option, + past: Option, limit: Option, cursor: Option, } +/// Pure: the overview's drill-down filters, or 400 for a word outside them. +pub fn drill_of( + stage: Option, + past: Option, +) -> Result<(Option, Option), StatusCode> { + let stage = clean(stage); + if stage.as_deref().is_some_and(|s| { + ![ + "draft", + "first_review", + "in_review", + "blocked", + "coderhelm_working", + "approved", + ] + .contains(&s) + }) { + return Err(StatusCode::BAD_REQUEST); + } + let past = match clean(past).as_deref() { + None => None, + Some("p85") => Some(85), + Some("p95") => Some(95), + Some(_) => return Err(StatusCode::BAD_REQUEST), + }; + Ok((stage, past)) +} + fn clean(v: Option) -> Option { v.map(|s| s.trim().to_string()).filter(|s| !s.is_empty()) } @@ -575,15 +613,51 @@ fn synced_at(items: &[Item], team_id: &str, q: &pr_view::Query) -> Option>, Extension(claims): Extension, - Query(q): Query, + Query(mut q): Query, ) -> Result, StatusCode> { + let (stage, past) = drill_of(q.stage.take(), q.past.take())?; let (query, limit, cursor) = query_of(q)?; - let (data, sources) = read_all(&state, &claims.team_id).await?; + let (data, mut sources) = read_all(&state, &claims.team_id).await?; let (items, joins) = (&data.0, &data.1); let viewer = claims.github_login.as_deref(); - let rows = pr_view::rows(&claims.team_id, items, joins, viewer, now()); + let t = now(); + let rows = pr_view::rows(&claims.team_id, items, joins, viewer, t); let synced = synced_at(items, &claims.team_id, &query); - let page = pr_view::page(rows, &query, limit, cursor.as_deref()); + let page = if stage.is_none() && past.is_none() { + pr_view::page(rows, &query, limit, cursor.as_deref()) + } else { + // The counts stay over the whole scope; the rows are the drill-down's. + let limit_secs = match past { + Some(p) => past_secs(&state, &claims.team_id, &query, p, t).await, + None => None, + }; + if past.is_some() && limit_secs.is_none() { + sources.push(json!({"name": "percentiles", "read": "held", "detail": "no percentiles yet, so every open pull request is shown"})); + } + let picked: Vec = rows + .iter() + .filter(|r| { + stage + .as_deref() + .is_none_or(|s| r.stage.as_deref() == Some(s)) + }) + .filter(|r| match limit_secs { + Some(l) => { + !r.draft + && r.ready_at + .as_deref() + .and_then(|a| chrono::DateTime::parse_from_rfc3339(a).ok()) + .is_some_and(|a| t - a.timestamp() > l) + } + None => true, + }) + .cloned() + .collect(); + let counts = pr_view::page(rows, &query, 1, None).counts; + let mut p = pr_view::page(picked, &query, limit, cursor.as_deref()); + p.counts = counts; + p + }; let backfill = backfill_progress(&state, &claims.team_id).await; Ok(Json(json!({ "backfill": backfill, @@ -597,6 +671,32 @@ pub async fn list_prs( }))) } +/// The scope's cycle-time percentile from its newest snapshot (90 days of +/// merges): the line "past usual" is measured against. +async fn past_secs( + state: &AppState, + team_id: &str, + q: &pr_view::Query, + p: u32, + now: i64, +) -> Option { + let scope = q.repo.clone().or_else(|| q.org.clone())?; + let since = chrono::DateTime::from_timestamp(now - 3 * 86_400, 0)? + .format("%Y-%m-%d") + .to_string(); + let snaps = common::pr_history::snapshots_of( + &state.dynamo, + &state.config.settings_table_name, + team_id, + &scope, + &since, + ) + .await + .ok()?; + let c = &snaps.last()?.pct.cycle; + c.get(if p == 95 { 2 } else { 1 }).copied() +} + /// Pure: each organization's history backfill as the page shows it. pub fn backfill_json(items: &[Item]) -> Vec { use common::pr_history::{Backfill, BACKFILL_MONTHS}; diff --git a/services/gateway/src/routes/prs_overview.rs b/services/gateway/src/routes/prs_overview.rs new file mode 100644 index 000000000..8880c9a2d --- /dev/null +++ b/services/gateway/src/routes/prs_overview.rs @@ -0,0 +1,269 @@ +//! `GET /api/prs/overview?org=&repo=&window=` — the org's pull requests in +//! one answer (`common::pr_overview::build`): the written summary, the stage +//! strip, the aging dots, each repository's health, the stale, failure, +//! review and security panels, this week's events and CoderHelm's slice. +//! +//! Every pull request in the team's repositories counts: people's, +//! CoderHelm's and other bots'. The team is the session's, never a +//! parameter; every read is keyed by it (records, history, snapshots, +//! backfill progress). The short cache is keyed by the installation, the +//! team and the scope. + +use std::collections::BTreeMap; +use std::sync::{Arc, LazyLock}; +use std::time::{Duration, Instant}; + +use axum::{ + extract::{Query, State}, + http::StatusCode, + Extension, Json, +}; +use common::pr_history::{self, Backfill, History, Snapshot}; +use common::pr_overview::{self, Input, Open, Sla}; +use common::pr_view; +use serde::Deserialize; +use serde_json::{json, Value}; +use tracing::{error, warn}; + +use super::prs::{items_under, read_all}; +use super::run_checks::{read_key, TtlCache}; +use crate::models::Claims; +use crate::AppState; + +/// How long one scope's overview is reused (the page polls every minute). +const OVERVIEW_TTL: Duration = Duration::from_secs(60); +/// Most repositories whose own snapshots are read for sparklines and ranges. +const MAX_REPO_SNAPS: usize = 30; + +/// The built overview, keyed by +/// `read_key(installation_id, "prs_overview####")`. +static OVERVIEW: LazyLock>> = LazyLock::new(TtlCache::new); + +#[derive(Deserialize, Default)] +pub struct OverviewQuery { + org: Option, + repo: Option, + window: Option, +} + +fn clean(v: Option) -> Option { + v.map(|s| s.trim().to_string()).filter(|s| !s.is_empty()) +} + +/// Pure: the scope and window, or 400 for anything outside them. +pub fn scope_of(q: OverviewQuery) -> Result<(Option, Option, i64), StatusCode> { + let org = clean(q.org); + if let Some(o) = &org { + if o.len() > 100 + || !o + .chars() + .all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_' || c == '.') + { + return Err(StatusCode::BAD_REQUEST); + } + } + let repo = clean(q.repo); + if let Some(r) = &repo { + super::reviewer::validate_repo(r)?; + } + let days = + pr_overview::window_days(clean(q.window).as_deref()).ok_or(StatusCode::BAD_REQUEST)?; + Ok((org, repo, days)) +} + +fn day(t: i64) -> String { + chrono::DateTime::from_timestamp(t, 0) + .map(|d| d.format("%Y-%m-%d").to_string()) + .unwrap_or_default() +} + +/// GET /api/prs/overview — computed facts only; what isn't stored yet is +/// null and named in `missing`. +pub async fn get_overview( + State(state): State>, + Extension(claims): Extension, + Query(q): Query, +) -> Result, StatusCode> { + let (org, repo, days) = scope_of(q)?; + let team_id = claims.team_id.as_str(); + let installation_id = super::api::get_team_installation_id(&state, team_id) + .await + .unwrap_or(0); + let key = read_key( + installation_id, + &format!( + "prs_overview#{team_id}#{}#{}#{days}", + org.as_deref().unwrap_or(""), + repo.as_deref().unwrap_or("") + ), + ); + let at = Instant::now(); + if let Some(hit) = OVERVIEW.get(&key, at) { + return Ok(Json((*hit).clone())); + } + + let now = chrono::Utc::now().timestamp(); + let table = &state.config.settings_table_name; + let (data, mut sources) = read_all(&state, team_id).await?; + let (items, joins) = (&data.0, &data.1); + let recs = pr_view::records_of(team_id, items); + let rows = pr_view::rows(team_id, items, joins, None, now); + let open: Vec = recs + .into_iter() + .filter(|r| r.is_open()) + .filter_map(|rec| { + let k = format!("{}#{}", rec.repo, rec.number); + let row = rows + .iter() + .find(|r| r.key.eq_ignore_ascii_case(&k))? + .clone(); + Some(Open { rec, row }) + }) + .collect(); + + let hist: Vec = match pr_history::all_since( + &state.dynamo, + table, + team_id, + now - pr_history::HISTORY_KEEP_SECS, + ) + .await + { + Ok(h) => h, + Err(e) => { + warn!(team_id, error = %e, "Overview: history not read"); + sources.push(json!({"name": "history", "read": "failed", "detail": "merged and closed pull requests couldn't be read; numbers that need them say so"})); + Vec::new() + } + }; + let org_scope = repo + .as_deref() + .and_then(|r| r.split('/').next()) + .map(str::to_string) + .or(org.clone()) + .or_else(|| open.first().map(|o| o.rec.org().to_string())) + .unwrap_or_default(); + let scope = repo.clone().unwrap_or_else(|| org_scope.clone()); + let since_day = day(now - 63 * 86_400); + let snaps: Vec = if scope.is_empty() { + Vec::new() + } else { + pr_history::snapshots_of(&state.dynamo, table, team_id, &scope, &since_day) + .await + .unwrap_or_else(|e| { + warn!(team_id, error = %e, "Overview: snapshots not read"); + Vec::new() + }) + }; + // Each repository's own snapshots, for its sparkline and 8-week range: + // the busiest first, bounded. + let mut busy: BTreeMap = BTreeMap::new(); + for o in &open { + if repo + .as_deref() + .is_none_or(|r| o.rec.repo.eq_ignore_ascii_case(r)) + && (org_scope.is_empty() || o.rec.org().eq_ignore_ascii_case(&org_scope)) + { + *busy.entry(o.rec.repo.clone()).or_default() += 1; + } + } + let mut names: Vec<(String, usize)> = busy.into_iter().collect(); + names.sort_by_key(|b| std::cmp::Reverse(b.1)); + let reads = names.iter().take(MAX_REPO_SNAPS).map(|(n, _)| { + let n = n.clone(); + let st = state.clone(); + let since = since_day.clone(); + let team = team_id.to_string(); + async move { + let t = st.config.settings_table_name.clone(); + let s = pr_history::snapshots_of(&st.dynamo, &t, &team, &n, &since) + .await + .unwrap_or_default(); + (n, s) + } + }); + let repo_snaps: BTreeMap> = + futures::future::join_all(reads).await.into_iter().collect(); + let backfill: Vec = + match items_under(&state, team_id, pr_history::BACKFILL_PREFIX).await { + Ok(items) => items + .iter() + .filter(|i| { + i.get("pk").and_then(|v| v.as_s().ok()).map(String::as_str) == Some(team_id) + }) + .filter_map(|i| i.get("doc").and_then(|v| v.as_s().ok())) + .filter_map(|d| serde_json::from_str(d).ok()) + .collect(), + Err(e) => { + error!(team_id, error = %e, "Overview: backfill progress not read"); + Vec::new() + } + }; + + let mut out = pr_overview::build(&Input { + open: &open, + hist: &hist, + snaps: &snaps, + repo_snaps: &repo_snaps, + backfill: &backfill, + org: if org_scope.is_empty() { + None + } else { + Some(org_scope.as_str()) + }, + repo: repo.as_deref(), + window_days: days, + sla: Sla::default(), + now, + }); + let mut orgs: Vec = open.iter().map(|o| o.rec.org().to_string()).collect(); + orgs.sort(); + orgs.dedup(); + out["scope"]["orgs"] = json!(orgs); + out["synced_at"] = json!(open + .iter() + .map(|o| o.rec.synced_at.max(o.rec.event_at)) + .filter(|t| *t > 0) + .min() + .and_then(pr_view::rfc3339)); + out["sources"] = json!(sources); + let out = Arc::new(out); + OVERVIEW.put(key, out.clone(), OVERVIEW_TTL, at); + Ok(Json((*out).clone())) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn the_scope_takes_only_its_own_words() { + let q = |org: Option<&str>, repo: Option<&str>, w: Option<&str>| OverviewQuery { + org: org.map(Into::into), + repo: repo.map(Into::into), + window: w.map(Into::into), + }; + assert_eq!(scope_of(q(Some("acme"), None, None)).unwrap().2, 7); + assert_eq!( + scope_of(q(None, Some("acme/web"), Some("28d"))).unwrap().2, + 28 + ); + assert!(scope_of(q(Some("acme corp"), None, None)).is_err()); + assert!(scope_of(q(None, Some("acme/../web"), None)).is_err()); + assert!(scope_of(q(None, None, Some("1y"))).is_err()); + } + + #[test] + fn the_lists_drill_down_takes_a_stage_or_a_percentile() { + use super::super::prs::drill_of; + let w = |s: &str| Some(s.to_string()); + assert_eq!( + drill_of(w("first_review"), None).unwrap(), + (w("first_review"), None) + ); + assert_eq!(drill_of(None, w("p85")).unwrap(), (None, Some(85))); + assert_eq!(drill_of(None, w("p95")).unwrap().1, Some(95)); + assert!(drill_of(w("everything"), None).is_err()); + assert!(drill_of(None, w("p99")).is_err()); + } +} diff --git a/services/gateway/src/routes/run_wake.rs b/services/gateway/src/routes/run_wake.rs index 1bc5c96a8..1fd3dd415 100644 --- a/services/gateway/src/routes/run_wake.rs +++ b/services/gateway/src/routes/run_wake.rs @@ -296,21 +296,13 @@ async fn run_item(state: &AppState, team_id: &str, run_id: &str) -> Option /// The newest run of `ticket_id`, whatever its status. async fn newest_of_ticket(state: &AppState, team_id: &str, ticket_id: &str) -> Option { - let out = state - .dynamo - .query() - .table_name(&state.config.runs_table_name) - .index_name("ticket-index") - .key_condition_expression("team_id = :tid AND ticket_id = :ticket") - .expression_attribute_values(":tid", AttributeValue::S(team_id.to_string())) - .expression_attribute_values(":ticket", AttributeValue::S(ticket_id.to_string())) - .send() - .await - .ok()?; - out.items() - .iter() - .max_by(|a, b| text(a, "run_id").cmp(text(b, "run_id"))) - .cloned() + run_wake::newest_of_ticket( + &state.dynamo, + &state.config.runs_table_name, + team_id, + ticket_id, + ) + .await } /// The answer to approval `approval_id` sends the run that waited for it @@ -400,70 +392,27 @@ pub async fn alert_delivery( ticket_id: &str, cleared: bool, ) -> bool { + // A clear takes the one path every recovery takes, whether it posts at + // once or after the route's quiet window (`run_wake::alert_cleared`). + if cleared { + return run_wake::alert_cleared( + &state.dynamo, + &state.config.runs_table_name, + team_id, + ticket_id, + ) + .await; + } let Some(item) = newest_of_ticket(state, team_id, ticket_id).await else { return false; }; let wait = WaitingOn::of_item(&item).unwrap_or_default(); - match run_wake::alert_wake(text(&item, "status"), &wait.handback, cleared) { + match run_wake::alert_wake(text(&item, "status"), &wait.handback, false) { Some(run_wake::AlertWake::Resume) => { wake_one(state, team_id, &item, "its alert fired again").await } - Some(run_wake::AlertWake::Close) => close_cleared(state, team_id, &item).await, - None => false, - } -} - -/// Closes a waiting alert run whose alert cleared by itself. -async fn close_cleared(state: &AppState, team_id: &str, item: &Item) -> bool { - let run_id = text(item, "run_id").to_string(); - let why = "the alert cleared by itself, so nothing is left to fix"; - let closed = state - .dynamo - .update_item() - .table_name(&state.config.runs_table_name) - .key("team_id", AttributeValue::S(team_id.to_string())) - .key("run_id", AttributeValue::S(run_id.clone())) - .update_expression( - "SET #status = :s, status_run_id = :sri, updated_at = :t, \ - progress_notes = list_append(if_not_exists(progress_notes, :empty), :n)", - ) - .condition_expression("#status = :waiting") - .expression_attribute_names("#status", "status") - .run_status( - ":s", - &common::run_ending::gate( - &run_id, - &common::run_ending::RunEnd::Stopped(common::run_ending::Stopped { - reason: common::run_ending::Stop::ClosedBy { - who: "CoderHelm".into(), - why: why.into(), - }, - tried: Default::default(), - }), - ), - ) - .expression_attribute_values(":waiting", AttributeValue::S(run_wake::WAITING.into())) - .expression_attribute_values(":empty", AttributeValue::L(vec![])) - .expression_attribute_values( - ":n", - AttributeValue::L(vec![AttributeValue::M(HashMap::from([ - ( - "message".to_string(), - AttributeValue::S(format!("Closed: {why}.")), - ), - ( - "timestamp".to_string(), - AttributeValue::S(chrono::Utc::now().to_rfc3339()), - ), - ]))]), - ) - .expression_attribute_values(":t", AttributeValue::S(chrono::Utc::now().to_rfc3339())) - .send() - .await; - if closed.is_ok() { - info!(run_id, "Alert cleared: its waiting run closed"); + _ => false, } - closed.is_ok() } #[cfg(test)] diff --git a/services/worker/src/main.rs b/services/worker/src/main.rs index 080a944fc..2426690aa 100644 --- a/services/worker/src/main.rs +++ b/services/worker/src/main.rs @@ -1164,7 +1164,7 @@ async fn handle_message_inner(state: Arc, message: models::WorkerMe passes::webhooks::run_waiting(&state, &msg).await; } models::WorkerMessage::ChangeWaitCheck(msg) => { - passes::change_wait::check_all(&state, Some(&msg.team_id)).await; + passes::change_wait::check_change(&state, &msg).await; } models::WorkerMessage::PrRecordsSync(msg) => { passes::pr_records::sync_message(&state, &msg).await; diff --git a/services/worker/src/passes/alert_episodes.rs b/services/worker/src/passes/alert_episodes.rs index 6c93b33ad..5ef5445c8 100644 --- a/services/worker/src/passes/alert_episodes.rs +++ b/services/worker/src/passes/alert_episodes.rs @@ -98,6 +98,16 @@ pub async fn run(state: &WorkerState, msg: AlertEpisodeCheckMessage) { match applied.decision { Decision::Cleared(ended) => { episodes::post_cleared(&posting, &msg.team_id, &ended).await; + // The recovery is final: its run waiting on a person closes the + // way a recovery posted at once closes it (the gateway's + // `run_wake::alert_delivery` takes the same path). + common::run_wake::alert_cleared( + &state.dynamo, + &state.config.runs_table_name, + &msg.team_id, + &common::run_wake::alert_ticket_id(&msg.fingerprint), + ) + .await; } Decision::Remind => { let Some(ep) = applied.episode else { return }; diff --git a/services/worker/src/passes/change_wait.rs b/services/worker/src/passes/change_wait.rs index 2ae5637fe..d67cc4f61 100644 --- a/services/worker/src/passes/change_wait.rs +++ b/services/worker/src/passes/change_wait.rs @@ -211,6 +211,23 @@ pub struct Checked { /// as "needs you" (closed without merging), or left waiting with its /// page saying why (the dependency's run stopped). pub async fn check_all(state: &WorkerState, team: Option<&str>) -> Checked { + check_scoped(state, team, "", 0).await +} + +/// A pull request of the team moved (a merge, a close, a reopen as GitHub +/// reports it): the team's waiting runs read their change again, and a run +/// stopped because this change closed goes back to waiting at once when it +/// is reopened (or on when it merged). The sweep is the backstop. +pub async fn check_change( + state: &WorkerState, + msg: &common::messages::ChangeWaitCheckMessage, +) -> Checked { + check_scoped(state, Some(&msg.team_id), &msg.repo, msg.pr).await +} + +/// [`check_all`], with the stopped runs read only for the change `repo` +/// `pr` that moved (empty and 0: every change). +async fn check_scoped(state: &WorkerState, team: Option<&str>, repo: &str, pr: u64) -> Checked { let mut out = Checked::default(); // Read to the last page either way: one team's waiting runs by the // status index, or every team's runs by key (a capped scan of the runs @@ -263,10 +280,9 @@ pub async fn check_all(state: &WorkerState, team: Option<&str>) -> Checked { } } // Runs that stopped because their change closed: reopened, they wait - // for it again; merged, they go on (the 15-minute sweep reads them). - if team.is_none() { - out.resumed += check_closed(state).await; - } + // for it again; merged, they go on (a pull request event for the team + // reads them at once; the 15-minute sweep reads every team's). + out.resumed += check_closed(state, team, repo, pr).await; info!( waiting = out.waiting, resumed = out.resumed, @@ -279,14 +295,23 @@ pub async fn check_all(state: &WorkerState, team: Option<&str>) -> Checked { /// Every run that stopped because the change it waited for closed: when /// that change is reopened the run waits for it again, and when it merged /// the run goes on. Returns how many went back. -async fn check_closed(state: &WorkerState) -> usize { +async fn check_closed(state: &WorkerState, team: Option<&str>, repo: &str, pr: u64) -> usize { let filter = super::team_runs::Filter { expr: "#s = :n AND attribute_exists(#w)", names: vec![("#s", "status"), ("#w", cw::FIELD)], values: vec![(":n", attr_s(common::run_wake::WAITING))], projection: None, }; - let items = super::team_runs::matching(state, "Runs whose change closed", &filter).await; + let items = match team { + Some(t) => match super::team_runs::of_team(state, t, &filter).await { + Ok(items) => items, + Err(e) => { + warn!(error = %e, "Runs whose change closed couldn't be listed"); + Vec::new() + } + }, + None => super::team_runs::matching(state, "Runs whose change closed", &filter).await, + }; let mut back = 0; for item in items { if s(&item, "status") != common::run_status::NEEDS_INPUT { @@ -302,6 +327,10 @@ async fn check_closed(state: &WorkerState) -> usize { let Some(dep) = Dependency::from_json(s(&item, cw::FIELD)) else { continue; }; + // An event reads only the runs of the change it reports. + if !cw::moved_is(&dep, repo, pr) { + continue; + } let Some((o, r)) = dep.repo.split_once('/') else { continue; }; diff --git a/services/worker/src/passes/incidents/bm_teams_never_cross.rs b/services/worker/src/passes/incidents/bm_teams_never_cross.rs index f4988d90c..2d58121a6 100644 --- a/services/worker/src/passes/incidents/bm_teams_never_cross.rs +++ b/services/worker/src/passes/incidents/bm_teams_never_cross.rs @@ -353,6 +353,10 @@ const CACHES: &[(&str, &str)] = &[ ("gateway/src/permissions.rs::ROUTES", "route table; no data"), ("gateway/src/routes/chat_work_prs.rs::CACHE", "URL, reused only on a 304 to the team's own token; repo checked against the team's repos first"), ("gateway/src/routes/github_webhook.rs::SEEN", "installation id; log throttle"), + ( + "gateway/src/routes/prs_overview.rs::OVERVIEW", + "installation id plus the team id, org, repo and window (read_key(installation_id, \"prs_overview##...\")); built only from that team's records, history and snapshots", + ), ("gateway/src/routes/prs.rs::LIST", "installation id plus the team id (read_key(installation_id, \"prs#\")); its rows keep only that team's records"), ("gateway/src/routes/roles.rs::CACHE", "(team, role)"), ("gateway/src/routes/run_checks.rs::TOKENS", "installation id"), diff --git a/services/worker/src/passes/incidents/wz_waits_go_on_by_themselves.rs b/services/worker/src/passes/incidents/wz_waits_go_on_by_themselves.rs index 0a2c1777a..88d71f525 100644 --- a/services/worker/src/passes/incidents/wz_waits_go_on_by_themselves.rs +++ b/services/worker/src/passes/incidents/wz_waits_go_on_by_themselves.rs @@ -255,7 +255,7 @@ fn a_limit_wait_wakes_when_the_limit_allows_runs_again() { fn a_reopened_change_takes_its_run_back() { assert!(!CHANGE_WAIT.contains("then press Retry")); assert!(CHANGE_WAIT.contains("action: cw::closed_action(&dep),")); - assert!(CHANGE_WAIT.contains("out.resumed += check_closed(state).await;")); + assert!(CHANGE_WAIT.contains("out.resumed += check_closed(state, team, repo, pr).await;")); assert_eq!( common::change_wait::after_close(Some(("open", false))), Some(common::change_wait::AfterClose::Reopened) diff --git a/services/worker/src/passes/incidents/xx_waits_never_outlive_their_event.rs b/services/worker/src/passes/incidents/xx_waits_never_outlive_their_event.rs new file mode 100644 index 000000000..42bc39751 --- /dev/null +++ b/services/worker/src/passes/incidents/xx_waits_never_outlive_their_event.rs @@ -0,0 +1,126 @@ +//! xx. Two waits went on after what they waited for had happened. A run +//! stopped because the change it built on closed was told that reopening +//! the change takes it back to waiting by itself. The change was reopened, +//! but only the 15-minute sweep read stopped runs: the reopen webhook went +//! to the review triggers and returned, and the check a pull request event +//! sent skipped stopped runs. On an alert route that waits out a quiet +//! window before posting the recovery, the run that waited on a person for +//! that alert stayed waiting after the recovery posted: only a recovery +//! posted at once closed it, and the later post (the worker's episode +//! check) never reached the run. +//! +//! Guarantees: a pull request closed or reopened sends the team's change +//! check before any return a reopen reaches, naming the change, and that +//! check reads the runs stopped by that change's close (the sweep stays the +//! backstop for every team). A recovery closes its waiting run through one +//! path, `common::run_wake::alert_cleared`, whether it posts at once (the +//! gateway's `alert_delivery`) or after the quiet window (the worker's +//! episode check). + +use common::change_wait::{self as cw, Dependency}; +use common::run_wake::{self, AlertWake}; + +const GITHUB_WEBHOOK: &str = include_str!("../../../../gateway/src/routes/github_webhook.rs"); +const GATEWAY_WAKE: &str = include_str!("../../../../gateway/src/routes/run_wake.rs"); +const COMMON_WAKE: &str = include_str!("../../../../common/src/run_wake.rs"); +const CHANGE_WAIT: &str = include_str!("../change_wait.rs"); +const EPISODES: &str = include_str!("../alert_episodes.rs"); +const MAIN: &str = include_str!("../../main.rs"); + +fn fn_src<'a>(src: &'a str, head: &str) -> &'a str { + let start = src.find(head).unwrap_or_else(|| panic!("{head} is gone")); + let rest = &src[start..]; + let end = [ + "\nfn ", + "\npub fn ", + "\nasync fn ", + "\npub async fn ", + "\n#[cfg(test)]", + ] + .iter() + .filter_map(|h| rest[1..].find(h).map(|i| i + 1)) + .min() + .unwrap_or(rest.len()); + &rest[..end] +} + +/// The reopen GitHub reports reaches the run stopped by that change's close +/// at once; the sweep is only the backstop. +#[test] +fn a_reopened_change_takes_its_run_back_when_github_reports_it() { + assert!(cw::event_moves_change("reopened")); + assert!(cw::event_moves_change("closed")); + let dep = Dependency { + ticket: "WEB-7".into(), + repo: "acme/bookstore-web".into(), + pr: 12, + ..Default::default() + }; + assert!(cw::moved_is(&dep, "acme/bookstore-web", 12)); + assert!(!cw::moved_is(&dep, "acme/bookstore-web", 99)); + assert!(cw::moved_is(&dep, "", 0), "the sweep reads every change"); + assert_eq!( + cw::after_close(Some(("open", false))), + Some(cw::AfterClose::Reopened) + ); + + // The webhook sends the check before the reopen returns to the review + // triggers. + let handler = GITHUB_WEBHOOK + .split("async fn handle_pull_request(") + .nth(1) + .unwrap(); + let check = handler + .find("change_wait_check(action, payload, team_id)") + .expect("the pull request handler sends the change check"); + assert!(check < handler.find("return handle_review_trigger(").unwrap()); + assert!(check < handler.find("if action != \"closed\"").unwrap()); + + // The worker's check reads the stopped runs of that team for that + // change, not only the sweep. + assert!(MAIN.contains("passes::change_wait::check_change(&state, &msg).await;")); + let scoped = fn_src(CHANGE_WAIT, "async fn check_scoped("); + assert!(scoped.contains("check_closed(state, team, repo, pr)")); + assert!(!scoped.contains("if team.is_none()")); + let closed = fn_src(CHANGE_WAIT, "async fn check_closed("); + assert!(closed.contains("super::team_runs::of_team(state, t, &filter)")); + assert!(closed.contains("cw::moved_is(&dep, repo, pr)")); + assert!(CHANGE_WAIT.contains("check_scoped(state, team, \"\", 0)")); +} + +/// A recovery posted after the quiet window closes the waiting run the +/// way a recovery posted at once does: one path. +#[test] +fn a_later_recovery_closes_its_waiting_run_through_the_same_path() { + for why in common::handback::HUMAN_ONLY { + assert_eq!( + run_wake::alert_wake(run_wake::WAITING, why.code(), true), + Some(AlertWake::Close), + "{why:?}" + ); + } + // Both posts end in the one close. + let gateway = fn_src(GATEWAY_WAKE, "pub async fn alert_delivery("); + assert!(gateway.contains("run_wake::alert_cleared(")); + assert!(!GATEWAY_WAKE.contains("async fn close_cleared(")); + let cleared = EPISODES + .split("Decision::Cleared(ended) =>") + .nth(1) + .unwrap(); + let cleared = &cleared[..cleared.find("Decision::Remind =>").unwrap()]; + assert!(cleared.contains("episodes::post_cleared(")); + assert!(cleared.contains("common::run_wake::alert_cleared(")); + assert!(cleared.contains("common::run_wake::alert_ticket_id(&msg.fingerprint)")); + // The close is written once, in common. + let shared = fn_src(COMMON_WAKE, "pub async fn alert_cleared("); + assert!(shared.contains("alert_wake(text(&item, \"status\"), &wait.handback, true)")); + assert!(shared.contains("close_cleared(dynamo, runs_table, team_id, &item)")); + assert_eq!( + COMMON_WAKE.matches("pub async fn close_cleared(").count(), + 1 + ); + // The gateway's ticket for an alert is the one the worker looks up. + let alerts = include_str!("../../../../gateway/src/routes/alerts.rs"); + let ticket = fn_src(alerts, "pub fn ticket_id("); + assert!(ticket.contains("common::run_wake::alert_ticket_id(fingerprint)")); +} diff --git a/services/worker/src/passes/incidents/xz_org_overview_facts_only.rs b/services/worker/src/passes/incidents/xz_org_overview_facts_only.rs new file mode 100644 index 000000000..277bd7bf2 --- /dev/null +++ b/services/worker/src/passes/incidents/xz_org_overview_facts_only.rs @@ -0,0 +1,459 @@ +//! xz. A leader opened the pull requests page to understand the state of +//! the org's pull requests and found only a list: no summary of what was +//! stuck, on whom, or whether that was usual. The overview above the list +//! answers that, and it is the one place a page could rank people, write a +//! number nothing computed, or mix two teams' pull requests. +//! +//! Guarantees: +//! - no per-person ranking, count or duration is ever returned; a GitHub +//! login appears only as the owner of one item in "Needs attention"; +//! - every number in the summary is a computed fact's value; +//! - one team never sees another's data: every read is keyed by the +//! session's team and the cache by the installation and the team; +//! - an org with no CoderHelm pull requests still gets the whole overview; +//! - the Stale tile and the Stale panel's headline are one number, and no +//! rate is shown on fewer than 10 events. + +use aws_sdk_dynamodb::types::AttributeValue; +use common::pr_history::{Backfill, History}; +use common::pr_overview::{self, Input, Open, Sla}; +use common::pr_record::{self, Item, PrRecord, RequestEvent, ReviewEvent}; +use common::pr_view::{self, Joins}; +use serde_json::Value; +use std::collections::BTreeMap; + +const NOW: i64 = 1_800_000_000; +const H: i64 = 3_600; +const D: i64 = 86_400; +const PEOPLE: [&str; 4] = ["octocat", "mara", "theo", "jun"]; + +fn item(team: &str, rec: &PrRecord) -> Item { + let mut i = Item::new(); + i.insert("pk".into(), AttributeValue::S(team.into())); + i.insert( + "sk".into(), + AttributeValue::S(pr_record::record_sk(&rec.repo, rec.number)), + ); + i.insert( + "doc".into(), + AttributeValue::S(serde_json::to_string(rec).expect("record")), + ); + i +} + +fn src(path: &str) -> String { + let root = concat!(env!("CARGO_MANIFEST_DIR"), "/.."); + std::fs::read_to_string(format!("{root}/{path}")).unwrap_or_else(|e| panic!("{path}: {e}")) +} + +/// An open pull request by a person, waiting on a review by another. +fn open_pr(repo: &str, n: u64, author: &str, reviewer: &str, ready_ago: i64) -> PrRecord { + let mut r = PrRecord::new(repo, n); + r.known = true; + r.title = format!("Show stock per warehouse, part {n}"); + r.author = author.into(); + r.created_at = NOW - ready_ago - H; + r.ready_at = NOW - ready_ago; + r.additions = 120; + r.deletions = 30; + r.requested = vec![reviewer.into()]; + r.request_log.push(RequestEvent { + who: reviewer.into(), + at: NOW - ready_ago, + removed_at: 0, + }); + r.last_author_action_at = NOW - ready_ago; + r.people.insert(author.into(), vec!["author".into()]); + r.people.insert(reviewer.into(), vec!["requested".into()]); + r +} + +/// A merged pull request by a person, reviewed by another. +fn merged(repo: &str, n: u64, author: &str, reviewer: &str, ready_ago: i64, took: i64) -> History { + History { + repo: repo.into(), + number: n, + title: format!("Cache the bestseller list, part {n}"), + author: author.into(), + author_type: if pr_record::is_coderhelm(author) { + "coderhelm".to_string() + } else { + "person".into() + }, + created_at: NOW - ready_ago - H, + ready_at: NOW - ready_ago, + first_human_review_at: NOW - ready_ago + took / 2, + final_approval_at: NOW - ready_ago + took - H, + merged: true, + merged_at: NOW - ready_ago + took, + closed_at: NOW - ready_ago + took, + merged_by: author.into(), + additions: 80, + deletions: 20, + coverage: "human_approved".into(), + review_log: vec![ReviewEvent { + who: reviewer.into(), + state: "APPROVED".into(), + at: NOW - ready_ago + took - H, + human: true, + ..Default::default() + }], + request_log: vec![RequestEvent { + who: reviewer.into(), + at: NOW - ready_ago, + removed_at: 0, + }], + ..Default::default() + } +} + +struct World { + open: Vec, + hist: Vec, + backfill: Vec, +} + +/// The bookstore's org: people's pull requests only, unless `coderhelm`. +fn world(team: &str, coderhelm: bool) -> World { + let mut recs = Vec::new(); + for n in 0..24u64 { + let author = PEOPLE[(n % 4) as usize]; + let reviewer = PEOPLE[((n + 1) % 4) as usize]; + let repo = ["acme/web", "acme/checkout", "acme/api"][(n % 3) as usize]; + recs.push(open_pr( + repo, + 100 + n, + author, + reviewer, + (n as i64 + 1) * 9 * H, + )); + } + if coderhelm { + recs.push(open_pr("acme/web", 300, "coderhelm[bot]", "mara", 2 * D)); + } + let items: Vec = recs.iter().map(|r| item(team, r)).collect(); + let rows = pr_view::rows(team, &items, &Joins::default(), None, NOW); + let open = pr_view::records_of(team, &items) + .into_iter() + .filter_map(|rec| { + let k = format!("{}#{}", rec.repo, rec.number); + let row = rows.iter().find(|r| r.key == k)?.clone(); + Some(Open { rec, row }) + }) + .collect(); + let mut hist = Vec::new(); + for n in 0..60u64 { + let author = PEOPLE[(n % 4) as usize]; + let reviewer = PEOPLE[((n + 2) % 4) as usize]; + let repo = ["acme/web", "acme/checkout", "acme/api"][(n % 3) as usize]; + hist.push(merged( + repo, + 1 + n, + author, + reviewer, + (n as i64 + 2) * D, + (n as i64 % 7 + 1) * 6 * H, + )); + } + let backfill = vec![Backfill { + owner: "acme".into(), + done: true, + months_read: 14, + repos: BTreeMap::from([ + ("acme/web".into(), 20), + ("acme/checkout".into(), 20), + ("acme/api".into(), 20), + ]), + ..Default::default() + }]; + World { + open, + hist, + backfill, + } +} + +fn overview(w: &World) -> Value { + let repo_snaps = BTreeMap::new(); + pr_overview::build(&Input { + open: &w.open, + hist: &w.hist, + snaps: &[], + repo_snaps: &repo_snaps, + backfill: &w.backfill, + org: Some("acme"), + repo: None, + window_days: 7, + sla: Sla::default(), + now: NOW, + }) +} + +/// Every string and key in the answer, with its path. +fn strings(v: &Value, path: &str, out: &mut Vec<(String, String)>) { + match v { + Value::String(s) => out.push((path.to_string(), s.clone())), + Value::Array(a) => a + .iter() + .enumerate() + .for_each(|(i, x)| strings(x, &format!("{path}[{i}]"), out)), + Value::Object(m) => { + for (k, x) in m { + out.push((format!("{path}.{k}#key"), k.clone())); + strings(x, &format!("{path}.{k}"), out); + } + } + _ => {} + } +} + +#[test] +fn no_person_is_ranked_counted_or_timed() { + let o = overview(&world("TEAM#bookstore", true)); + let mut all = Vec::new(); + strings(&o, "", &mut all); + for (path, s) in &all { + for p in PEOPLE { + let named = s + .to_ascii_lowercase() + .split(|c: char| !c.is_ascii_alphanumeric() && c != '-') + .any(|w| w == p); + if named { + // The only place: the owner of one item that needs attention. + assert!( + path.starts_with(".summary.attention[") && path.ends_with(".owner"), + "{p} appears at {path}: {s}" + ); + } + } + } + // Concentration is a share and a count of reviewers, never a list. + let c = &o["review"]["concentration"]; + assert!(c["top_share"].is_number() || c["top_share"].is_null()); + assert!(c.get("reviewers").is_some_and(Value::is_number)); + assert!( + c["where"].is_null() + || c["where"] + .as_array() + .is_some_and(|a| a.iter().all(|x| x.get("repo").is_some())) + ); +} + +#[test] +fn every_number_in_the_summary_is_a_fact() { + for coderhelm in [true, false] { + let o = overview(&world("TEAM#bookstore", coderhelm)); + let nums = pr_overview::summary_numbers(&o); + assert!(!nums.is_empty(), "the summary carries numbers"); + let facts = o["facts"].as_array().expect("facts"); + for (fact, n) in nums { + assert!( + facts + .iter() + .any(|f| f["id"] == fact && f["value"].as_f64() == Some(n)), + "summary number {n} ({fact}) is not a fact" + ); + } + // No digit is written outside a number part: words carry only + // pull request references (#318), never a count or a duration. + let s = &o["summary"]; + let mut lines: Vec<&Value> = vec![ + &s["verdict"]["parts"], + &s["stability"]["parts"], + &s["coderhelm"]["parts"], + &s["changed"]["parts"], + &s["quiet"]["parts"], + ]; + for a in s["attention"].as_array().unwrap() { + lines.push(&a["parts"]); + } + for line in lines.into_iter().filter_map(Value::as_array) { + for p in line { + if let Some(t) = p.get("t").and_then(Value::as_str) { + let mut words = String::new(); + let mut ref_digits = false; + for c in t.chars() { + if c == '#' { + ref_digits = true; + } else if !c.is_ascii_digit() { + ref_digits = false; + } + if !(ref_digits && c.is_ascii_digit()) { + words.push(c); + } + } + assert!( + !words + .replace("p85", "") + .replace("8-week", "") + .chars() + .any(|c| c.is_ascii_digit()), + "a number outside a fact: {t}" + ); + } + } + } + // Always one stability line and one CoderHelm line. + assert!(!s["stability"]["parts"].as_array().unwrap().is_empty()); + assert!(!s["coderhelm"]["parts"].as_array().unwrap().is_empty()); + } +} + +#[test] +fn one_team_never_sees_another() { + let mine = open_pr("acme/web", 1, "mara", "theo", D); + let mut theirs = open_pr("acme/web", 2, "jun", "theo", D); + theirs.title = "Another team's pull request".into(); + let items = vec![item("TEAM#a", &mine), item("TEAM#b", &theirs)]; + let recs = pr_view::records_of("TEAM#a", &items); + assert_eq!(recs.len(), 1); + let rows = pr_view::rows("TEAM#a", &items, &Joins::default(), None, NOW); + let open: Vec = recs + .into_iter() + .map(|rec| { + let row = rows + .iter() + .find(|r| r.number == rec.number) + .unwrap() + .clone(); + Open { rec, row } + }) + .collect(); + let repo_snaps = BTreeMap::new(); + let o = pr_overview::build(&Input { + open: &open, + hist: &[], + snaps: &[], + repo_snaps: &repo_snaps, + backfill: &[], + org: Some("acme"), + repo: None, + window_days: 7, + sla: Sla::default(), + now: NOW, + }); + assert!(!o.to_string().contains("Another team's")); + assert_eq!(o["aging"]["total"], 1); + + // The route reads only the session's team, and the cache names the + // installation and the team. + // Compared without whitespace, so formatting never hides a read. + let flat = |t: &str| t.chars().filter(|c| !c.is_whitespace()).collect::(); + let r = flat(&src("gateway/src/routes/prs_overview.rs")); + assert!(r.contains(&flat("let team_id = claims.team_id.as_str();"))); + assert!(r.contains(&flat("read_all(&state, team_id)"))); + assert!(r.contains(&flat("pr_view::records_of(team_id, items)"))); + assert!(r.contains(&flat( + "pr_history::all_since(&state.dynamo, table, team_id," + ))); + assert!(r.contains(&flat( + "pr_history::snapshots_of(&state.dynamo, table, team_id," + ))); + assert!(r.contains(&flat( + "items_under(&state, team_id, pr_history::BACKFILL_PREFIX)" + ))); + assert!( + r.contains(&flat("read_key(installation_id,")) + && r.contains(&flat("prs_overview#{team_id}#")) + ); + assert!(!r.contains(&flat("q.team")) && !r.contains(&flat("team: Option"))); + let perms = src("gateway/src/permissions.rs"); + let view = &perms[perms.find("\"prs::list_prs\"").expect("view list")..]; + assert!( + view[..400].contains("\"prs_overview::get_overview\""), + "the overview is under \"view\"" + ); + let teams = src("worker/src/passes/incidents/bm_teams_never_cross.rs"); + assert!(teams.contains("gateway/src/routes/prs_overview.rs::OVERVIEW")); +} + +#[test] +fn an_org_with_no_coderhelm_pull_requests_gets_the_whole_overview() { + let o = overview(&world("TEAM#bookstore", false)); + assert_eq!(o["aging"]["total"], 24); + assert!( + o["thresholds"]["cycle"].is_object(), + "percentiles from people's merges" + ); + assert_eq!(o["repos"].as_array().unwrap().len(), 3); + assert!(o["review"]["coverage"]["merged"].as_u64().unwrap() > 0); + assert!(o["review"]["first_review_human"].is_object()); + assert_eq!(o["coderhelm"]["author"]["opened"], 0); + let ch: String = o["summary"]["coderhelm"]["parts"] + .as_array() + .unwrap() + .iter() + .filter_map(|p| p.get("t").and_then(Value::as_str)) + .collect(); + assert!(ch.contains("No PRs from CoderHelm"), "{ch}"); + assert!(o["summary"]["verdict"]["parts"] + .as_array() + .is_some_and(|a| !a.is_empty())); +} + +#[test] +fn the_stale_tile_is_the_stale_panels_headline_and_rates_need_ten() { + let w = world("TEAM#bookstore", true); + let o = overview(&w); + let tile = o["summary"]["tiles"] + .as_array() + .unwrap() + .iter() + .find(|t| t["fact"] == "stale") + .unwrap() + .clone(); + assert_eq!(tile["value"], o["stale"]["stale"]); + assert_eq!(tile["value"], o["conditions"]["stale"]["count"]); + + // Under 10 merges, no rate. + let few = World { + open: Vec::new(), + hist: w + .hist + .into_iter() + .take(3) + .map(|mut h| { + h.merged_at = NOW - H; + h.closed_at = NOW - H; + h + }) + .collect(), + backfill: w.backfill, + }; + let o = overview(&few); + assert!(o["review"]["depth"]["merged_without_review"].is_null()); + assert!(o["summary"]["tiles"][2]["value"].is_null()); + assert!(o["coderhelm"]["author"]["merge_rate"].is_null()); +} + +#[test] +fn what_isnt_stored_is_named_never_estimated() { + let o = overview(&world("TEAM#bookstore", true)); + let missing: Vec<&str> = o["missing"] + .as_array() + .unwrap() + .iter() + .filter_map(|m| m["path"].as_str()) + .collect(); + for path in [ + "failures.main_red", + "conditions.blocked_by_main", + "review.funnel", + "coderhelm.exceptions.cost_per_merged", + ] { + assert!(missing.contains(&path), "{path} is named in missing"); + } + assert!(o["failures"]["main_red"].is_null()); + assert!(o["conditions"]["blocked_by_main"].is_null()); + // Before the backfill finishes, the history is young and says so. + let mut w = world("TEAM#bookstore", true); + w.backfill[0].done = false; + let o = overview(&w); + assert_eq!(o["history"]["young"], true); + assert_eq!(o["history"]["backfill"]["done"], false); + assert!(o["missing"] + .as_array() + .unwrap() + .iter() + .any(|m| m["path"] == "history")); +} From 43e3196037c4d23dc3a83147bc33d56bba56d00d Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 17:18:00 -0500 Subject: [PATCH 06/19] Answer the review: the gate never waits on what GitHub does not require, the sync never undoes events, history is never thinned The repository's approval rule is GitHub's own review decision and the team's rule is a person's approval; a review no rule requires is named, never a hold. The sync never reopens a closed record, yields to events newer than its read, replaces the reviews and requests it lists, and marks lists cut by their page size. History rows merge by source, so the backfill never thins a row written from events. The review decision is worked out at review events and used for bypass only when fresh. Stacks join within one repository, and the detail decides with the list's own linked records. --- docs/pull-requests.md | 1 + docs/pull-requests/api_contract.md | 8 + services/common/src/pr_history.rs | 168 ++++-- services/common/src/pr_needs.rs | 111 +++- services/common/src/pr_record.rs | 570 ++++++++++++++---- services/common/src/pr_view.rs | 97 ++- services/gateway/src/routes/prs.rs | 55 +- services/worker/src/passes/await_merge.rs | 27 +- .../xw_every_open_pr_has_one_state.rs | 32 +- services/worker/src/passes/pr_records.rs | 6 +- 10 files changed, 824 insertions(+), 251 deletions(-) diff --git a/docs/pull-requests.md b/docs/pull-requests.md index ea343c375..9b241d073 100644 --- a/docs/pull-requests.md +++ b/docs/pull-requests.md @@ -8,6 +8,7 @@ One settings-table item per pull request (`pk` = team id, `sk = PRREC# &'static str { .review_log .iter() .any(|v| !v.human && v.state == "APPROVED" && is_bot(&v.who)); - let held = matches!( - r.review_decision.as_deref(), - Some("REVIEW_REQUIRED") | Some("CHANGES_REQUESTED") - ); + // GitHub's decision counts only when it was read or worked out after + // the last review and request; a stale one never names a bypass. + let held = r.decision_fresh() + && matches!( + r.review_decision.as_deref(), + Some("REVIEW_REQUIRED") | Some("CHANGES_REQUESTED") + ); if human && held && r.codeowners_required { "non_owner_on_owned" } else if human { @@ -178,16 +185,21 @@ pub fn bypass_of(r: &PrRecord) -> Option { } let f = r.facts(); let (failing, _) = f.checks.blocking(); - if matches!(r.review_decision.as_deref(), Some("CHANGES_REQUESTED")) { + // The review decision and GitHub's merge state come from the sync or + // are worked out at each review event: a decision older than the last + // review or request says nothing about the merge, so no bypass is + // named from it. + let fresh = r.decision_fresh(); + if fresh && matches!(r.review_decision.as_deref(), Some("CHANGES_REQUESTED")) { Some("merged with changes requested".into()) - } else if matches!(r.review_decision.as_deref(), Some("REVIEW_REQUIRED")) { + } else if fresh && matches!(r.review_decision.as_deref(), Some("REVIEW_REQUIRED")) { Some("merged before the required review".into()) } else if !failing.is_empty() && !f.checks.required.is_empty() { Some(format!( "merged with required checks failing: {}", failing.join(", ") )) - } else if r.merge_state == "blocked" { + } else if fresh && r.synced_at >= r.decision_at && r.merge_state == "blocked" { Some("merged while the branch's rules blocked it".into()) } else { None @@ -257,6 +269,7 @@ impl History { drift_overlap: r.drift_overlap, run_outcome: String::new(), stop_reason: String::new(), + source: "events".into(), } } @@ -598,18 +611,7 @@ pub async fn load_backfill( team_id: &str, owner: &str, ) -> Result, Err> { - let out = dynamo - .get_item() - .table_name(table) - .key("pk", AttributeValue::S(team_id.into())) - .key("sk", AttributeValue::S(backfill_sk(owner))) - .send() - .await?; - Ok(out - .item() - .and_then(|i| i.get("doc")) - .and_then(|v| v.as_s().ok()) - .and_then(|d| serde_json::from_str(d).ok())) + pr_record::get_doc(dynamo, table, team_id, &backfill_sk(owner)).await } pub async fn save_backfill( @@ -633,16 +635,63 @@ pub async fn save_backfill( pub fn history_of_node(repo: &str, node: &serde_json::Value, now: i64) -> Option { let number = node["number"].as_u64()?; let mut r = PrRecord::new(repo, number); - r.apply_node(node, now); - (!r.is_open()).then(|| History::from_record(&r)) + r.apply_node(node, now, now); + (!r.is_open()).then(|| History { + source: "search".into(), + ..History::from_record(&r) + }) } // ─── Storage ──────────────────────────────────────────────────────────────── type Err = Box; -/// Write a closed pull request's history (again, when it closes again). -/// A revert or follow-up already recorded on the row is kept. +fn empty(v: &serde_json::Value) -> bool { + match v { + serde_json::Value::Null => true, + serde_json::Value::String(s) => s.is_empty(), + serde_json::Value::Number(n) => n.as_f64() == Some(0.0), + serde_json::Value::Array(a) => a.is_empty(), + serde_json::Value::Object(o) => o.is_empty(), + serde_json::Value::Bool(b) => !b, + } +} + +/// One row out of the stored one and a new one, never thinner than +/// either. The row from events wins over the search's (it holds the change +/// log, the runs and the logs the search can't see); between two of the +/// same source the newer wins. Every field the winner left empty is taken +/// from the other, and revert and follow-up links are kept from both. +pub fn merge(new: &History, old: &History) -> History { + let new_wins = !(old.source == "events" && new.source == "search"); + let (win, other) = if new_wins { (new, old) } else { (old, new) }; + let mut w = serde_json::to_value(win).unwrap_or_default(); + let o = serde_json::to_value(other).unwrap_or_default(); + if let (Some(w), Some(o)) = (w.as_object_mut(), o.as_object()) { + for (k, v) in o { + if w.get(k).is_none_or(empty) && !empty(v) { + w.insert(k.clone(), v.clone()); + } + } + } + let mut h: History = serde_json::from_value(w).unwrap_or_else(|_| win.clone()); + h.reverted_by = new.reverted_by.clone().or_else(|| old.reverted_by.clone()); + h.follow_ups = old.follow_ups.clone(); + for f in &new.follow_ups { + if !h + .follow_ups + .iter() + .any(|x| x.repo == f.repo && x.number == f.number) + { + h.follow_ups.push(f.clone()); + } + } + h +} + +/// Write a closed pull request's history (again, when it closes again), +/// merged with the stored row ([`merge`]): the backfill and the reconcile +/// never thin a row the gateway wrote from events. pub async fn put( dynamo: &DynamoClient, table: &str, @@ -650,15 +699,10 @@ pub async fn put( h: &History, now: i64, ) -> Result<(), Err> { - let mut h = h.clone(); - if let Some(old) = load(dynamo, table, team_id, &h.repo, h.number).await? { - h.reverted_by = h.reverted_by.or(old.reverted_by); - for f in old.follow_ups { - if !h.follow_ups.contains(&f) { - h.follow_ups.push(f); - } - } - } + let h = match load(dynamo, table, team_id, &h.repo, h.number).await? { + Some(old) => merge(h, &old), + None => h.clone(), + }; dynamo .put_item() .table_name(table) @@ -682,18 +726,7 @@ pub async fn load( repo: &str, number: u64, ) -> Result, Err> { - let out = dynamo - .get_item() - .table_name(table) - .key("pk", AttributeValue::S(team_id.into())) - .key("sk", AttributeValue::S(hist_sk(repo, number))) - .send() - .await?; - Ok(out - .item() - .and_then(|i| i.get("doc")) - .and_then(|v| v.as_s().ok()) - .and_then(|d| serde_json::from_str(d).ok())) + pr_record::get_doc(dynamo, table, team_id, &hist_sk(repo, number)).await } /// A merged pull request reverting or following up an earlier one. @@ -998,6 +1031,7 @@ mod tests { r.status = "merged".into(); r.merged_by = "coderhelm[bot]".into(); r.review_decision = Some("REVIEW_REQUIRED".into()); + r.decision_at = NOW; r.approvals_required = 1; let h = History::from_record(&r); assert_eq!(h.coverage, "bypass_or_exempt"); @@ -1025,4 +1059,50 @@ mod tests { }); assert_eq!(coverage_of(&r), "human_approved"); } + + #[test] + fn a_search_row_never_thins_a_row_written_from_events() { + let mut events = merged("acme/web", 9, DAY, 0); + events.source = "events".into(); + events.run_ids = vec!["run-1".into()]; + events.spans = vec![Span { + who: "person:mara".into(), + state: "needs_review".into(), + from: NOW - DAY, + turn: "person".into(), + stage: "first_review".into(), + }]; + events.coderhelm_role = "fixer".into(); + let mut search = merged("acme/web", 9, DAY, 0); + search.source = "search".into(); + search.title = "Shelf labels".into(); + search.coderhelm_role = "none".into(); + let m = merge(&search, &events); + assert_eq!(m.run_ids, vec!["run-1"]); + assert_eq!(m.spans.len(), 1); + assert_eq!(m.coderhelm_role, "fixer"); + assert_eq!(m.source, "events"); + assert_eq!( + m.title, "Shelf labels", + "an empty field is filled from the other row" + ); + } + + #[test] + fn a_stale_review_decision_never_names_a_bypass() { + let mut r = PrRecord::new("acme/web", 7); + r.author = "octocat".into(); + r.status = "merged".into(); + r.review_decision = Some("REVIEW_REQUIRED".into()); + r.decision_at = NOW - 3600; + r.review_log.push(ReviewEvent { + who: "mara".into(), + state: "APPROVED".into(), + at: NOW - 60, + human: true, + ..Default::default() + }); + assert_eq!(bypass_of(&r), None, "approved after the decision was read"); + assert_eq!(coverage_of(&r), "human_approved"); + } } diff --git a/services/common/src/pr_needs.rs b/services/common/src/pr_needs.rs index 573b37499..bbc69327a 100644 --- a/services/common/src/pr_needs.rs +++ b/services/common/src/pr_needs.rs @@ -472,6 +472,8 @@ pub struct Facts { pub threads_required: bool, pub open_threads: u32, pub thread_authors: Vec, + /// The sync read only the first conversations: more may be open. + pub threads_unread: bool, /// GitHub's auto-merge is on. pub auto_merge: bool, /// CoderHelm's auto-merge gate is armed on it: CoderHelm merges. @@ -511,6 +513,20 @@ fn names(list: &[String], max: usize) -> String { out.join(", ") } +/// Reviews asked for that no rule requires: said, never a hold. +fn optional_asks(f: &Facts) -> String { + let mut who: Vec = f.requested.clone(); + who.extend(f.requested_teams.iter().cloned()); + if who.is_empty() { + return String::new(); + } + format!( + " {} {} also asked to review; no rule waits on it.", + at(&who), + if who.len() == 1 { "is" } else { "are" } + ) +} + fn rule_tag(rule: Option) -> String { rule.map(|r| format!(" ({})", r.words())) .unwrap_or_default() @@ -869,27 +885,35 @@ fn decide_state(repo: &str, f: &Facts) -> Needs { } } } - // Approvals: the repository's rule, and the team's own rule when - // CoderHelm merges. - let (required, approval_rule) = if f.approvals_required > 0 { - (f.approvals_required, Some(Rule::RepoRule)) - } else if f.team_requires_approval { - (1, Some(Rule::TeamRule)) + // Approvals: GitHub's requirement and the team's own rule, apart, and + // never stricter than GitHub. GitHub's review decision is the authority + // on the repository's rule (it counts every approval that counts there, + // an app's included); without one, the rule's count against people's + // approvals stands in. A review someone is asked for but no rule + // requires never holds the merge. + let people = f.approved_by.len() as u32; + let repo_required = if f.approvals_required > 0 { + f.approvals_required } else if f.review_decision.as_deref() == Some("REVIEW_REQUIRED") { - (1, Some(Rule::RepoRule)) + 1 } else { - (0, None) + 0 + }; + let repo_have = match f.review_decision.as_deref() { + Some("APPROVED") => repo_required, + _ => people, }; - // GitHub's own decision is the authority on the repository's count. - let mut have = f.approved_by.len() as u32; - if f.review_decision.as_deref() == Some("APPROVED") && have > 0 { - have = have.max(required); - } let codeowner_gap = f.codeowners_required && f.review_decision.as_deref() == Some("REVIEW_REQUIRED") - && have >= required.max(1); - if have < required && !codeowner_gap { - let missing = required - have; + && repo_have >= repo_required.max(1); + let (missing, approval_rule) = if repo_have < repo_required && !codeowner_gap { + (repo_required - repo_have, Some(Rule::RepoRule)) + } else if f.team_requires_approval && people == 0 && !codeowner_gap { + (1, Some(Rule::TeamRule)) + } else { + (0, None) + }; + if missing > 0 { let words = merge_standing::approvals_words(missing); let asked: Vec = f .requested @@ -945,14 +969,15 @@ fn decide_state(repo: &str, f: &Facts) -> Needs { Some(Rule::Codeowners), ); } - if required == 0 && have == 0 && !f.requested.is_empty() { - let verb = if f.requested.len() == 1 { "is" } else { "are" }; + if f.threads_required && f.open_threads == 0 && f.threads_unread { return need( - State::NeedsReview, - format!("{} {verb} asked to review.", at(&f.requested)), - f.requested.iter().map(|p| person(p)).collect(), + State::Unknown, + "Not synced yet: the pull request has more conversations than the sync reads, \ + and the repo rule needs them resolved; the next event or sync settles it." + .into(), + vec![NOBODY.into()], since, - None, + Some(Rule::RepoRule), ); } if f.threads_required && f.open_threads > 0 { @@ -1050,8 +1075,9 @@ fn decide_state(repo: &str, f: &Facts) -> Needs { need( State::ReadyToMerge, format!( - "Ready to merge: every rule is met; {} merges it.", - author_words(f) + "Ready to merge: every rule is met; {} merges it.{}", + author_words(f), + optional_asks(f) ), author_from(f), since, @@ -1174,7 +1200,12 @@ pub fn checklist(f: &Facts) -> Vec { } else { (0, None) }; - let have = f.approved_by.len() as u32; + // GitHub's decision counts every approval that counts there. + let have = if f.review_decision.as_deref() == Some("APPROVED") { + (f.approved_by.len() as u32).max(f.approvals_required) + } else { + f.approved_by.len() as u32 + }; out.push(if !f.changes_requested_by.is_empty() { step( "approvals", @@ -1552,4 +1583,34 @@ mod tests { assert!(keys.iter().any(|x| x == k), "{k}"); } } + + #[test] + fn a_review_no_rule_requires_never_holds_the_merge() { + let mut f = ready(); + f.approvals_required = 0; + f.approved_by.clear(); + f.requested = vec!["mara".into()]; + let n = decide("acme/web", &f); + assert_eq!(n.state, State::ReadyToMerge, "{n:?}"); + assert!( + n.next.text.contains("no rule waits on it"), + "{}", + n.next.text + ); + } + + #[test] + fn githubs_decision_counts_every_approval_that_counts_there() { + // An app's approval counted toward the rule: GitHub says approved, + // and nothing here is stricter. + let mut f = ready(); + f.approved_by.clear(); + f.approvals_required = 1; + f.review_decision = Some("APPROVED".into()); + assert!(decide("acme/web", &f).state.is_ready()); + // The team's own rule still wants a person. + f.team_requires_approval = true; + let n = decide("acme/web", &f); + assert_eq!(n.next.rule, Some(Rule::TeamRule), "{n:?}"); + } } diff --git a/services/common/src/pr_record.rs b/services/common/src/pr_record.rs index e624318d8..4975e1e45 100644 --- a/services/common/src/pr_record.rs +++ b/services/common/src/pr_record.rs @@ -38,10 +38,28 @@ use crate::pr_needs::{self, Facts, Needs}; /// Sort-key prefix of every record. pub const SK_PREFIX: &str = "PRREC#"; -/// Pointer from a head commit to its pull request (`status` events). -pub const HEAD_PREFIX: &str = "PRRECHEAD#"; -/// Pointer from a branch to its pull request (`push` events). -pub const REF_PREFIX: &str = "PRRECREF#"; +/// The pointer items that find a pull request from an event that doesn't +/// name it. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Pointer { + /// Head commit to its pull request (`status` events). + Head, + /// Head branch to its pull request (`push` events to the branch). + Ref, + /// Base branch to each pull request based on it (`push` events to the + /// base: drift). One item per pull request. + Base, +} + +impl Pointer { + pub fn prefix(self) -> &'static str { + match self { + Pointer::Head => "PRRECHEAD#", + Pointer::Ref => "PRRECREF#", + Pointer::Base => "PRRECBASE#", + } + } +} /// How long a closed or merged pull request's record is kept. pub const CLOSED_KEEP_SECS: i64 = 3 * 86_400; /// How long a pointer item is kept after its last write. @@ -64,12 +82,9 @@ pub fn parse_sk(sk: &str) -> Option<(String, u64)> { Some((repo.to_string(), n.parse().ok()?)) } -pub fn head_sk(repo: &str, sha: &str) -> String { - format!("{HEAD_PREFIX}{repo}#{sha}") -} - -pub fn ref_sk(repo: &str, branch: &str) -> String { - format!("{REF_PREFIX}{repo}#{branch}") +/// A pointer's sort key: `key` is the commit or the branch. +pub fn pointer_sk(kind: Pointer, repo: &str, key: &str) -> String { + format!("{}{repo}#{key}", kind.prefix()) } /// A GitHub login is CoderHelm's own (its app, under any install's name). @@ -287,6 +302,9 @@ pub struct PrRecord { pub draft: bool, pub head_sha: String, pub head_ref: String, + /// The repository the head branch lives in (a fork's for a pull request + /// from a fork). + pub head_repo: String, pub base_ref: String, pub created_at: i64, /// When it was first ready for review: its creation when it never was @@ -307,6 +325,9 @@ pub struct PrRecord { /// and the commit it is on. pub coderhelm_verdict: Option<(String, String)>, pub review_decision: Option, + /// When the review decision was read (the sync) or worked out (a review + /// or review request event); 0 never. + pub decision_at: i64, pub approvals_required: u32, pub codeowners_required: bool, pub threads_required: bool, @@ -317,6 +338,10 @@ pub struct PrRecord { pub conflict: Option, /// GitHub's `mergeStateStatus` / `mergeable_state`, lower case. pub merge_state: String, + /// The sync's lists were cut short by their page size: the checks it + /// read are not all of them, and neither are the conversations. + pub checks_partial: bool, + pub threads_partial: bool, pub open_threads: u32, pub thread_authors: Vec, pub auto_merge: bool, @@ -569,6 +594,7 @@ impl PrRecord { .into(); self.new_head(pr["head"]["sha"].as_str().unwrap_or("")); self.head_ref = s(&pr["head"]["ref"]); + self.head_repo = s(&pr["head"]["repo"]["full_name"]); self.base_ref = s(&pr["base"]["ref"]); self.created_at = ts(&pr["created_at"]); self.updated_at = ts(&pr["updated_at"]).max(self.updated_at); @@ -734,6 +760,7 @@ impl PrRecord { }); bounded(&mut self.request_log); } + self.derive_decision(when); self.event(when, &sender, "reviewers", format!("asked {who} to review")) } "review_request_removed" => { @@ -754,6 +781,7 @@ impl PrRecord { { r.removed_at = when; } + self.derive_decision(when); self.event( when, &sender, @@ -897,6 +925,7 @@ impl PrRecord { (_, "CHANGES_REQUESTED") => "asked for changes".to_string(), _ => "commented in a review".to_string(), }; + self.derive_decision(when); self.event(when, &who, "review", words); self.event_at = now; true @@ -1077,6 +1106,62 @@ impl PrRecord { true } + /// GitHub's review decision as of a review or review request event, + /// worked out the way GitHub does from the reviews and the branch's + /// rule, so a merge right after an approval never reads a decision the + /// hourly sync read before it. Code owners can't be told from events: + /// with them required the decision keeps its last read and its time, so + /// it reads as stale rather than wrong. + fn derive_decision(&mut self, at: i64) { + if self + .reviews + .values() + .any(|r| r.state == "CHANGES_REQUESTED") + { + self.review_decision = Some("CHANGES_REQUESTED".into()); + self.decision_at = at; + return; + } + if self.codeowners_required { + return; + } + let approved = self + .reviews + .iter() + .filter(|(who, r)| r.state == "APPROVED" && !who.eq_ignore_ascii_case(&self.author)) + .count() as u32; + let decision = match (self.approvals_required, self.review_decision.as_deref()) { + // Nothing requires a review: GitHub reports no decision. + (0, None) => None, + // A rule the sync didn't name (a ruleset) requires one. + (0, Some(_)) => Some(if approved > 0 { + "APPROVED" + } else { + "REVIEW_REQUIRED" + }), + (n, _) => Some(if approved >= n { + "APPROVED" + } else { + "REVIEW_REQUIRED" + }), + }; + self.review_decision = decision.map(str::to_string); + self.decision_at = at; + } + + /// The review decision was read or worked out after the last review, + /// review request and push: bypass and coverage may rely on it. + pub fn decision_fresh(&self) -> bool { + let last = self + .review_log + .iter() + .map(|r| r.at) + .chain(self.request_log.iter().map(|r| r.at.max(r.removed_at))) + .max() + .unwrap_or(0); + self.decision_at > 0 && self.decision_at >= last + } + /// The head's checks as one word: `red`, `pending` or `green`. pub fn check_rollup(&self) -> &'static str { if self.checks.is_empty() { @@ -1182,8 +1267,30 @@ impl PrRecord { } /// Apply one pull request node from the sync's GraphQL search - /// ([`SEARCH_QUERY`]); it is the authority for everything it names. - pub fn apply_node(&mut self, n: &Value, now: i64) { + /// ([`SEARCH_QUERY`]), read at `read_at`. The search trails GitHub, so + /// it never reopens a record an event closed, and when an event reached + /// the record after the search was read it takes only what events never + /// carry (the review decision, the branch's rules, mergeability, + /// conversations, files). Lists it reads in full (reviews, review + /// requests) replace what the record held; a list cut short by its page + /// size is marked partial, never read as complete. False when it changed + /// nothing. + pub fn apply_node(&mut self, n: &Value, read_at: i64, now: i64) -> bool { + let node_open = !matches!(n["state"].as_str(), Some("MERGED") | Some("CLOSED")); + if self.known && !self.is_open() && node_open { + return false; + } + let events_newer = self.known && self.event_at > read_at; + if !events_newer { + self.take_node_events_part(n, now); + } + self.take_node_sync_part(n, read_at, now); + true + } + + /// What events also carry: identity, state, head, labels, requests, + /// each person's latest review and the checks. + fn take_node_events_part(&mut self, n: &Value, now: i64) { self.known = true; self.title = s(&n["title"]); self.url = s(&n["url"]); @@ -1206,9 +1313,123 @@ impl PrRecord { self.new_head(&head); self.checks_sha = self.head_sha.clone(); self.head_ref = s(&n["headRefName"]); + self.head_repo = s(&n["headRepository"]["nameWithOwner"]); self.base_ref = s(&n["baseRefName"]); self.created_at = ts(&n["createdAt"]); self.updated_at = ts(&n["updatedAt"]); + if let Some(t) = [ts(&n["mergedAt"]), ts(&n["closedAt"])] + .into_iter() + .find(|t| *t > 0) + { + self.closed_at = t; + } + if let Some(by) = n["mergedBy"]["login"].as_str() { + self.merged_by = by.to_string(); + } + self.additions = n["additions"].as_u64().unwrap_or(0) as u32; + self.deletions = n["deletions"].as_u64().unwrap_or(0) as u32; + self.labels = n["labels"]["nodes"] + .as_array() + .into_iter() + .flatten() + .map(|l| s(&l["name"])) + .collect(); + self.requested.clear(); + self.requested_teams.clear(); + for r in n["reviewRequests"]["nodes"] + .as_array() + .into_iter() + .flatten() + { + let rv = &r["requestedReviewer"]; + if let Some(l) = rv["login"].as_str() { + push_unique(&mut self.requested, l); + } else if let Some(slug) = rv["slug"].as_str() { + let t = format!("{}/{slug}", self.org()); + push_unique(&mut self.requested_teams, &t); + } + } + for r in self.requested.clone() { + self.role(&r, "requested"); + } + // Each person's latest review that took a side, as GitHub has it + // now: a review dismissed or gone leaves the record too. + self.reviews.clear(); + self.coderhelm_verdict = None; + for r in n["latestOpinionatedReviews"]["nodes"] + .as_array() + .into_iter() + .flatten() + { + let who = login(&r["author"]); + if who.is_empty() { + continue; + } + let state = s(&r["state"]); + let sha = s(&r["commit"]["oid"]); + if is_coderhelm(&who) { + let v = match state.as_str() { + "APPROVED" => "APPROVE", + "CHANGES_REQUESTED" => "REQUEST_CHANGES", + _ => "COMMENT", + }; + self.coderhelm_verdict = Some((v.into(), sha)); + } else if state != "DISMISSED" { + self.reviews.insert( + who.clone(), + Review { + state, + sha, + at: ts(&r["submittedAt"]), + }, + ); + } + self.role(&who, "reviewer"); + } + let rollup = &n["commits"]["nodes"][0]["commit"]["statusCheckRollup"]["contexts"]; + if let Some(list) = rollup["nodes"].as_array() { + let partial = rollup["pageInfo"]["hasNextPage"].as_bool() == Some(true); + // A list cut short keeps the checks events reported beside it. + if !partial { + self.checks.clear(); + } + self.checks_partial = partial; + for c in list.iter().take(MAX_CHECKS) { + let (name, check) = if c["__typename"] == "StatusContext" { + let (status, concl) = match c["state"].as_str() { + Some("PENDING") | Some("EXPECTED") => ("in_progress", ""), + Some("SUCCESS") => ("completed", "success"), + Some("FAILURE") => ("completed", "failure"), + _ => ("completed", "error"), + }; + ( + s(&c["context"]), + Check { + status: status.into(), + conclusion: concl.into(), + at: now, + }, + ) + } else { + ( + s(&c["name"]), + Check { + status: s(&c["status"]).to_ascii_lowercase(), + conclusion: s(&c["conclusion"]).to_ascii_lowercase(), + at: now, + }, + ) + }; + if !name.is_empty() { + self.checks.insert(name, check); + } + } + } + } + + /// What only the search carries. + fn take_node_sync_part(&mut self, n: &Value, read_at: i64, now: i64) { + self.known = true; let files: Vec = n["files"]["nodes"] .as_array() .into_iter() @@ -1222,15 +1443,6 @@ impl PrRecord { let (category, severity) = category_of(&self.author, &self.labels, &self.title); self.category = category.into(); self.severity = severity.into(); - let closed = [ts(&n["mergedAt"]), ts(&n["closedAt"])] - .into_iter() - .find(|t| *t > 0); - if let Some(t) = closed { - self.closed_at = t; - } - if let Some(by) = n["mergedBy"]["login"].as_str() { - self.merged_by = by.to_string(); - } // Its timeline: when it left draft, and every review request. let mut requests: Vec = Vec::new(); for t in n["timelineItems"]["nodes"].as_array().into_iter().flatten() { @@ -1292,62 +1504,6 @@ impl PrRecord { self.review_log.sort_by_key(|r| r.at); bounded(&mut self.review_log); } - self.additions = n["additions"].as_u64().unwrap_or(0) as u32; - self.deletions = n["deletions"].as_u64().unwrap_or(0) as u32; - self.labels = n["labels"]["nodes"] - .as_array() - .into_iter() - .flatten() - .map(|l| s(&l["name"])) - .collect(); - self.requested.clear(); - self.requested_teams.clear(); - for r in n["reviewRequests"]["nodes"] - .as_array() - .into_iter() - .flatten() - { - let rv = &r["requestedReviewer"]; - if let Some(l) = rv["login"].as_str() { - push_unique(&mut self.requested, l); - } else if let Some(slug) = rv["slug"].as_str() { - let t = format!("{}/{slug}", self.org()); - push_unique(&mut self.requested_teams, &t); - } - } - for r in self.requested.clone() { - self.role(&r, "requested"); - } - for r in n["latestOpinionatedReviews"]["nodes"] - .as_array() - .into_iter() - .flatten() - { - let who = login(&r["author"]); - if who.is_empty() { - continue; - } - let state = s(&r["state"]); - let sha = s(&r["commit"]["oid"]); - if is_coderhelm(&who) { - let v = match state.as_str() { - "APPROVED" => "APPROVE", - "CHANGES_REQUESTED" => "REQUEST_CHANGES", - _ => "COMMENT", - }; - self.coderhelm_verdict = Some((v.into(), sha)); - } else { - self.reviews.insert( - who.clone(), - Review { - state, - sha, - at: ts(&r["submittedAt"]), - }, - ); - } - self.role(&who, "reviewer"); - } for p in n["participants"]["nodes"].as_array().into_iter().flatten() { let l = login(p); if !self.people.contains_key(&l) && !l.is_empty() { @@ -1355,6 +1511,7 @@ impl PrRecord { } } self.review_decision = n["reviewDecision"].as_str().map(str::to_string); + self.decision_at = read_at; self.conflict = match n["mergeable"].as_str() { Some("CONFLICTING") => Some(true), Some("MERGEABLE") => Some(false), @@ -1381,9 +1538,10 @@ impl PrRecord { .map(s) .collect(); } + let threads = &n["reviewThreads"]; let mut open = 0; let mut authors = Vec::new(); - for t in n["reviewThreads"]["nodes"].as_array().into_iter().flatten() { + for t in threads["nodes"].as_array().into_iter().flatten() { if t["isResolved"].as_bool() == Some(false) { open += 1; let a = login(&t["comments"]["nodes"][0]["author"]); @@ -1392,41 +1550,7 @@ impl PrRecord { } self.open_threads = open; self.thread_authors = authors; - let contexts = - &n["commits"]["nodes"][0]["commit"]["statusCheckRollup"]["contexts"]["nodes"]; - if let Some(list) = contexts.as_array() { - self.checks.clear(); - for c in list.iter().take(MAX_CHECKS) { - let (name, check) = if c["__typename"] == "StatusContext" { - let (status, concl) = match c["state"].as_str() { - Some("PENDING") | Some("EXPECTED") => ("in_progress", ""), - Some("SUCCESS") => ("completed", "success"), - Some("FAILURE") => ("completed", "failure"), - _ => ("completed", "error"), - }; - ( - s(&c["context"]), - Check { - status: status.into(), - conclusion: concl.into(), - at: now, - }, - ) - } else { - ( - s(&c["name"]), - Check { - status: s(&c["status"]).to_ascii_lowercase(), - conclusion: s(&c["conclusion"]).to_ascii_lowercase(), - at: now, - }, - ) - }; - if !name.is_empty() { - self.checks.insert(name, check); - } - } - } + self.threads_partial = threads["pageInfo"]["hasNextPage"].as_bool() == Some(true); self.synced_at = now; } @@ -1471,10 +1595,16 @@ impl PrRecord { } } } - // A required check not reported yet is still to run. + // A required check not reported yet is still to run, unless the + // sync's list was cut short: then it may be among the checks it + // didn't read, and the checks are not known. if checks.known { for r in &self.required_checks { if !self.checks.keys().any(|k| k.eq_ignore_ascii_case(r)) { + if self.checks_partial { + checks.known = false; + break; + } checks.total += 1; checks.running.push(r.clone()); } @@ -1512,6 +1642,7 @@ impl PrRecord { threads_required: self.threads_required, open_threads: self.open_threads, thread_authors: self.thread_authors.clone(), + threads_unread: self.threads_partial, auto_merge: self.auto_merge, blocked_by_rules: blocked, since: self.spans.last().map(|s| s.from).unwrap_or(self.created_at), @@ -1588,6 +1719,7 @@ pub const SEARCH_QUERY: &str = "query($q: String!, $after: String) { ... on PullRequest { number title url state isDraft createdAt updatedAt additions deletions headRefName headRefOid baseRefName reviewDecision mergeable mergeStateStatus + headRepository { nameWithOwner } isInMergeQueue repository { nameWithOwner } author { login } @@ -1600,9 +1732,9 @@ pub const SEARCH_QUERY: &str = "query($q: String!, $after: String) { reviews(first: 40) { nodes { state submittedAt body author { login } commit { oid } } } timelineItems(first: 40, itemTypes: [READY_FOR_REVIEW_EVENT, REVIEW_REQUESTED_EVENT, REVIEW_REQUEST_REMOVED_EVENT]) { nodes { __typename ... on ReadyForReviewEvent { createdAt } ... on ReviewRequestedEvent { createdAt requestedReviewer { ... on User { login } ... on Team { slug } } } ... on ReviewRequestRemovedEvent { createdAt requestedReviewer { ... on User { login } ... on Team { slug } } } } } participants(first: 20) { nodes { login } } - reviewThreads(first: 50) { nodes { isResolved comments(first: 1) { nodes { author { login } } } } } + reviewThreads(first: 100) { pageInfo { hasNextPage } nodes { isResolved comments(first: 1) { nodes { author { login } } } } } baseRef { branchProtectionRule { requiredApprovingReviewCount requiresCodeOwnerReviews requiresConversationResolution requiredStatusCheckContexts } } - commits(last: 1) { nodes { commit { statusCheckRollup { contexts(first: 60) { nodes { __typename ... on CheckRun { name status conclusion } ... on StatusContext { context state } } } } } } } + commits(last: 1) { nodes { commit { statusCheckRollup { contexts(first: 100) { pageInfo { hasNextPage } nodes { __typename ... on CheckRun { name status conclusion } ... on StatusContext { context state } } } } } } } } } } @@ -1644,22 +1776,51 @@ pub fn from_item(item: &Item) -> Option<(PrRecord, i64)> { } /// Read one record. -pub async fn load( +/// One settings item of the team (consistent read), the one read every +/// record, pointer, history row and backfill progress goes through. +pub async fn get_item( dynamo: &DynamoClient, table: &str, team_id: &str, - repo: &str, - number: u64, -) -> Result, Err> { + sk: &str, +) -> Result, Err> { let out = dynamo .get_item() .table_name(table) .key("pk", AttributeValue::S(team_id.into())) - .key("sk", AttributeValue::S(record_sk(repo, number))) + .key("sk", AttributeValue::S(sk.into())) .consistent_read(true) .send() .await?; - Ok(out.item().and_then(from_item)) + Ok(out.item().cloned()) +} + +/// The JSON body (`doc`) of a team's settings item. +pub async fn get_doc( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + sk: &str, +) -> Result, Err> { + Ok(get_item(dynamo, table, team_id, sk) + .await? + .as_ref() + .and_then(|i| i.get("doc")) + .and_then(|v| v.as_s().ok()) + .and_then(|d| serde_json::from_str(d).ok())) +} + +pub async fn load( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + repo: &str, + number: u64, +) -> Result, Err> { + Ok(get_item(dynamo, table, team_id, &record_sk(repo, number)) + .await? + .as_ref() + .and_then(from_item)) } /// Write a record when its version is still `ver` (0: not there yet). @@ -1764,9 +1925,12 @@ pub async fn point( rec: &PrRecord, now: i64, ) -> Result<(), Err> { + let base = format!("{}#{:06}", rec.base_ref, rec.number); for sk in [ - (!rec.head_sha.is_empty()).then(|| head_sk(&rec.repo, &rec.head_sha)), - (!rec.head_ref.is_empty()).then(|| ref_sk(&rec.repo, &rec.head_ref)), + (!rec.head_sha.is_empty()).then(|| pointer_sk(Pointer::Head, &rec.repo, &rec.head_sha)), + (!rec.head_ref.is_empty()).then(|| pointer_sk(Pointer::Ref, &rec.repo, &rec.head_ref)), + (!rec.base_ref.is_empty() && rec.is_open()) + .then(|| pointer_sk(Pointer::Base, &rec.repo, &base)), ] .into_iter() .flatten() @@ -1794,18 +1958,42 @@ pub async fn pointed( team_id: &str, sk: &str, ) -> Result, Err> { + Ok(get_item(dynamo, table, team_id, sk) + .await? + .as_ref() + .and_then(|i| i.get("pr_number")) + .and_then(|v| v.as_n().ok()) + .and_then(|v| v.parse().ok())) +} + +/// The open pull requests a base-branch pointer names: those based on +/// `branch` in `repo` (pointers outlive a base change by up to their +/// expiry; the record's own base decides). +pub async fn based_on( + dynamo: &DynamoClient, + table: &str, + team_id: &str, + repo: &str, + branch: &str, +) -> Result, Err> { + let prefix = pointer_sk(Pointer::Base, repo, &format!("{branch}#")); let out = dynamo - .get_item() + .query() .table_name(table) - .key("pk", AttributeValue::S(team_id.into())) - .key("sk", AttributeValue::S(sk.into())) + .key_condition_expression("pk = :pk AND begins_with(sk, :p)") + .expression_attribute_values(":pk", AttributeValue::S(team_id.into())) + .expression_attribute_values(":p", AttributeValue::S(prefix)) + .projection_expression("pr_number") + .limit(200) .send() .await?; Ok(out - .item() - .and_then(|i| i.get("pr_number")) - .and_then(|v| v.as_n().ok()) - .and_then(|v| v.parse().ok())) + .items() + .iter() + .filter_map(|i| i.get("pr_number")) + .filter_map(|v| v.as_n().ok()) + .filter_map(|v| v.parse().ok()) + .collect()) } /// Every record of a team (one query, paged). @@ -1992,7 +2180,7 @@ mod tests { {"__typename": "CheckRun", "name": "unit", "status": "COMPLETED", "conclusion": "SUCCESS"}]}}}}]} }); let mut r = PrRecord::new("acme/web", 318); - r.apply_node(&node, NOW); + r.apply_node(&node, NOW, NOW); assert_eq!(r.requested_teams, vec!["acme/payments"]); assert_eq!(r.open_threads, 1); assert_eq!(r.thread_authors, vec!["jun"]); @@ -2069,4 +2257,122 @@ mod tests { ("security", "high") ); } + + fn node(state: &str, decision: &str) -> Value { + json!({ + "number": 318, "title": "Round cart totals", "url": "https://github.com/acme/web/pull/318", + "state": state, "isDraft": false, "createdAt": "2026-01-10T10:00:00Z", + "updatedAt": "2026-01-10T12:00:00Z", "headRefName": "fix/cart-rounding", + "headRefOid": "aaaaaaa1111111", "baseRefName": "main", "reviewDecision": decision, + "mergeable": "MERGEABLE", "author": {"login": "octocat"}, + "headRepository": {"nameWithOwner": "acme/web"}, + "latestOpinionatedReviews": {"nodes": []}, + "reviewThreads": {"pageInfo": {"hasNextPage": false}, "nodes": []}, + "commits": {"nodes": [{"commit": {"statusCheckRollup": {"contexts": { + "pageInfo": {"hasNextPage": false}, + "nodes": [{"__typename": "CheckRun", "name": "unit", "status": "COMPLETED", "conclusion": "SUCCESS"}]}}}}]} + }) + } + + #[test] + fn the_sync_never_reopens_a_closed_record_or_overwrites_newer_events() { + let mut r = PrRecord::new("acme/web", 318); + r.apply_event("pull_request", &opened(), NOW); + let mut closed = opened(); + closed["action"] = json!("closed"); + closed["pull_request"]["state"] = json!("closed"); + r.apply_event("pull_request", &closed, NOW); + assert!(!r.apply_node(&node("OPEN", "APPROVED"), NOW - 60, NOW)); + assert_eq!(r.status, "closed"); + + // An event after the search was read wins over the page. + let mut r = PrRecord::new("acme/web", 318); + r.apply_event("pull_request", &opened(), NOW); + r.title = "Newer title from an event".into(); + assert!(r.apply_node(&node("OPEN", "APPROVED"), NOW - 60, NOW)); + assert_eq!(r.title, "Newer title from an event"); + // ...while what only the search carries still lands. + assert_eq!(r.review_decision.as_deref(), Some("APPROVED")); + } + + #[test] + fn the_sync_is_the_authority_for_the_reviews_it_lists() { + let mut r = PrRecord::new("acme/web", 318); + r.reviews.insert( + "mara".into(), + Review { + state: "CHANGES_REQUESTED".into(), + ..Default::default() + }, + ); + r.coderhelm_verdict = Some(("REQUEST_CHANGES".into(), "aaaaaaa1111111".into())); + r.apply_node(&node("OPEN", "REVIEW_REQUIRED"), NOW, NOW); + assert!( + r.reviews.is_empty(), + "a review gone from GitHub leaves the record" + ); + assert_eq!(r.coderhelm_verdict, None); + } + + #[test] + fn a_list_cut_short_is_never_read_as_complete() { + let mut n = node("OPEN", "APPROVED"); + n["commits"]["nodes"][0]["commit"]["statusCheckRollup"]["contexts"]["pageInfo"] + ["hasNextPage"] = json!(true); + n["reviewThreads"]["pageInfo"]["hasNextPage"] = json!(true); + let mut r = PrRecord::new("acme/web", 318); + r.checks_sha = "aaaaaaa1111111".into(); + r.head_sha = "aaaaaaa1111111".into(); + r.checks.insert( + "lint".into(), + Check { + status: "completed".into(), + conclusion: "success".into(), + at: NOW, + }, + ); + r.apply_node(&n, NOW, NOW); + assert!(r.checks.contains_key("lint"), "event-fed checks are kept"); + r.required_checks = vec!["e2e".into()]; + let f = r.facts(); + assert!( + !f.checks.known, + "a required check maybe on a later page is unknown, not running" + ); + r.threads_required = true; + r.required_checks.clear(); + let n = pr_needs::decide("acme/web", &r.facts()); + assert_eq!(n.state, pr_needs::State::Unknown, "{n:?}"); + } + + #[test] + fn a_review_event_refreshes_the_review_decision() { + let mut r = PrRecord::new("acme/web", 318); + r.apply_event("pull_request", &opened(), NOW); + r.approvals_required = 1; + r.review_decision = Some("REVIEW_REQUIRED".into()); + r.decision_at = NOW - 3600; + let review = json!({"action": "submitted", "pull_request": {"number": 318}, + "review": {"user": {"login": "mara"}, "state": "approved", "commit_id": "aaaaaaa1111111", + "submitted_at": "2026-01-10T11:00:00Z"}}); + r.apply_event("pull_request_review", &review, NOW); + assert_eq!(r.review_decision.as_deref(), Some("APPROVED")); + assert!(r.decision_fresh()); + } + + #[test] + fn one_pointer_helper_names_every_pointer() { + assert_eq!( + pointer_sk(Pointer::Head, "acme/web", "aaa"), + "PRRECHEAD#acme/web#aaa" + ); + assert_eq!( + pointer_sk(Pointer::Ref, "acme/web", "main"), + "PRRECREF#acme/web#main" + ); + assert_eq!( + pointer_sk(Pointer::Base, "acme/web", "main#000318"), + "PRRECBASE#acme/web#main#000318" + ); + } } diff --git a/services/common/src/pr_view.rs b/services/common/src/pr_view.rs index c969dd63a..49980ada1 100644 --- a/services/common/src/pr_view.rs +++ b/services/common/src/pr_view.rs @@ -281,9 +281,14 @@ pub fn facts_of( /// Links between the team's own records: a pull request based on another's /// branch is stacked on it; the run's plan links its pull requests. pub fn link_records(recs: &mut [PrRecord], joins: &Joins) { + // A branch is a base other pull requests stack on only when it lives in + // the same repository: a fork's `main` is not the repository's `main`. + // A head whose repository isn't known stacks nothing. let heads: HashMap<(String, String), u64> = recs .iter() - .filter(|r| r.is_open() && !r.head_ref.is_empty()) + .filter(|r| { + r.is_open() && !r.head_ref.is_empty() && r.head_repo.eq_ignore_ascii_case(&r.repo) + }) .map(|r| ((r.repo.clone(), r.head_ref.clone()), r.number)) .collect(); let mut children: HashMap<(String, u64), Vec> = HashMap::new(); @@ -371,6 +376,31 @@ pub fn rows( viewer: Option<&str>, now: i64, ) -> Vec { + decided(team_id, items, joins, viewer, now) + .into_iter() + .map(|d| d.row) + .collect() +} + +/// One pull request as the list and the detail both read it: its linked +/// record (stack and plan links in), the facts, the decision and the row. +#[derive(Debug, Clone)] +pub struct Decided { + pub record: PrRecord, + pub facts: Facts, + pub needs: Needs, + pub row: Row, +} + +/// The one input builder of the list and the detail: every record of the +/// team linked to the others, decided once. +pub fn decided( + team_id: &str, + items: &[Item], + joins: &Joins, + viewer: Option<&str>, + now: i64, +) -> Vec { let mut recs = records_of(team_id, items); link_records(&mut recs, joins); let mut decided: Vec<(PrRecord, Needs, Facts)> = Vec::new(); @@ -425,11 +455,32 @@ pub fn rows( && p75 .get(&(r.repo.clone(), n.state)) .is_some_and(|p| now - since > *p && *p > 0); - row(&r, &n, &f, joins, &states, viewer, since, stale) + let row = row(&r, &n, &f, joins, &states, viewer, since, stale); + Decided { + record: r, + facts: f, + needs: n, + row, + } }) .collect() } +/// One pull request of the team, decided exactly as the list decides it. +pub fn detail_of( + team_id: &str, + items: &[Item], + joins: &Joins, + viewer: Option<&str>, + now: i64, + repo: &str, + number: u64, +) -> Option { + decided(team_id, items, joins, viewer, now) + .into_iter() + .find(|d| d.record.repo.eq_ignore_ascii_case(repo) && d.record.number == number) +} + fn waiting_since(r: &PrRecord) -> i64 { r.spans .last() @@ -986,6 +1037,7 @@ mod tests { fn a_stacked_pull_request_waits_on_its_base() { let mut base = rec("acme/web", 1, "octocat"); base.head_ref = "feature/a".into(); + base.head_repo = "acme/web".into(); base.base_ref = "main".into(); let mut top = rec("acme/web", 2, "octocat"); top.head_ref = "feature/b".into(); @@ -1049,4 +1101,45 @@ mod tests { .iter() .all(|e| !e.coderhelm || e.run_id.as_deref() == Some("run-1"))); } + + #[test] + fn a_forks_branch_never_stacks_the_repositorys_pull_requests() { + let mut fork = rec("acme/web", 1, "octocat"); + fork.head_ref = "main".into(); + fork.head_repo = "octocat/web".into(); + let mut other = rec("acme/web", 2, "mara"); + other.base_ref = "main".into(); + let items = vec![item("TEAM#a", &fork), item("TEAM#a", &other)]; + let all = rows("TEAM#a", &items, &Joins::default(), None, NOW); + let other = all.iter().find(|r| r.number == 2).unwrap(); + assert_ne!(other.state, "waiting_on_pr"); + assert!(other.links.is_empty()); + } + + #[test] + fn the_detail_decides_a_stacked_pull_request_as_the_list_does() { + let mut base = rec("acme/web", 1, "octocat"); + base.head_ref = "feature/a".into(); + base.head_repo = "acme/web".into(); + let mut top = rec("acme/web", 2, "octocat"); + top.base_ref = "feature/a".into(); + let items = vec![item("TEAM#a", &base), item("TEAM#a", &top)]; + let row = rows("TEAM#a", &items, &Joins::default(), None, NOW) + .into_iter() + .find(|r| r.number == 2) + .unwrap(); + let d = detail_of( + "TEAM#a", + &items, + &Joins::default(), + None, + NOW, + "acme/web", + 2, + ) + .unwrap(); + assert_eq!(row.state, "waiting_on_pr"); + assert_eq!(d.needs.state.code(), row.state); + assert_eq!(d.facts.waits_on, vec!["acme/web#1".to_string()]); + } } diff --git a/services/gateway/src/routes/prs.rs b/services/gateway/src/routes/prs.rs index 1136ddd13..7ba4b28cc 100644 --- a/services/gateway/src/routes/prs.rs +++ b/services/gateway/src/routes/prs.rs @@ -25,7 +25,7 @@ use axum::{ http::StatusCode, Extension, Json, }; -use common::pr_record::{self, Item, PrRecord}; +use common::pr_record::{self, Item, Pointer, PrRecord}; use common::pr_view::{self, Joins, ReviewJoin, RunJoin}; use serde::Deserialize; use serde_json::{json, Value}; @@ -38,8 +38,9 @@ use crate::AppState; /// How long one team's read is reused (the page polls while visible). const LIST_TTL: Duration = Duration::from_secs(10); -/// One team's records and what is joined to them. -type Snapshot = Arc<(Vec, Joins)>; +/// One team's records, what is joined to them, and how each source read +/// (a cache hit says the same as the read it keeps). +type Snapshot = Arc<(Vec, Joins, Vec)>; /// The team's records and joins as last read, keyed by /// `read_key(installation_id, "prs#")`. @@ -66,11 +67,11 @@ pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, paylo let sk = match event_type { "status" => payload["sha"] .as_str() - .map(|sha| pr_record::head_sk(repo, sha)), + .map(|sha| pr_record::pointer_sk(Pointer::Head, repo, sha)), "push" => payload["ref"] .as_str() .and_then(|r| r.strip_prefix("refs/heads/")) - .map(|b| pr_record::ref_sk(repo, b)), + .map(|b| pr_record::pointer_sk(Pointer::Ref, repo, b)), _ => None, }; if event_type == "push" { @@ -133,8 +134,9 @@ pub async fn on_webhook(state: &AppState, team_id: &str, event_type: &str, paylo } /// A push to a branch other pull requests are based on: their drift -/// (commits behind, and those touching their files). The repository's open -/// records only, at most 200. +/// (commits behind, and those touching their files). Only the pull +/// requests a base pointer names are read (most pushes go to branches +/// nothing is based on, and read nothing), at most 200. async fn base_push(state: &AppState, team_id: &str, repo: &str, payload: &Value) { let Some(branch) = payload["ref"] .as_str() @@ -146,21 +148,16 @@ async fn base_push(state: &AppState, team_id: &str, repo: &str, payload: &Value) return; } let table = &state.config.settings_table_name; - let prefix = format!("{}{repo}#", pr_record::SK_PREFIX); - let items = match items_under(state, team_id, &prefix).await { - Ok(i) => i, + let numbers = match pr_record::based_on(&state.dynamo, table, team_id, repo, branch).await { + Ok(n) => n, Err(e) => { - warn!(repo, error = %e, "Drift: records not read"); + warn!(repo, error = %e, "Drift: base pointers not read"); return; } }; let t = now(); - for rec in pr_view::records_of(team_id, &items) - .into_iter() - .filter(|r| r.is_open() && r.base_ref == branch) - .take(200) - { - let _ = pr_record::update(&state.dynamo, table, team_id, repo, rec.number, t, |r| { + for number in numbers.into_iter().take(200) { + let _ = pr_record::update(&state.dynamo, table, team_id, repo, number, t, |r| { r.note_base_push(branch, payload, t) }) .await; @@ -434,10 +431,8 @@ async fn read_all(state: &AppState, team_id: &str) -> Result<(Snapshot, Vec Result<(Snapshot, Vec = run.cloned().into_iter().collect(); let runs_out: Vec = runs .iter() diff --git a/services/worker/src/passes/await_merge.rs b/services/worker/src/passes/await_merge.rs index fe6fd264b..d0d8eff05 100644 --- a/services/worker/src/passes/await_merge.rs +++ b/services/worker/src/passes/await_merge.rs @@ -700,13 +700,28 @@ pub(crate) fn gate_facts(v: &GateView, ci: Option<&Ci>) -> common::pr_needs::Fac } None => {} } - let approved_by = if !human { - Vec::new() - } else if v.approvals.approved_at_head.is_empty() { + // People's approvals. The team's rule takes them only through the + // person key; GitHub's rule is GitHub's own decision. + let people = if v.approvals.approved_at_head.is_empty() { v.approvals.approved_by.clone() } else { v.approvals.approved_at_head.clone() }; + let approved_by = if v.require_human && !human { + Vec::new() + } else { + people + }; + // GitHub reports no review decision when the branch requires no review: + // then no approval count holds the merge, whatever rules were read. + let approvals_required = if v.review_decision.is_none() { + 0 + } else { + v.rules + .required_approvals + .unwrap_or(0) + .min(u64::from(u32::MAX)) as u32 + }; Facts { known: true, draft: v.draft, @@ -721,11 +736,7 @@ pub(crate) fn gate_facts(v: &GateView, ci: Option<&Ci>) -> common::pr_needs::Fac approved_by, requested: v.requested.clone(), review_decision: v.review_decision.clone(), - approvals_required: v - .rules - .required_approvals - .unwrap_or(0) - .min(u64::from(u32::MAX)) as u32, + approvals_required, team_requires_approval: v.require_human, conflict: Some(false), checks, diff --git a/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs index c33ca1404..c4d857d60 100644 --- a/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs +++ b/services/worker/src/passes/incidents/xw_every_open_pr_has_one_state.rs @@ -217,8 +217,10 @@ fn gate_view() -> GateView { #[test] fn the_merge_gates_and_the_list_read_one_decision() { // The reviewer's auto-merge gate merges exactly when the list says - // ready, over every combination of what it weighs. - for bits in 0u32..(1 << 8) { + // ready, over every combination of what it weighs: the keys, the + // checks, people asked to review, GitHub's review decision and the + // branch's approval count. + for bits in 0u32..(1 << 12) { let on = |i: u32| bits & (1 << i) != 0; let mut v = gate_view(); v.draft = on(0); @@ -246,6 +248,18 @@ fn the_merge_gates_and_the_list_read_one_decision() { ..Default::default() }, }; + if on(8) { + v.requested = vec!["theo".into()]; + } + v.review_decision = match (on(9), on(10)) { + (false, false) => None, + (true, false) => Some("REVIEW_REQUIRED".into()), + (false, true) => Some("APPROVED".into()), + (true, true) => Some("CHANGES_REQUESTED".into()), + }; + if on(11) { + v.rules.required_approvals = Some(1); + } let ci = summary.ci(); v.ci = Some(summary); let gate = decide_gate(&v); @@ -253,7 +267,7 @@ fn the_merge_gates_and_the_list_read_one_decision() { assert_eq!( gate.action == Action::Merge, list.state.is_ready(), - "bits {bits:08b}: the gate says {:?}, the list says {:?}", + "bits {bits:012b}: the gate says {:?}, the list says {:?}", gate.action, list.state ); @@ -262,6 +276,18 @@ fn the_merge_gates_and_the_list_read_one_decision() { } } + // Never stricter than GitHub: a review someone is asked for that no + // rule requires, with the team's rule off, never holds the merge. + let mut v = gate_view(); + v.require_human = false; + v.requested = vec!["theo".into()]; + v.ci = Some(CheckSummary::default()); + assert_eq!(decide_gate(&v).action, Action::Merge); + // GitHub's approval counts every approval that counts there. + v.review_decision = Some("APPROVED".into()); + v.rules.required_approvals = Some(1); + assert_eq!(decide_gate(&v).action, Action::Merge); + // The run's watch stores the standing this function decides, and the // list reads the stored standing to the same state. let watch = src("worker/src/passes/pr_watch.rs"); diff --git a/services/worker/src/passes/pr_records.rs b/services/worker/src/passes/pr_records.rs index 7adcc34e9..3d6a4026a 100644 --- a/services/worker/src/passes/pr_records.rs +++ b/services/worker/src/passes/pr_records.rs @@ -179,6 +179,9 @@ async fn sync_team( break; } let vars = json!({"q": pr_record::search_text(&owner, as_org), "after": after}); + // Before the read: an event recorded after this moment is newer + // than anything the page says. + let read_at = chrono::Utc::now().timestamp(); let data = match github.graphql_read(pr_record::SEARCH_QUERY, vars).await { Ok(d) => d, // A personal account's repositories are searched by user. @@ -205,8 +208,7 @@ async fn sync_team( seen.insert(format!("{}#{number}", repo.to_ascii_lowercase())); let written = pr_record::update(&state.dynamo, table, team_id, repo, number, now, |r| { - r.apply_node(node, now); - true + r.apply_node(node, read_at, now) }) .await; match written { From 29dc1560dde3a97639c442f92eaf92cda961476e Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 18:20:18 -0500 Subject: [PATCH 07/19] For you: one person's own page, linked by them, never by email GET /api/foryou joins the pull request records, chat_work_needs::gather and the person's open sprint from the Jira app for the session's user only: needs you now grouped by whose turn it is, the sprint with a fit band per ticket, CoderHelm's work for them, their pull requests waiting on others, Later, three private numbers and suggestions with their lifecycle. People link their Jira account from the Jira app's new "Link my CoderHelm account" action with a one-time code made on the dashboard. Give to CoderHelm adds the team's trigger label through the Jira app, so the run starts on the label path with the person as owner; "Draft a plan first" stops the run after its plan until the person approves it. --- coderhelm-jira/manifest.yml | 13 + coderhelm-jira/package-lock.json | 3353 ++++++++++++++++- coderhelm-jira/package.json | 5 +- coderhelm-jira/src/frontend/link.jsx | 63 + coderhelm-jira/src/issues.js | 106 + coderhelm-jira/src/link-resolver.js | 12 + coderhelm-jira/src/link.js | 110 + coderhelm-jira/src/release.js | 76 +- coderhelm-jira/test/issues.test.js | 77 + coderhelm-jira/test/link.test.js | 75 + coderhelm-jira/test/manifest.test.js | 10 + docs/for-you.md | 86 + docs/incidents/ya_for_you_is_only_yours.md | 5 + services/Cargo.lock | 1 + services/common/Cargo.toml | 1 + services/common/src/foryou.rs | 1978 ++++++++++ services/common/src/handback.rs | 2 + services/common/src/lib.rs | 1 + services/common/src/pr_history.rs | 4 + services/common/src/stop_judge.rs | 69 +- services/gateway/src/main.rs | 20 + services/gateway/src/permissions.rs | 9 + services/gateway/src/routes/chat_work.rs | 1 + .../gateway/src/routes/chat_work_needs.rs | 146 +- services/gateway/src/routes/foryou.rs | 1818 +++++++++ services/gateway/src/routes/foryou/tests.rs | 627 +++ services/gateway/src/routes/foryou_give.rs | 347 ++ services/gateway/src/routes/foryou_link.rs | 449 +++ services/gateway/src/routes/jira_webhook.rs | 44 +- services/gateway/src/routes/mod.rs | 3 + services/gateway/src/routes/prs.rs | 5 +- .../passes/incidents/bm_teams_never_cross.rs | 7 + .../incidents/ya_for_you_is_only_yours.rs | 248 ++ services/worker/src/passes/mod.rs | 110 + 34 files changed, 9726 insertions(+), 155 deletions(-) create mode 100644 coderhelm-jira/src/frontend/link.jsx create mode 100644 coderhelm-jira/src/link-resolver.js create mode 100644 coderhelm-jira/src/link.js create mode 100644 coderhelm-jira/test/link.test.js create mode 100644 docs/for-you.md create mode 100644 docs/incidents/ya_for_you_is_only_yours.md create mode 100644 services/common/src/foryou.rs create mode 100644 services/gateway/src/routes/foryou.rs create mode 100644 services/gateway/src/routes/foryou/tests.rs create mode 100644 services/gateway/src/routes/foryou_give.rs create mode 100644 services/gateway/src/routes/foryou_link.rs create mode 100644 services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs diff --git a/coderhelm-jira/manifest.yml b/coderhelm-jira/manifest.yml index 0eaedb8fa..4a0196d32 100644 --- a/coderhelm-jira/manifest.yml +++ b/coderhelm-jira/manifest.yml @@ -23,6 +23,15 @@ modules: function: getSiteUrlHandler - key: get-issues-trigger function: getIssuesHandler + # Any issue's "..." menu: a person links their Jira account to their + # CoderHelm user with a one-time code from the For you page (src/link.js). + jira:issueAction: + - key: coderhelm-link-account + title: Link my CoderHelm account + resource: link + render: native + resolver: + function: linkResolver jira:adminPage: - key: coderhelm-admin-page resource: adminPage @@ -46,9 +55,13 @@ modules: handler: release.getIssuesHandler - key: lifecycleHandler handler: register.lifecycleHandler + - key: linkResolver + handler: link-resolver.handler resources: - key: adminPage path: resources/admin/build + - key: link + path: src/frontend/link.jsx permissions: scopes: - read:jira-work diff --git a/coderhelm-jira/package-lock.json b/coderhelm-jira/package-lock.json index 5a9ba280f..a963b8747 100644 --- a/coderhelm-jira/package-lock.json +++ b/coderhelm-jira/package-lock.json @@ -6,86 +6,2371 @@ "": { "dependencies": { "@forge/api": "^7.1.1", + "@forge/bridge": "^5.17.0", + "@forge/react": "^11.17.0", "@forge/resolver": "^1.8.0", - "@forge/ui": "^1.11.4" + "@forge/ui": "^1.11.4", + "react": "^19.3.1" + } + }, + "node_modules/@atlaskit/adf-schema": { + "version": "48.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema/-/adf-schema-48.0.0.tgz", + "integrity": "sha512-zzPhx1zsiAL2zSR9APrw6CMNxAGMerjjNgc0AeqQWZjSuh4U18THv77o4buS9QPdUn2S8BztBNiEbB7bP9wNRw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/editor-prosemirror": "*", + "@atlaskit/feature-gate-js-client": "^4.26.4", + "@babel/runtime": "^7.0.0", + "css-color-names": "0.0.4", + "linkify-it": "^2.0.3", + "memoize-one": "^6.0.0" + } + }, + "node_modules/@atlaskit/adf-schema-generator": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema-generator/-/adf-schema-generator-2.4.0.tgz", + "integrity": "sha512-67OANQ8dqp2tJbrHjP9vcwf3aQ90t8pyzT66YSc0Fw/52qibUEQtXU5QEQZFtq7Y0go0YreeLdO8dkH6R+zMAA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/editor-prosemirror": "^7.3.0", + "@babel/runtime": "^7.0.0", + "lodash": "^4.17.21" + } + }, + "node_modules/@atlaskit/adf-schema-generator/node_modules/@atlaskit/editor-prosemirror": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-7.3.0.tgz", + "integrity": "sha512-6KB4CuURZ+fU1DJMlmCox6q8T5ooVaCE+eZVrAlcODIfTyLu/wCvJfPJLOJUPZBvzCHqoWCebFmpu39uwUUleg==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "prosemirror-commands": "1.7.1", + "prosemirror-dropcursor": "1.8.2", + "prosemirror-history": "1.5.0", + "prosemirror-keymap": "1.2.3", + "prosemirror-markdown": "1.13.2", + "prosemirror-model": "1.25.4", + "prosemirror-state": "1.4.4", + "prosemirror-transform": "1.10.5", + "prosemirror-utils": "1.2.2", + "prosemirror-view": "1.41.5" + } + }, + "node_modules/@atlaskit/adf-schema-generator/node_modules/prosemirror-markdown": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.2.tgz", + "integrity": "sha512-FPD9rHPdA9fqzNmIIDhhnYQ6WgNoSWX9StUZ8LEKapaXU9i6XgykaHKhp6XMyXlOWetmaFgGDS/nu/w9/vUc5g==", + "license": "MIT", + "dependencies": { + "@types/markdown-it": "^14.0.0", + "markdown-it": "^14.0.0", + "prosemirror-model": "^1.25.0" + } + }, + "node_modules/@atlaskit/adf-schema-generator/node_modules/prosemirror-transform": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.10.5.tgz", + "integrity": "sha512-RPDQCxIDhIBb1o36xxwsaeAvivO8VLJcgBtzmOwQ64bMtsVFh5SSuJ6dWSxO1UsHTiTXPCgQm3PDJt7p6IOLbw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.21.0" + } + }, + "node_modules/@atlaskit/adf-schema-generator/node_modules/prosemirror-view": { + "version": "1.41.5", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.5.tgz", + "integrity": "sha512-UDQbIPnDrjE8tqUBbPmCOZgtd75htE6W3r0JCmY9bL6W1iemDM37MZEKC49d+tdQ0v/CKx4gjxLoLsfkD2NiZA==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.20.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0" + } + }, + "node_modules/@atlaskit/adf-utils": { + "version": "19.33.9", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-utils/-/adf-utils-19.33.9.tgz", + "integrity": "sha512-we14ekAIWGvcA00C5RevNrNFbErCDObKcp6o/xNhgEUqRosRqGTs/dwK5kf0JgfVrPYsDpwrO+3y7/flKLaIrQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/adf-schema": "^54.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/tmp-editor-statsig": "^103.0.0", + "@babel/runtime": "^7.0.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/adf-schema": { + "version": "54.0.4", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema/-/adf-schema-54.0.4.tgz", + "integrity": "sha512-Ra+tIQGMhcOj96CnRjpDkom8sjebA+PmzHp8OjXW6BOJO6yGRBlnwNSxlcBKdk0O6hFxfIwr5SRN0FF1Dyo1Rg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/adf-schema-generator": "^2.4.0", + "@atlaskit/editor-prosemirror": "^7.3.0", + "@atlaskit/tmp-editor-statsig": "^103.0.0", + "@babel/runtime": "^7.0.0", + "css-color-names": "0.0.4", + "linkify-it": "^3.0.3", + "memoize-one": "^6.0.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/browser-apis": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-0.0.2.tgz", + "integrity": "sha512-3mfBAVBx8ReUlILUGdsc+G1JlrA0DvFAbOMorJfsIvsOqJViABxjQyW05psbnLoLZD/CT3+9jCHSHOIY8Gwtyw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/editor-prosemirror": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-7.3.0.tgz", + "integrity": "sha512-6KB4CuURZ+fU1DJMlmCox6q8T5ooVaCE+eZVrAlcODIfTyLu/wCvJfPJLOJUPZBvzCHqoWCebFmpu39uwUUleg==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "prosemirror-commands": "1.7.1", + "prosemirror-dropcursor": "1.8.2", + "prosemirror-history": "1.5.0", + "prosemirror-keymap": "1.2.3", + "prosemirror-markdown": "1.13.2", + "prosemirror-model": "1.25.4", + "prosemirror-state": "1.4.4", + "prosemirror-transform": "1.10.5", + "prosemirror-utils": "1.2.2", + "prosemirror-view": "1.41.5" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/feature-gate-js-client": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-5.8.0.tgz", + "integrity": "sha512-SJ+U0EVPdAXHy8Ge7I1BT7bptUiCG11x2XVwqRqZ5ysbR9WsfuUfX4l5BchAqyogJrcrt0v8TC1IBmcQ0WeEUA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/atlassian-context": "^0.11.0", + "@babel/runtime": "^7.0.0", + "@statsig/client-core": "^3.27.0", + "@statsig/js-client": "^3.27.0", + "eventemitter3": "^4.0.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/interaction-context": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-3.1.0.tgz", + "integrity": "sha512-LB3T0ATpJ5y7/IVBndNbcjtaNmPcz/8k7+smMibzphmV7xB3HaIyJFEu2JoSmgps66qLXo0ia8Hj7v4dF9zJZw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/react-ufo": { + "version": "6.7.5", + "resolved": "https://registry.npmjs.org/@atlaskit/react-ufo/-/react-ufo-6.7.5.tgz", + "integrity": "sha512-xzz8KzMSAGEni6sUckaer2GNokMeSq9Cn+4awpZhspgiXDv1TOLFqFuqz8uUisHmbUPbK+9e/fE0r6gc5/ZQvg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/atlassian-context": "^0.11.0", + "@atlaskit/browser-apis": "^0.0.2", + "@atlaskit/feature-gate-js-client": "^5.8.0", + "@atlaskit/interaction-context": "^3.1.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@babel/runtime": "^7.0.0", + "@opentelemetry/api": "^1.9.0", + "bind-event-listener": "^3.0.0", + "bowser-ultralight": "^1.0.6", + "scheduler": "0.23.2", + "uuid": "^3.1.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/tmp-editor-statsig": { + "version": "103.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/tmp-editor-statsig/-/tmp-editor-statsig-103.0.1.tgz", + "integrity": "sha512-XbGaofYNGvpFCt7kol/OunGO7hDV32Nm0KHXtotvsqNZNKrFC1lIB/5aw5b8sXyrn2D93VBlaaRLsvJ4tbejHA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/feature-gate-js-client": "^5.8.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/react-ufo": "^6.7.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/linkify-it": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", + "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", + "license": "MIT", + "dependencies": { + "uc.micro": "^1.0.1" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/prosemirror-markdown": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.2.tgz", + "integrity": "sha512-FPD9rHPdA9fqzNmIIDhhnYQ6WgNoSWX9StUZ8LEKapaXU9i6XgykaHKhp6XMyXlOWetmaFgGDS/nu/w9/vUc5g==", + "license": "MIT", + "dependencies": { + "@types/markdown-it": "^14.0.0", + "markdown-it": "^14.0.0", + "prosemirror-model": "^1.25.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/prosemirror-transform": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.10.5.tgz", + "integrity": "sha512-RPDQCxIDhIBb1o36xxwsaeAvivO8VLJcgBtzmOwQ64bMtsVFh5SSuJ6dWSxO1UsHTiTXPCgQm3PDJt7p6IOLbw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.21.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/prosemirror-view": { + "version": "1.41.5", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.5.tgz", + "integrity": "sha512-UDQbIPnDrjE8tqUBbPmCOZgtd75htE6W3r0JCmY9bL6W1iemDM37MZEKC49d+tdQ0v/CKx4gjxLoLsfkD2NiZA==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.20.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@atlaskit/adf-utils/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "license": "MIT", + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/@atlaskit/atlassian-context": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@atlaskit/atlassian-context/-/atlassian-context-0.11.0.tgz", + "integrity": "sha512-Q2iMFa6A3OPruD9GQS+quqHWM5Rh+Ew1bP4MxL2BoJV5QulT66K77fq8c86+g+MRqxeqtZ6jnT5zNw6IVrnpMw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/ds-lib": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/ds-lib/-/ds-lib-7.0.0.tgz", + "integrity": "sha512-Uqywr6YMi6uBpD0BtbRmG8f81fteRT7NBf62J8zzWPSs7u3Jq9G3Oruwm3y+57Dxv6IqfRwrS10WJARlCJdBLw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/editor-prosemirror": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-9.0.2.tgz", + "integrity": "sha512-Hn5atRMHJDQFz1U6PbzK50LRt/rEHbwvvNm49n6zIVV1464GfVuoGFtK0sHXPKi2LE1k8HNyyEjOAjLQUsoifw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "prosemirror-commands": "1.7.1", + "prosemirror-dropcursor": "1.8.2", + "prosemirror-history": "1.5.0", + "prosemirror-keymap": "1.2.3", + "prosemirror-markdown": "1.13.4", + "prosemirror-model": "1.25.4", + "prosemirror-state": "1.4.4", + "prosemirror-transform": "1.11.0", + "prosemirror-utils": "1.2.2", + "prosemirror-view": "1.41.7" + } + }, + "node_modules/@atlaskit/feature-gate-js-client": { + "version": "4.26.5", + "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-4.26.5.tgz", + "integrity": "sha512-ZCcw7GP6WapqfP18Hr4q5+AZuI1k6pJECL9tyIw64JwG0GntMa3tTj/T8c5aqBIOagRQTw24lkM+Nt+agrRcnA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/atlassian-context": "^0.2.0", + "@babel/runtime": "^7.0.0", + "@statsig/client-core": "^3.10.0", + "@statsig/js-client": "^3.10.0", + "eventemitter2": "^4.1.0" + } + }, + "node_modules/@atlaskit/feature-gate-js-client/node_modules/@atlaskit/atlassian-context": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/atlassian-context/-/atlassian-context-0.2.0.tgz", + "integrity": "sha512-msLRSp0qck6eflkShplgyIoOogNKxKRc6QIWGQlSvKGxHQNEbLEkRGcDzdh8PuBxSs1gda7OqYrdtQYQiPbpTQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/feature-gate-js-client/node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@atlaskit/platform-feature-flags": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags/-/platform-feature-flags-1.1.3.tgz", + "integrity": "sha512-dRn6UvVmMF5+WXnv7ZlxKTV2rVQncI2TgM0KTGSqpHdD9LnogITWC/rFjzUuF/W8MBCEvpouGilukqhq6rASnw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/feature-gate-js-client": "^5.5.0", + "@babel/runtime": "^7.0.0" + } + }, + "node_modules/@atlaskit/platform-feature-flags/node_modules/@atlaskit/feature-gate-js-client": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-5.8.0.tgz", + "integrity": "sha512-SJ+U0EVPdAXHy8Ge7I1BT7bptUiCG11x2XVwqRqZ5ysbR9WsfuUfX4l5BchAqyogJrcrt0v8TC1IBmcQ0WeEUA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/atlassian-context": "^0.11.0", + "@babel/runtime": "^7.0.0", + "@statsig/client-core": "^3.27.0", + "@statsig/js-client": "^3.27.0", + "eventemitter3": "^4.0.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop/-/pragmatic-drag-and-drop-1.8.1.tgz", + "integrity": "sha512-uXWNPpL8n4OmTVbduH7nq8pk8htqGo/prR5cYEE8sVCPJGAUMWn6lzvWTfI+4VCeQvHiDRODVz4YzH06OVAxhw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0", + "raf-schd": "^4.0.3" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-hitbox": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-hitbox/-/pragmatic-drag-and-drop-hitbox-1.2.0.tgz", + "integrity": "sha512-eWJvvuHZOC4Yk+Li7QpS+JM2F/I50/3PhMvEcyvcHbXI0FP0kCDD1MiF8Hv7uSOxpk5JNqKoOmK8e1ncOzTgqA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", + "@babel/runtime": "^7.0.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll/-/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll-2.0.2.tgz", + "integrity": "sha512-lo4x9p7DAq3WeCknHXqkCNmzSMvyKfucl1BFF6K22BjdiRd+DavBwt4aGUQBGnIPGwZgNKrjmwAFj9xuYdLZDQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^1.7.0", + "@babel/runtime": "^7.0.0", + "css-box-model": "^1.2.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": { + "version": "3.2.16", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/-/pragmatic-drag-and-drop-react-drop-indicator-3.2.16.tgz", + "integrity": "sha512-A2rcb6cqBFlGFR0cVwAwZKcSqUaYviNLskfBLI6wvDUFD2/dYI7GN56SOC895YC7EMoG/tPHkDB5vZiLa/iyQA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", + "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tokens": { + "version": "13.4.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tokens/-/tokens-13.4.0.tgz", + "integrity": "sha512-KtVQEwCa3boPmHSGnN0e0eKX9kkxXYFfKjkeex3NZAHju5h6iuDNBCk5MCX+uSu+2cnMRTIh1Trqj1OycoO8gQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@babel/runtime": "^7.0.0", + "@babel/traverse": "^7.23.2", + "@babel/types": "^7.20.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/top-layer": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@atlaskit/top-layer/-/top-layer-0.18.0.tgz", + "integrity": "sha512-l3Um9ACdf6UjD0apuvkNZhyDDADr+QH0aD9ilT2wMDfuAxFc0rbQLekDKeXTPPewX5LEGQm0DrTt16U8JQtmog==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/browser-apis": "^0.0.2", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/tokens": "^13.4.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0", + "raf-schd": "^4.0.3" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/top-layer/node_modules/@atlaskit/browser-apis": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-0.0.2.tgz", + "integrity": "sha512-3mfBAVBx8ReUlILUGdsc+G1JlrA0DvFAbOMorJfsIvsOqJViABxjQyW05psbnLoLZD/CT3+9jCHSHOIY8Gwtyw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/top-layer/node_modules/@atlaskit/css": { + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/@atlaskit/css/-/css-0.19.4.tgz", + "integrity": "sha512-OBacSDD/XBkuu4R2FFMgOoVifSbs7E4LRwqUJFolPurxnsc88/cDrwf9C3obMwDh+64O3a5OyzuUPLVQTfMXYQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/top-layer/node_modules/@atlaskit/layering": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@atlaskit/layering/-/layering-3.8.0.tgz", + "integrity": "sha512-PmwwvOuj2VhHU+LLsAwFl2VptWNn1aSuSoTXwsC0ZedV4M2WDr0yn0Z3ex0JGq7Za+6VOZsVhiBVW2jXW9a+0A==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0" } }, "node_modules/@babel/code-frame": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz", - "integrity": "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==", + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.17.tgz", + "integrity": "sha512-IdlVpcDeoDATtN2cfmnVk0A4XJKhu7SlpGuSaiOFdko09YC1MD07WokWUSEdw5R2o4o8VObX2LzViQW6VXnzkA==", + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.17", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.17.tgz", + "integrity": "sha512-xjNUVINWex7s4U0vESYwa8ChCBnmvhCQ6nkAdnhM8WYPlhXvU9D9fPurOSYQLV4FwcNXacDkN/MWIPNHsTI2OA==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.17", + "@babel/types": "^7.29.17", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.17.tgz", + "integrity": "sha512-SeQUwFlH8hH1vjUmBFeqwxt6Nsjp01MKEZOtZPJ86lpA4GBdb/o0dShjC+Awf7v74/+84KIL1RiJ4TOJj6gU+A==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.17.tgz", + "integrity": "sha512-bLxkfvUEHeWShbadKTm7EfDCkosXZh6PjWEa9bYiCuob24c0nm388ara2Hz6KisGaXe+XCsi6VyfJNSJjeUUwg==", + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.17", + "@babel/types": "^7.29.17" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.17.tgz", + "integrity": "sha512-iY5lvqFhfgMXp4o4zWads4NvQZXizBxzCoADPOgFMcMwk1XefAdBJbc9i1y94aflY57lokjOjRTa3AOOW9R7BQ==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.17.tgz", + "integrity": "sha512-AG+olLB+teKhkQ2WYJeaZqJwNLjtWTz1waQIP/tEYITzVzpdHLP7IXx2c/bH2JTsNCgvWlkqdCv91xcb8lul8Q==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.17.tgz", + "integrity": "sha512-I+0olVqWMm9bimQJc/5B3jn1nivNDXtnMtDVs07XdHzZLcWa2N/mlCTPmAsQg95QcKoXSuFD2Yz4fwdtoyk7DQ==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.17" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.17.tgz", + "integrity": "sha512-CvlZdpED5dsu21yK0DfpXksJWt1zeW09lY49hp7P9cA5Qedx/QkwEs1PfluSJjijH9i94oT9LmtgGWlPY8ISzw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.17.tgz", + "integrity": "sha512-D4nOLKOzIBwn7/Z78h3UPEwzFObmPVTukBJ9+63BijgMVeLj6mQ77FJb6YCZ4QBo6VjAk/yj4QnpKusTcBy6vA==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.17", + "@babel/parser": "^7.29.17", + "@babel/types": "^7.29.17" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.17.tgz", + "integrity": "sha512-q+CnfQcmNfDdOUARkt9FWtdR0HPOCcyQBj1Z7l2SOpFIfUB/XI3dXS0B5UOlZWwQCun80xVhgcv4ip6w128u9g==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.17", + "@babel/generator": "^7.29.17", + "@babel/helper-globals": "^7.29.17", + "@babel/parser": "^7.29.17", + "@babel/template": "^7.29.17", + "@babel/types": "^7.29.17", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.17.tgz", + "integrity": "sha512-kzo3lZUbI0gARA4QvhmOTH/aws2SrZ880ECQRIjPPSrdfBM0bZCkj1U7UN2fB0GNeXayqCiLVXa2+1jAhn377Q==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.17", + "@babel/helper-validator-identifier": "^7.29.17" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@compiled/react": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-0.20.0.tgz", + "integrity": "sha512-mEJuYGFxIDST1H7CpksyE6a3HRVRQmeDal26O+bCHTEZlPp7iKvs5KD1FOmd2palng+S60dPFFG+UuoZDRILwA==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@emotion/babel-plugin": { + "version": "11.13.5", + "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.13.5.tgz", + "integrity": "sha512-pxHCpT2ex+0q+HH91/zsdHkw/lXd468DIN2zvfvLtPKLLMo6gQj7oLObq8PhkrxOZb/gGCq03S3Z7PDhS8pduQ==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.16.7", + "@babel/runtime": "^7.18.3", + "@emotion/hash": "^0.9.2", + "@emotion/memoize": "^0.9.0", + "@emotion/serialize": "^1.3.3", + "babel-plugin-macros": "^3.1.0", + "convert-source-map": "^1.5.0", + "escape-string-regexp": "^4.0.0", + "find-root": "^1.1.0", + "source-map": "^0.5.7", + "stylis": "4.2.0" + } + }, + "node_modules/@emotion/babel-plugin/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@emotion/cache": { + "version": "11.14.0", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.14.0.tgz", + "integrity": "sha512-L/B1lc/TViYk4DcpGxtAVbx0ZyiKM5ktoIyafGkH6zg/tj+mA+NE//aPYKG0k8kCHSHVJrpLpcAlOBEXQ3SavA==", + "license": "MIT", + "dependencies": { + "@emotion/memoize": "^0.9.0", + "@emotion/sheet": "^1.4.0", + "@emotion/utils": "^1.4.2", + "@emotion/weak-memoize": "^0.4.0", + "stylis": "4.2.0" + } + }, + "node_modules/@emotion/hash": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.2.tgz", + "integrity": "sha512-MyqliTZGuOm3+5ZRSaaBGP3USLw6+EGykkwZns2EPC5g8jJ4z9OrdZY9apkl3+UP9+sdz76YYkwCKP5gh8iY3g==", + "license": "MIT" + }, + "node_modules/@emotion/memoize": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.9.0.tgz", + "integrity": "sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ==", + "license": "MIT" + }, + "node_modules/@emotion/react": { + "version": "11.14.0", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.14.0.tgz", + "integrity": "sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.18.3", + "@emotion/babel-plugin": "^11.13.5", + "@emotion/cache": "^11.14.0", + "@emotion/serialize": "^1.3.3", + "@emotion/use-insertion-effect-with-fallbacks": "^1.2.0", + "@emotion/utils": "^1.4.2", + "@emotion/weak-memoize": "^0.4.0", + "hoist-non-react-statics": "^3.3.1" + }, + "peerDependencies": { + "react": ">=16.8.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@emotion/serialize": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.3.3.tgz", + "integrity": "sha512-EISGqt7sSNWHGI76hC7x1CksiXPahbxEOrC5RjmFRJTqLyEK9/9hZvBbiYn70dw4wuwMKiEMCUlR6ZXTSWQqxA==", + "license": "MIT", + "dependencies": { + "@emotion/hash": "^0.9.2", + "@emotion/memoize": "^0.9.0", + "@emotion/unitless": "^0.10.0", + "@emotion/utils": "^1.4.2", + "csstype": "^3.0.2" + } + }, + "node_modules/@emotion/sheet": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.4.0.tgz", + "integrity": "sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg==", + "license": "MIT" + }, + "node_modules/@emotion/unitless": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.10.0.tgz", + "integrity": "sha512-dFoMUuQA20zvtVTuxZww6OHoJYgrzfKM1t52mVySDJnMSEa08ruEvdYQbhvyu6soU+NeLVd3yKfTfT0NeV6qGg==", + "license": "MIT" + }, + "node_modules/@emotion/use-insertion-effect-with-fallbacks": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.2.0.tgz", + "integrity": "sha512-yJMtVdH59sxi/aVJBpk9FQq+OR8ll5GT8oWd57UpeaKEVGab41JWaCFA7FRLoMLloOZF/c/wsPoe+bfGmRKgDg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.8.0" + } + }, + "node_modules/@emotion/utils": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.4.2.tgz", + "integrity": "sha512-3vLclRofFziIa3J2wDh9jjbkUz9qk5Vi3IZ/FSTKViB0k+ef0fPV7dYrUIugbgupYDx7v9ud/SjrtEP8Y4xLoA==", + "license": "MIT" + }, + "node_modules/@emotion/weak-memoize": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.4.0.tgz", + "integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==", + "license": "MIT" + }, + "node_modules/@floating-ui/core": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz", + "integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz", + "integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==", + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.8.0", + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz", + "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", + "license": "MIT" + }, + "node_modules/@forge/api": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/@forge/api/-/api-7.2.2.tgz", + "integrity": "sha512-q0TwkgzZqEbB1NNetQ9xRvNH6ICaX71QH884tduRzps+qnjuJYh0lJHKKxtwWMfZFdiILNRayhyAlvvuMskH3Q==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@forge/auth": "0.0.9", + "@forge/egress": "2.3.2", + "@forge/i18n": "0.0.7", + "@forge/manifest": "^12.9.0", + "@forge/storage": "2.0.3", + "headers-utils": "^3.0.2" + } + }, + "node_modules/@forge/auth": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@forge/auth/-/auth-0.0.9.tgz", + "integrity": "sha512-3qZZNknFprzDkrXzBVKHqVD12r/b2K9cu/RJh9TP3QLiF18v7bdoD1fgZZbVavKJUmCNdQERk6NTVQLmmEszhg==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "tslib": "^2.6.2" + } + }, + "node_modules/@forge/bridge": { + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/@forge/bridge/-/bridge-5.17.0.tgz", + "integrity": "sha512-f8uLJiHR2QY/kXrTvRDOrvJCh3RLlmDmyn/IXC5Xk7hIquH/F783ZyYwrsOyyxy/QkdQh3I8Hkgrmdul+AQZeA==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@atlaskit/adf-schema": "^48.0.0", + "@atlaskit/tokens": "^1.58.0", + "@forge/egress": "^2.3.2", + "@forge/i18n": "0.0.7", + "@forge/manifest": "12.9.0", + "@forge/resolver": "1.8.0", + "@types/history": "^4.7.11", + "@types/iframe-resizer": "^3.5.8", + "iframe-resizer": "^4.4.5" + } + }, + "node_modules/@forge/bridge/node_modules/@atlaskit/ds-lib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@atlaskit/ds-lib/-/ds-lib-2.7.0.tgz", + "integrity": "sha512-+U4aPE2dBRFUBYWCM9vkrwJGrLAYVcK30ZpEiQDNpM2D7K41223TfEijC8azaN4VM3tsCgwSKBWwniloNxqYbA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/platform-feature-flags": "^0.3.0", + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0", + "react-uid": "^2.2.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@forge/bridge/node_modules/@atlaskit/platform-feature-flags": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags/-/platform-feature-flags-0.3.0.tgz", + "integrity": "sha512-/0u5fFJ0Rw2j4M5wzsXgaHO6Ey12oekPCDTRvmmAIp4GO9T2Swbl80bavLAPSOmSHMhHTSuvRxiJveZXfQ21IQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + } + }, + "node_modules/@forge/bridge/node_modules/@atlaskit/tokens": { + "version": "1.61.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tokens/-/tokens-1.61.0.tgz", + "integrity": "sha512-gRkBDZOaQffJHg9g+hYFgPjQ0Hz4XIDaK5WEttIGyhi2USsGsvDvUeED8liqcQNwssH/5UFxIFp3FmEwo0DoFA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/ds-lib": "^2.6.0", + "@atlaskit/platform-feature-flags": "^0.3.0", + "@babel/runtime": "^7.0.0", + "@babel/traverse": "^7.23.2", + "@babel/types": "^7.20.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@forge/bridge/node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@forge/egress": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@forge/egress/-/egress-2.3.2.tgz", + "integrity": "sha512-p8ioX4qnAlRFln+hyH9kO0MmVCSOUg0bsIG9RAYK8KM2YaJb6EnKqbCvPMBTwegiua3vixBsnZmWDgPegSZh9Q==", + "license": "SEE LICENSE IN LICENSE.txt" + }, + "node_modules/@forge/i18n": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@forge/i18n/-/i18n-0.0.7.tgz", + "integrity": "sha512-EKrQApcuI4k4AkUSeERkZv1dQaGjWsmB8i7ciDPtpDARPRH1sOrU+FSEOoA7b9FQ15++7Q144m94w/aMLCg5Gg==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "lodash": "^4.17.21" + } + }, + "node_modules/@forge/manifest": { + "version": "12.9.0", + "resolved": "https://registry.npmjs.org/@forge/manifest/-/manifest-12.9.0.tgz", + "integrity": "sha512-7JZiXpAHa5SNSM4DsmaO1PfgZtHngKKwh1++RoYCS1QDuck1sJ2KXh3dq7FV+ajOKVtI54uyukUb7oYMGp7rPw==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@forge/i18n": "0.0.7", + "@sentry/node": "7.106.0", + "ajv": "^8.18.0", + "ajv-formats": "2.1.1", + "cheerio": "^1.1.0", + "glob": "^13.0.0", + "lodash": "^4.17.21", + "mime-types": "^2.1.35", + "yaml": "^2.3.4" + } + }, + "node_modules/@forge/react": { + "version": "11.17.0", + "resolved": "https://registry.npmjs.org/@forge/react/-/react-11.17.0.tgz", + "integrity": "sha512-78kXJrSf2s2NwXM4qqeJzP1ZOACwZNtssVuv8apjnvrYvNjjs41H8UZKBJMyw1jZk0o9R8Fbuzcjo4rlv+NN7Q==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@atlaskit/adf-schema": "^48.0.0", + "@atlaskit/adf-utils": "^19.19.0", + "@atlaskit/forge-react-types": "^1.7.0", + "@forge/bridge": "^5.17.0", + "@forge/egress": "^2.3.2", + "@forge/i18n": "0.0.7", + "@types/react": "^18.2.64", + "@types/react-reconciler": "^0.28.8", + "lodash": "^4.17.21", + "react": "^18.2.0", + "react-hook-form": "7.65.0", + "react-reconciler": "^0.29.0", + "react-test-renderer": "^18.2.0", + "uuid": "^9.0.1" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/analytics-next": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-11.3.0.tgz", + "integrity": "sha512-UDTl1YSRz7QCFXxTXctgsbVjXMVIIaoyqpH7SAZw2CRjKeTuihljtxBuv0C2EX5hocPS6b2KZKCwA4yEXHWozQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/app-provider": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@atlaskit/app-provider/-/app-provider-4.3.3.tgz", + "integrity": "sha512-hVOEl1VqwgUGVZOMfQsKIyg3DH7rYh/8qY5BXJuRKqw8Vn3ybexnkyeduQbfCP4rzLUnUUQCVhMxvTZhe+mDOw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/browser-apis": "^0.0.2", + "@atlaskit/css": "^0.19.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/avatar": { + "version": "25.15.1", + "resolved": "https://registry.npmjs.org/@atlaskit/avatar/-/avatar-25.15.1.tgz", + "integrity": "sha512-tWTdjed8UHD/nBC5jBPcoevrNbsHqriM4kmD2Z8OPdPUsy2ouFhbywXqA6Xol0ED7Du8Kd/TbeuUmwMpfn7V7g==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/badge": { + "version": "18.7.1", + "resolved": "https://registry.npmjs.org/@atlaskit/badge/-/badge-18.7.1.tgz", + "integrity": "sha512-H6Ic5ZOXgGEFfNwqnFcxIWzChoJIPUgzXfox2UHcHurBODSQaGFrNXApHMn0Qa+az+yqTmSdRWQOVaIBdZ+99Q==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.3.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/banner": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/banner/-/banner-14.1.0.tgz", + "integrity": "sha512-tgLEgyl/y/s6Nu+Fcvm/rbpeQDPwAJ6lWaCDO8u2tnTzsLrHTKo2VRMqjLMUAdecaW1LqHTaNxQNWT+U2Nh1+g==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^0.19.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/blanket": { + "version": "15.0.34", + "resolved": "https://registry.npmjs.org/@atlaskit/blanket/-/blanket-15.0.34.tgz", + "integrity": "sha512-BIO7KYWSL6p6t5AbrTbAtO86XSuuNF+qhm5c0hPv8nkRiAfVQW3WlDXly036oB1Kj/HtP0G6TIre/XXgKlr4yw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/breadcrumbs": { + "version": "16.1.1", + "resolved": "https://registry.npmjs.org/@atlaskit/breadcrumbs/-/breadcrumbs-16.1.1.tgz", + "integrity": "sha512-BkCgqW7CeEDk+rCue1dP2kWPx9PzsRXfp84NJCDaWpDCR28bo+PNpnTHFQoQm5RHIcs3wXWWhHwAlC9X9hjpEQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@atlaskit/tooltip": "^22.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/browser-apis": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-0.0.2.tgz", + "integrity": "sha512-3mfBAVBx8ReUlILUGdsc+G1JlrA0DvFAbOMorJfsIvsOqJViABxjQyW05psbnLoLZD/CT3+9jCHSHOIY8Gwtyw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/button": { + "version": "23.11.8", + "resolved": "https://registry.npmjs.org/@atlaskit/button/-/button-23.11.8.tgz", + "integrity": "sha512-ptEGHRfBLmEigbD2t0PkrZkQxMPtyuS6rtfW6htGQo3c+nilap85qNxZtkdOVfO3oPYTssVnOD663rnbd/CHnA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/focus-ring": "^3.1.0", + "@atlaskit/icon": "^35.1.0", + "@atlaskit/interaction-context": "^3.1.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/spinner": "^19.1.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.0.0", + "@atlaskit/tooltip": "^22.3.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "@emotion/react": "^11.7.1" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/calendar": { + "version": "17.2.20", + "resolved": "https://registry.npmjs.org/@atlaskit/calendar/-/calendar-17.2.20.tgz", + "integrity": "sha512-xBT7/Kca3b8aA4SLokGq91UlAdbhIEd2biXeWKNCJ6/tO7+UUPm3iIuzG1c5tXyzDY09JoatZt05c7iYWwA0MA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/heading": "^5.4.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/locale": "^4.1.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "date-fns": "^2.17.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/comment": { + "version": "13.3.1", + "resolved": "https://registry.npmjs.org/@atlaskit/comment/-/comment-13.3.1.tgz", + "integrity": "sha512-osYooHPajtJ9+MTTYPRDpVU/EB6yRFbnD9736zTcAOMsff7/9pIFwmH+bnoD8UNc/il2UKJi+se2+ItgKMXt/Q==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/lozenge": "^13.8.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/css": { + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/@atlaskit/css/-/css-0.19.4.tgz", + "integrity": "sha512-OBacSDD/XBkuu4R2FFMgOoVifSbs7E4LRwqUJFolPurxnsc88/cDrwf9C3obMwDh+64O3a5OyzuUPLVQTfMXYQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/datetime-picker": { + "version": "17.9.6", + "resolved": "https://registry.npmjs.org/@atlaskit/datetime-picker/-/datetime-picker-17.9.6.tgz", + "integrity": "sha512-Jml9iVsZxfxSaQoyjlWMRVb87RQe6VnTt64l7dHLyyMzFTR6RsXj6xxDBtZxpAvfAXduDRs2AhxeeKvcMyfIeA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/calendar": "^17.2.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.4.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/locale": "^4.1.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/popper": "^7.2.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/select": "^21.12.0", + "@atlaskit/tokens": "^13.4.0", + "@atlaskit/top-layer": "^0.18.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "date-fns": "^2.17.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/dynamic-table": { + "version": "18.4.2", + "resolved": "https://registry.npmjs.org/@atlaskit/dynamic-table/-/dynamic-table-18.4.2.tgz", + "integrity": "sha512-RkiMCuJ6tjhKhU8GYc/n+EyMR7mwF7zTY96bMXcQTwy+sVQufcDzwwwT1NZHOubCPxrNlURcqDpDVhNMEuEDnw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/pagination": "^16.3.0", + "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": "^2.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/spinner": "^19.1.0", + "@atlaskit/tokens": "^13.0.0", + "@atlaskit/tooltip": "^22.2.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/focus-ring": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/focus-ring/-/focus-ring-3.1.0.tgz", + "integrity": "sha512-mrXeeqrV0wVnru59ZfRBG9VitjQA13roEiwU4efOHM/mHGrkWsFiCTdmwJAJklyBddiemUTM08I/+Av+QHHBag==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@emotion/react": "^11.7.1" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/forge-react-types": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@atlaskit/forge-react-types/-/forge-react-types-1.7.1.tgz", + "integrity": "sha512-5u6RhFf7muciYP8/PeAhl2sLoU+QmCdGMkzC0kh9DnmVTs4votj+wUoJunc8gTE/qH2nIgMZIQapwi9QnX3vuQ==", + "dependencies": { + "@atlaskit/banner": "^14.1.0", + "@atlaskit/blanket": "^15.0.0", + "@atlaskit/breadcrumbs": "^16.1.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/comment": "^13.3.0", + "@atlaskit/datetime-picker": "^17.9.0", + "@atlaskit/dynamic-table": "^18.4.0", + "@atlaskit/form": "^15.5.0", + "@atlaskit/inline-edit": "^15.6.0", + "@atlaskit/modal-dialog": "^15.2.0", + "@atlaskit/navigation-system": "^9.4.0", + "@atlaskit/object": "^1.0.0", + "@atlaskit/pagination": "^16.3.0", + "@atlaskit/popup": "^4.23.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/progress-bar": "^4.2.0", + "@atlaskit/progress-tracker": "^10.5.0", + "@atlaskit/radio": "^8.6.0", + "@atlaskit/section-message": "^8.13.0", + "@atlaskit/select": "^21.12.0", + "@atlaskit/skeleton": "^2.1.0", + "@atlaskit/spinner": "^19.1.0", + "@atlaskit/tabs": "^19.1.0", + "@atlaskit/tag": "^14.15.0", + "@atlaskit/tag-group": "^12.1.0", + "@atlaskit/textarea": "^8.3.0", + "@atlaskit/textfield": "^8.3.0", + "@atlaskit/tile": "^1.1.0", + "@atlaskit/toggle": "^16.1.0", + "@atlaskit/tokens": "^13.3.0", + "@atlaskit/tooltip": "^22.6.0", + "@babel/runtime": "^7.0.0", + "@emotion/react": "^11.7.1", + "@emotion/serialize": "^1.1.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/form": { + "version": "15.5.6", + "resolved": "https://registry.npmjs.org/@atlaskit/form/-/form-15.5.6.tgz", + "integrity": "sha512-ocjHXkvNGUzjlGcwIabxX3SL27zsHD1R3idpATokQXbdELsyYQJuRu70NISEPQUQIIknPKQRm3eqMxlTGWhAtQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/heading": "^5.4.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "final-form": "^4.20.3", + "final-form-focus": "^1.1.2", + "lodash": "^4.17.21" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/heading": { + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/@atlaskit/heading/-/heading-5.4.2.tgz", + "integrity": "sha512-B4SMRq9sq3WWJYLo8Nx5731LvAjiev6dT3SbK1/dqSM+HXnrAy6GwEhW3oDJefeWYO7eZ9xPfuC3jpjdNBgxoA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/icon": { + "version": "35.4.0", + "resolved": "https://registry.npmjs.org/@atlaskit/icon/-/icon-35.4.0.tgz", + "integrity": "sha512-zE8DtQVaPTL3H6OSOwtgDihal0d5As/J3f4W2gzVLn9gOv24sFMlFC/GEEuotyYOFFwS7+NeT2pVqOi2IRv17g==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/tile": "^1.1.0", + "@atlaskit/tokens": "^13.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/icon-lab": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@atlaskit/icon-lab/-/icon-lab-6.14.0.tgz", + "integrity": "sha512-Yi9DZMM6siOH3AGDyL+iCsFie07mbMlOtl1bYFG70ta2LensVtfohZIWcm3LWweWL3Xcc4dosRKO8v22xmWg1A==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/icon": "^35.4.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/inline-dialog": { + "version": "18.1.14", + "resolved": "https://registry.npmjs.org/@atlaskit/inline-dialog/-/inline-dialog-18.1.14.tgz", + "integrity": "sha512-+qjmwAl3MNH5nzkOfHodz8q32P94EvFf4mMsDftaNimrZpWGDvcuxwXgdaa977jm2xGcixWchiYSK83OAZNGsA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/popper": "^7.2.0", + "@atlaskit/tokens": "^13.4.0", + "@atlaskit/top-layer": "^0.18.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/inline-edit": { + "version": "15.6.16", + "resolved": "https://registry.npmjs.org/@atlaskit/inline-edit/-/inline-edit-15.6.16.tgz", + "integrity": "sha512-gnbGq5sx+cy6RY3hsJn1wfiNCmSNRNDA2RvtkU8cuE4weGW1jurjGjnu+JCwtZ7Ry+xhTHkxV1lFF2xwPAZylQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/form": "^15.5.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/inline-dialog": "^18.1.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/textfield": "^8.3.0", + "@atlaskit/tokens": "^13.0.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/interaction-context": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-3.1.0.tgz", + "integrity": "sha512-LB3T0ATpJ5y7/IVBndNbcjtaNmPcz/8k7+smMibzphmV7xB3HaIyJFEu2JoSmgps66qLXo0ia8Hj7v4dF9zJZw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/layering": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@atlaskit/layering/-/layering-3.8.0.tgz", + "integrity": "sha512-PmwwvOuj2VhHU+LLsAwFl2VptWNn1aSuSoTXwsC0ZedV4M2WDr0yn0Z3ex0JGq7Za+6VOZsVhiBVW2jXW9a+0A==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/link": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/@atlaskit/link/-/link-3.4.2.tgz", + "integrity": "sha512-Y2aItT5nfxQhJu7RzgwKQImMp50aq58M3ccbTuqElnNNK7QHde37Hrvtxpia7WLwvJOpKYmxJnaM9yxbkDsYKQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^0.19.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/locale": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/locale/-/locale-4.1.0.tgz", + "integrity": "sha512-8WCpGFK5N5ySol5IooUx8FIwnWe8ykgE/aGp9D22swLrCE3+5IS49seeWfAXGvLV8GtXRoB6L2RtcCpgQEGT5Q==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/select": "^21.10.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/logo": { + "version": "20.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/logo/-/logo-20.2.0.tgz", + "integrity": "sha512-SKxR17k17O95BQCH5B8CW4XNPptJgu60rYg8C6WIAUpYoskC5IRpv6g/OlnuzgmYzg+pEK4w6eH8ntV4EyQ0Ng==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/lozenge": { + "version": "13.9.0", + "resolved": "https://registry.npmjs.org/@atlaskit/lozenge/-/lozenge-13.9.0.tgz", + "integrity": "sha512-xj3PncJ8h3qwjCwBqUyPJ6pWEr/J4oM1HOZhYblLHNGQ4DP4Vibaiiu5rJ1RWwcIFfg23oziJb4A4SbxFeZIfQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/badge": "^18.7.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.4.0", + "@atlaskit/motion": "^6.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/spinner": "^19.1.0", + "@atlaskit/tokens": "^13.3.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog": { + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/@atlaskit/modal-dialog/-/modal-dialog-15.3.1.tgz", + "integrity": "sha512-H1klgfteq3uTG2Ev4WlbNE2YjABlUJ6pekqOMgk8Zl8x+MNeDRGA9jRuaDr1vFAYZ6xexmGoWkUyXwKgGuil+g==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/blanket": "^15.0.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.4.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/motion": "^6.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/portal": "^5.5.0", + "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.4.0", + "@atlaskit/top-layer": "^0.18.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0", + "raf-schd": "^4.0.3", + "react-focus-lock": "^2.9.5", + "react-scrolllock": "^5.0.1" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog/node_modules/react-focus-lock": { + "version": "2.13.7", + "resolved": "https://registry.npmjs.org/react-focus-lock/-/react-focus-lock-2.13.7.tgz", + "integrity": "sha512-20lpZHEQrXPb+pp1tzd4ULL6DyO5D2KnR0G69tTDdydrmNhU7pdFmbQUYVyHUgp+xN29IuFR0PVuhOmvaZL9Og==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.0.0", + "focus-lock": "^1.3.6", + "prop-types": "^15.6.2", + "react-clientside-effect": "^1.2.7", + "use-callback-ref": "^1.3.3", + "use-sidecar": "^1.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog/node_modules/use-callback-ref": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", + "integrity": "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog/node_modules/use-sidecar": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", + "integrity": "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==", + "license": "MIT", + "dependencies": { + "detect-node-es": "^1.1.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/motion": { + "version": "6.2.5", + "resolved": "https://registry.npmjs.org/@atlaskit/motion/-/motion-6.2.5.tgz", + "integrity": "sha512-cYKzj5cS6nxF0lmfxXBRvYmmTys3SAYkLIl29z6/hFNELs4LpU+13CGtJz/0+lDl7X4Lnt5QWjrCJdoeoACKGA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/browser-apis": "^0.0.2", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/tokens": "^13.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/navigation-system": { + "version": "9.4.3", + "resolved": "https://registry.npmjs.org/@atlaskit/navigation-system/-/navigation-system-9.4.3.tgz", + "integrity": "sha512-Y8FOgCuRjryYsZhG58gZsEdYPre4F6oKo3OEG3nNlO7oXjjq43Skb3F+irvhlTs49jNNt/uW2VSzIBU/Sw+kBQ==", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/app-provider": "^4.3.0", + "@atlaskit/avatar": "^25.15.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.4.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/logo": "^20.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/platform-feature-flags-react": "^0.5.0", + "@atlaskit/popup": "^4.24.0", + "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/side-nav-items": "^1.14.0", + "@atlaskit/tokens": "^13.3.0", + "@atlaskit/tooltip": "^22.6.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0", + "raf-schd": "^4.0.3", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/object": { + "version": "1.0.17", + "resolved": "https://registry.npmjs.org/@atlaskit/object/-/object-1.0.17.tgz", + "integrity": "sha512-xM7r+JvcykGUkJ2t+VuN7LLuEnHJt/Go1OcipLkBkJRWq80G+WEFFQXxYyoVK0ejMbcnftLnEuDlZWFUmh9DXg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^0.19.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/icon-lab": "^6.9.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tile": "^1.1.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/pagination": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/@atlaskit/pagination/-/pagination-16.3.1.tgz", + "integrity": "sha512-lAJUAhD0TEKII+5bv6WOb3ysSrXzhmNcQ6JblnqhrkfQ3lKwfvtE3LBu4soj4AqflYoSSZFZ3CGXntnpMgbugQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "memoize-one": "^6.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/platform-feature-flags-react": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags-react/-/platform-feature-flags-react-0.5.1.tgz", + "integrity": "sha512-QAjrPOWFRn+ijGu/uz1MxT/pISNgy9XKH/mnUlcOGk2YsjsLtCiHyY68vKLC0PDxA5IbVtuHOqZYG8Cwfx2k3w==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/platform-feature-flags": "^1.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "react-magnetic-di": "^3.1.4" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/popper": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/popper/-/popper-7.2.0.tgz", + "integrity": "sha512-Uw2dzPblwwfYxs5VYIKhOCkwG1tSbmw+sALylsdCTXlVqKWHVxaNzZ24RCglol2BO5QUAT+YAZh1jbjgXyH8mQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "@popperjs/core": "^2.11.8", + "react-popper": "^2.3.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/popup": { + "version": "4.26.0", + "resolved": "https://registry.npmjs.org/@atlaskit/popup/-/popup-4.26.0.tgz", + "integrity": "sha512-awJboKQwWe2RpY1uzaHtV4WPPoeKC5xB8U4WLozUsyerq+PNKL2e/AtyUI4Sv1r9Vw55KCQ61Smc45CfhNP7Qg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/motion": "^6.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/popper": "^7.2.0", + "@atlaskit/portal": "^5.5.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.4.0", + "@atlaskit/top-layer": "^0.18.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0", + "focus-trap": "^2.4.5", + "memoize-one": "^6.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/portal": { + "version": "5.5.6", + "resolved": "https://registry.npmjs.org/@atlaskit/portal/-/portal-5.5.6.tgz", + "integrity": "sha512-sB+31TrDA/r6daytYawF1zGJoVG/hbfhosGIu2gKmg/8KM/waNGVYd2HlUPGmhbuFKxT5P+NbIAbOF/zHffnaQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/app-provider": "^4.3.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/theme": "^25.0.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration/-/pragmatic-drag-and-drop-react-beautiful-dnd-migration-2.1.1.tgz", + "integrity": "sha512-l/NIcq2VPbYyy78MMCsfuG3EoHynHytoXm6gB6/O42Y1npcDn1SkxAtblAF0vf3aw1G1rx6TioDBI26KvRg0RQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", + "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0", + "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^2.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@emotion/react": "^11.7.1", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/primitives": { + "version": "19.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/primitives/-/primitives-19.0.2.tgz", + "integrity": "sha512-vMp2L8NhNeEkDj26GtVeynx8yC//uhfzVgxgI06dpHQ2gTV/jZidaNGOWjXslCrOpfgZckAAG3x2JamT/95XGw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/app-provider": "^4.3.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/interaction-context": "^3.1.0", + "@atlaskit/tokens": "^13.2.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "@emotion/react": "^11.7.1", + "@emotion/serialize": "^1.1.0", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/progress-bar": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/progress-bar/-/progress-bar-4.2.0.tgz", + "integrity": "sha512-H9VlEFff8brF/3fLOf7kbEPzI2JJUN3FL983ReCY3McATh/5bZZf8WrPpl6id/TKL1QS/pyr6AGx708xwLdcwA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/progress-tracker": { + "version": "10.5.7", + "resolved": "https://registry.npmjs.org/@atlaskit/progress-tracker/-/progress-tracker-10.5.7.tgz", + "integrity": "sha512-jm5lvURQsFK0uAW5Kbx4NzD61fQmzL63oELxl5T4dl2MQcOhfS+xDzxswcFxG9RHeTaT64qypzQfB+TSBU9ryA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^0.19.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/radio": { + "version": "8.6.2", + "resolved": "https://registry.npmjs.org/@atlaskit/radio/-/radio-8.6.2.tgz", + "integrity": "sha512-52HKnWiIOfc35nCsd/gs7T+tLqHQDtA1C6kr/H9UjAzCPf0t37+e+7g7tqSM+s4Adz/+snXpkhdu26P/g7Be8A==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/react-select": { + "version": "3.16.2", + "resolved": "https://registry.npmjs.org/@atlaskit/react-select/-/react-select-3.16.2.tgz", + "integrity": "sha512-q9gLluaJZFG/S0YB848N/SIrc16RoAhrpXO0OfEVZqcv8Qd7d97+wZxd0rL/ynjZZZqdCGec+D7aJlDCFnY96A==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.3.0", + "@atlaskit/layering": "^3.7.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/spinner": "^19.1.0", + "@atlaskit/tag": "^14.14.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "@floating-ui/dom": "^1.0.1", + "memoize-one": "^6.0.0", + "use-isomorphic-layout-effect": "^1.1.2" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/section-message": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@atlaskit/section-message/-/section-message-8.13.0.tgz", + "integrity": "sha512-tibMfW9dY1IcFnupBIP1UIkVwaud3A5mwfHHrSxyFBV1fVhhvccS0WlLvMXceu3cui20Y6tB1CQzCR4mB8f+og==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/heading": "^5.4.0", + "@atlaskit/icon": "^35.0.0", + "@atlaskit/link": "^3.4.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/select": { + "version": "21.12.15", + "resolved": "https://registry.npmjs.org/@atlaskit/select/-/select-21.12.15.tgz", + "integrity": "sha512-Ad3llod6ZUA15u73dG7pflHYUY4l0T1UkOwnTWpc/4kvTdZ05gE0lU7nM7BlAP7Vet9ENq2Fq75WbfqY5aN7PA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.4.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/react-select": "^3.16.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.4.0", + "@atlaskit/top-layer": "^0.18.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "@popperjs/core": "^2.11.8", + "bind-event-listener": "^3.0.0", + "react-focus-lock": "^2.9.5", + "react-popper": "^2.3.0", + "shallow-equal": "^3.1.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/select/node_modules/react-focus-lock": { + "version": "2.13.7", + "resolved": "https://registry.npmjs.org/react-focus-lock/-/react-focus-lock-2.13.7.tgz", + "integrity": "sha512-20lpZHEQrXPb+pp1tzd4ULL6DyO5D2KnR0G69tTDdydrmNhU7pdFmbQUYVyHUgp+xN29IuFR0PVuhOmvaZL9Og==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.0.0", + "focus-lock": "^1.3.6", + "prop-types": "^15.6.2", + "react-clientside-effect": "^1.2.7", + "use-callback-ref": "^1.3.3", + "use-sidecar": "^1.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/select/node_modules/use-callback-ref": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", + "integrity": "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/select/node_modules/use-sidecar": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", + "integrity": "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==", + "license": "MIT", + "dependencies": { + "detect-node-es": "^1.1.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/side-nav-items": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@atlaskit/side-nav-items/-/side-nav-items-1.14.0.tgz", + "integrity": "sha512-z1l0beJB7ohMOuiky1vCXYoVqxtRuyXtckIiHkCo31C+47b4/PNq1dACeao2XftHld95uWHYbGjD3NfzQuUQlA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/avatar": "^25.15.0", + "@atlaskit/button": "^23.11.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/heading": "^5.4.0", + "@atlaskit/icon": "^35.4.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/platform-feature-flags-react": "^0.5.0", + "@atlaskit/popup": "^4.24.0", + "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", + "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.2.0", + "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.3.0", + "@atlaskit/tooltip": "^22.6.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/skeleton": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/skeleton/-/skeleton-2.2.0.tgz", + "integrity": "sha512-0Pu7Wmem6Nakr0hQ2PqLitDvSAhaHh4G+jPdIQWciaW5PMYdeXPtJ1LpkRiEjtzLU6mStPbr/X5HIH1QJiQsrQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/tokens": "^13.3.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/spinner": { + "version": "19.1.2", + "resolved": "https://registry.npmjs.org/@atlaskit/spinner/-/spinner-19.1.2.tgz", + "integrity": "sha512-Z2zOdi+zNd2qn8BrKOcxmHdlhcA1mNi3gGPklqW2MY+Ch/zL8WBTLia8KL5dIFwLjLG9C2J1u8OTYvtrZrhDhA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/interaction-context": "^3.1.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/tabs": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tabs/-/tabs-19.1.0.tgz", + "integrity": "sha512-Pzxg6lZWnXFq8kt++qA5zIznEAfgf9zyQU0mSuDN4O5hDcsfhs9rwGAxgjCszxuVOJNnh+DfBd+mjB1847SF3A==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/tag": { + "version": "14.16.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tag/-/tag-14.16.0.tgz", + "integrity": "sha512-6xeoT2tZdD8Va2imwiXivcAwBtXSN+bizaddqD6GaJMGy98JW3o8t36/mhiiNRlULwJDPy/SF0jfxnrtPV+zgA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/avatar": "^25.15.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.4.0", + "@atlaskit/link": "^3.4.0", + "@atlaskit/lozenge": "^13.8.0", + "@atlaskit/motion": "^6.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/spinner": "^19.1.0", + "@atlaskit/teams-avatar": "^2.7.0", + "@atlaskit/tokens": "^13.3.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/tag-group": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tag-group/-/tag-group-12.1.0.tgz", + "integrity": "sha512-Lafdgis655Cs25Ooj2kF0SB0z0J3Cm6Slj/+1VpmdGIPZebxoQzA5UqU6N8jFMRGY54VLdsUNVVd4oEFr3L8zg==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/teams-avatar": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@atlaskit/teams-avatar/-/teams-avatar-2.7.0.tgz", + "integrity": "sha512-pSgF0uL9ghbHzJ0IYB/cS28rCT1GnMNVMKfdj+bKyOrrhuhTE1Gc3MpbTY3OS9PNr+KqQfmFhFeKLAa9sbUqhg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/avatar": "^25.14.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/textarea": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/textarea/-/textarea-8.3.2.tgz", + "integrity": "sha512-HeVjb0ur18Go29fKMBZJpUFYwjUUVrxvBxsuvA/wwYvgzvr9DDwDS5Wx6vBDIiBOwND8YHYHC8cr+fmaSPBZ7w==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/textfield": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/textfield/-/textfield-8.3.2.tgz", + "integrity": "sha512-rj+XIWl1mh8CEj8DeVlEiMBaAnUTeCgtLiNfqsQxzvsaeLI+/YgIQqTsVpslLKhhiAyCI/bDW076PreNywpCiQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/theme": { + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/theme/-/theme-25.0.0.tgz", + "integrity": "sha512-zZFJla2cDQg9hM87L1AiSy6SvgYWyZQ2uw/bWLV6Cb/anat2/NVtQ9fxlOpVrCiq8yVZEnJNaY97gFQ8mL9lzA==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/tile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tile/-/tile-1.1.0.tgz", + "integrity": "sha512-ZvFITAzYx4IUV+V7OsLrdM1Hic9WQfK4nIebG4dHasssBjsJfdVQmLDsR/lHbop24cFENI4x/D75LcMtr+kQew==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/skeleton": "^2.1.0", + "@atlaskit/tokens": "^13.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/toggle": { + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/toggle/-/toggle-16.1.0.tgz", + "integrity": "sha512-L0jykH+WkvBjHZf2jXOumBkDwqj+Ew4c/BPPxcrxOemmxwdRt6a+3bIcDKVY9/bkf5SIBdcF3Pd+Gez3MB68bw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.2.0", + "@atlaskit/css": "^0.19.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/icon": "^35.3.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/primitives": "^19.0.0", + "@atlaskit/spinner": "^19.1.0", + "@atlaskit/tokens": "^13.1.0", + "@atlaskit/visually-hidden": "^3.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/tooltip": { + "version": "22.6.5", + "resolved": "https://registry.npmjs.org/@atlaskit/tooltip/-/tooltip-22.6.5.tgz", + "integrity": "sha512-MXIsyhlqVW9JJRCQOBok2E52+HPvLEcIu31fG6eHWpVCQ7tH+fQK7YjfxBDCALJw8a8VzkotzPEUeVofeB/nhA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^11.3.0", + "@atlaskit/ds-lib": "^7.0.0", + "@atlaskit/layering": "^3.8.0", + "@atlaskit/motion": "^6.2.0", + "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/popper": "^7.2.0", + "@atlaskit/portal": "^5.5.0", + "@atlaskit/theme": "^25.0.0", + "@atlaskit/tokens": "^13.4.0", + "@atlaskit/top-layer": "^0.18.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/visually-hidden": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/visually-hidden/-/visually-hidden-3.1.0.tgz", + "integrity": "sha512-OpwLmUZhbbo3NHKDjLl9JzKdHroeLPzRS1HTyHubJkC5DUWoOAH4cXStMpoesZ/Fqmbyz8O0Wb4K8RzpNZ7Jmw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "@compiled/react": "^0.20.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@forge/react/node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@forge/react/node_modules/react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "license": "MIT", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, + "peerDependencies": { + "react": "^18.3.1" + } + }, + "node_modules/@forge/react/node_modules/react-popper": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.3.0.tgz", + "integrity": "sha512-e1hj8lL3uM+sgSR4Lxzn5h1GxBlpa4CQz0XLF8kx4MDrDRWY0Ena4c97PUeSX9i5W3UAfDP0z0FXCTQkoXUl3Q==", "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.28.5", - "js-tokens": "^4.0.0", - "picocolors": "^1.1.1" + "react-fast-compare": "^3.0.1", + "warning": "^4.0.2" }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "@popperjs/core": "^2.0.0", + "react": "^16.8.0 || ^17 || ^18", + "react-dom": "^16.8.0 || ^17 || ^18" } }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", - "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "node_modules/@forge/react/node_modules/react-reconciler": { + "version": "0.29.2", + "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.29.2.tgz", + "integrity": "sha512-zZQqIiYgDCTP/f1N/mAR10nJGrPD2ZR+jDSEsKWJHYC7Cm2wodlwbR3upZRdC3cjIjSlTLNVyO7Iu0Yy7t2AYg==", "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, "engines": { - "node": ">=6.9.0" + "node": ">=0.10.0" + }, + "peerDependencies": { + "react": "^18.3.1" } }, - "node_modules/@forge/api": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/@forge/api/-/api-7.2.2.tgz", - "integrity": "sha512-q0TwkgzZqEbB1NNetQ9xRvNH6ICaX71QH884tduRzps+qnjuJYh0lJHKKxtwWMfZFdiILNRayhyAlvvuMskH3Q==", - "license": "SEE LICENSE IN LICENSE.txt", + "node_modules/@forge/react/node_modules/react-scrolllock": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-scrolllock/-/react-scrolllock-5.0.1.tgz", + "integrity": "sha512-poeEsjnZAlpA6fJlaNo4rZtcip2j6l5mUGU/SJe1FFlicEudS943++u7ZSdA7lk10hoyYK3grOD02/qqt5Lxhw==", + "license": "MIT", "dependencies": { - "@forge/auth": "0.0.9", - "@forge/egress": "2.3.2", - "@forge/i18n": "0.0.7", - "@forge/manifest": "^12.9.0", - "@forge/storage": "2.0.3", - "headers-utils": "^3.0.2" + "exenv": "^1.2.2" + }, + "peerDependencies": { + "react": "^16.3.0" } }, - "node_modules/@forge/auth": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/@forge/auth/-/auth-0.0.9.tgz", - "integrity": "sha512-3qZZNknFprzDkrXzBVKHqVD12r/b2K9cu/RJh9TP3QLiF18v7bdoD1fgZZbVavKJUmCNdQERk6NTVQLmmEszhg==", - "license": "SEE LICENSE IN LICENSE.txt", + "node_modules/@forge/react/node_modules/react-shallow-renderer": { + "version": "16.15.0", + "resolved": "https://registry.npmjs.org/react-shallow-renderer/-/react-shallow-renderer-16.15.0.tgz", + "integrity": "sha512-oScf2FqQ9LFVQgA73vr86xl2NaOIX73rh+YFqcOp68CWj56tSfgtGKrEbyhCj0rSijyG9M1CYprTh39fBi5hzA==", + "license": "MIT", "dependencies": { - "tslib": "^2.6.2" + "object-assign": "^4.1.1", + "react-is": "^16.12.0 || ^17.0.0 || ^18.0.0" + }, + "peerDependencies": { + "react": "^16.0.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/egress": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@forge/egress/-/egress-2.3.2.tgz", - "integrity": "sha512-p8ioX4qnAlRFln+hyH9kO0MmVCSOUg0bsIG9RAYK8KM2YaJb6EnKqbCvPMBTwegiua3vixBsnZmWDgPegSZh9Q==", - "license": "SEE LICENSE IN LICENSE.txt" - }, - "node_modules/@forge/i18n": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/@forge/i18n/-/i18n-0.0.7.tgz", - "integrity": "sha512-EKrQApcuI4k4AkUSeERkZv1dQaGjWsmB8i7ciDPtpDARPRH1sOrU+FSEOoA7b9FQ15++7Q144m94w/aMLCg5Gg==", - "license": "SEE LICENSE IN LICENSE.txt", + "node_modules/@forge/react/node_modules/react-test-renderer": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-18.3.1.tgz", + "integrity": "sha512-KkAgygexHUkQqtvvx/otwxtuFu5cVjfzTCtjXLH9boS19/Nbtg84zS7wIQn39G8IlrhThBpQsMKkq5ZHZIYFXA==", + "license": "MIT", "dependencies": { - "lodash": "^4.17.21" + "react-is": "^18.3.1", + "react-shallow-renderer": "^16.15.0", + "scheduler": "^0.23.2" + }, + "peerDependencies": { + "react": "^18.3.1" } }, - "node_modules/@forge/manifest": { - "version": "12.9.0", - "resolved": "https://registry.npmjs.org/@forge/manifest/-/manifest-12.9.0.tgz", - "integrity": "sha512-7JZiXpAHa5SNSM4DsmaO1PfgZtHngKKwh1++RoYCS1QDuck1sJ2KXh3dq7FV+ajOKVtI54uyukUb7oYMGp7rPw==", - "license": "SEE LICENSE IN LICENSE.txt", - "dependencies": { - "@forge/i18n": "0.0.7", - "@sentry/node": "7.106.0", - "ajv": "^8.18.0", - "ajv-formats": "2.1.1", - "cheerio": "^1.1.0", - "glob": "^13.0.0", - "lodash": "^4.17.21", - "mime-types": "^2.1.35", - "yaml": "^2.3.4" + "node_modules/@forge/react/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, "node_modules/@forge/resolver": { @@ -161,6 +2446,60 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@opentelemetry/api": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.10.0.tgz", + "integrity": "sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@sentry-internal/tracing": { "version": "7.106.0", "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.106.0.tgz", @@ -230,6 +2569,33 @@ "integrity": "sha512-MTBk/3jGLNB2tVxv6uLlFh1iu64iYOQ2PbdOSK3NW8JZsmlaOh2q6sdtKowBhfw8QFLmYNzTW4/oK4uATIi6ZA==", "license": "MIT" }, + "node_modules/@statsig/client-core": { + "version": "3.33.8", + "resolved": "https://registry.npmjs.org/@statsig/client-core/-/client-core-3.33.8.tgz", + "integrity": "sha512-5N1XnYMgjXGPwQFO2bsyq2i7NL2yh+Oi8NALIgKCxVL3333Le66iRemPyK61XjkuIXvlNRn7iwoEEdJ1DKxuMg==", + "license": "ISC" + }, + "node_modules/@statsig/js-client": { + "version": "3.33.8", + "resolved": "https://registry.npmjs.org/@statsig/js-client/-/js-client-3.33.8.tgz", + "integrity": "sha512-xyfeoSLqn+lJRWo+8k915vSJtf+iuglMakiYxhu0Y7Fjb01Gf1cLmjtuMJYdjC1XCkyGgmiHFDtlLVms7LOcUg==", + "license": "ISC", + "dependencies": { + "@statsig/client-core": "3.33.8" + } + }, + "node_modules/@types/history": { + "version": "4.7.11", + "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", + "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", + "license": "MIT" + }, + "node_modules/@types/iframe-resizer": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@types/iframe-resizer/-/iframe-resizer-3.5.13.tgz", + "integrity": "sha512-/Np2ntlOWd/NOHs23Mj7QlNEnZ6SL02AWWdYZLm4RQNukDdpqpagfMAdin5FvQDLngR8LWfh/qUnYxuDmR8BCg==", + "license": "MIT" + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", @@ -264,12 +2630,40 @@ "pretty-format": "^29.0.0" } }, + "node_modules/@types/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==", + "license": "MIT" + }, + "node_modules/@types/markdown-it": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.2.0.tgz", + "integrity": "sha512-NoQ2yGlLWj4wpxMs+TYmRKk3thDrQ97agr7sFqfLsAlvoS8SNQuTrlObhFqG9iugdTtgOE9jpJ6FNM4ZGsa5xQ==", + "license": "MIT", + "dependencies": { + "@types/linkify-it": "^5", + "@types/mdurl": "^2" + } + }, + "node_modules/@types/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==", + "license": "MIT" + }, "node_modules/@types/node": { "version": "14.18.63", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz", "integrity": "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==", "license": "MIT" }, + "node_modules/@types/parse-json": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz", + "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==", + "license": "MIT" + }, "node_modules/@types/prop-types": { "version": "15.7.15", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz", @@ -286,6 +2680,15 @@ "csstype": "^3.2.2" } }, + "node_modules/@types/react-reconciler": { + "version": "0.28.9", + "resolved": "https://registry.npmjs.org/@types/react-reconciler/-/react-reconciler-0.28.9.tgz", + "integrity": "sha512-HHM3nxyUZ3zAylX8ZEyrDNd2XZOnQ0D5XfunJF5FLQnZbHHYq4UWvW1QfelQNXv1ICNkwYhfxjwfnqivYB6bFg==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*" + } + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -355,6 +2758,12 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -370,6 +2779,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/babel-plugin-macros": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz", + "integrity": "sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5", + "cosmiconfig": "^7.0.0", + "resolve": "^1.19.0" + }, + "engines": { + "node": ">=10", + "npm": ">=6" + } + }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -379,12 +2803,24 @@ "node": "18 || 20 || >=22" } }, + "node_modules/bind-event-listener": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bind-event-listener/-/bind-event-listener-3.0.0.tgz", + "integrity": "sha512-PJvH288AWQhKs2v9zyfYdPzlPqf5bXbGMmhmUIY9x4dAUGIWgomO771oBQNwJnMQSnUIXhKu6sgzpBRXTlvb8Q==", + "license": "MIT" + }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", "license": "ISC" }, + "node_modules/bowser-ultralight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/bowser-ultralight/-/bowser-ultralight-1.0.6.tgz", + "integrity": "sha512-ASWi8n3c6JvsUhbjproHnT4Mdhs4Q9wOxq1oSjUkM2e5StEEUmy1ej4UNOLSyeU4ANQFTx+mY+bsv/aH+AIcpg==", + "license": "MIT" + }, "node_modules/brace-expansion": { "version": "5.0.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", @@ -456,6 +2892,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -547,6 +2992,55 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "license": "MIT" }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "license": "MIT" + }, + "node_modules/cosmiconfig": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", + "integrity": "sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==", + "license": "MIT", + "dependencies": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.2.1", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.10.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/cosmiconfig/node_modules/yaml": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.3.tgz", + "integrity": "sha512-vIYeF1u3CjlhAFekPPAk2h/Kv4T3mAkMox5OymRiJQB0spDP10LHvt+K7G9Ny6NuuMAb25/6n1qyUjAcGNf/AA==", + "license": "ISC", + "engines": { + "node": ">= 6" + } + }, + "node_modules/css-box-model": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/css-box-model/-/css-box-model-1.2.1.tgz", + "integrity": "sha512-a7Vr4Q/kd/aw96bnJG332W9V9LkJO69JRcaCYDUqjp6/z0w6VcZjgAcTbgFxEPfBgdnAwlh3iwu+hLopa+flJw==", + "license": "MIT", + "dependencies": { + "tiny-invariant": "^1.0.6" + } + }, + "node_modules/css-color-names": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", + "integrity": "sha512-zj5D7X1U2h2zsXOAM8EyUREBnnts6H+Jm+d1M2DbiQQcUtnqgQsMrdo8JW9R80YFUmIdBZeMu5wvYM7hcgWP/Q==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/css-select": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz", @@ -581,6 +3075,39 @@ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "license": "MIT" }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", @@ -598,6 +3125,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/detect-node-es": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", + "integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==", + "license": "MIT" + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -701,6 +3234,15 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/error-ex": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz", + "integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==", + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, "node_modules/es-define-property": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", @@ -740,6 +3282,24 @@ "node": ">=8" } }, + "node_modules/eventemitter2": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-4.1.2.tgz", + "integrity": "sha512-erx0niBaTi8B7ywjGAcg8ilGNRl/xs/o4MO2ZMpRlpZ62mYzjGTBlOpxxRIrPQqBs9mbXkEux6aR+Sc5vQ/wUw==", + "license": "MIT" + }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", + "license": "MIT" + }, + "node_modules/exenv": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/exenv/-/exenv-1.2.2.tgz", + "integrity": "sha512-Z+ktTxTwv9ILfgKCk32OX3n/doe+OcLTRtqK9pcL+JsP3J1/VW8Uvl4ZjLlKqeW4rzK4oesDOGMEMRIZqtP4Iw==", + "license": "BSD-3-Clause" + }, "node_modules/expect": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", @@ -796,6 +3356,58 @@ "node": ">=8" } }, + "node_modules/final-form": { + "version": "4.20.10", + "resolved": "https://registry.npmjs.org/final-form/-/final-form-4.20.10.tgz", + "integrity": "sha512-TL48Pi1oNHeMOHrKv1bCJUrWZDcD3DIG6AGYVNOnyZPr7Bd/pStN0pL+lfzF5BNoj/FclaoiaLenk4XUIFVYng==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.10.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/final-form" + } + }, + "node_modules/final-form-focus": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/final-form-focus/-/final-form-focus-1.1.2.tgz", + "integrity": "sha512-Gd+Bd2Ll7ijo3/sd6kJ/bwLkhc2bUJPxTON6fIqee/008EJpACWhT+zoWCm9q6NcfMcWRS+Sp5ikRX8iqdXeGQ==", + "license": "MIT", + "peerDependencies": { + "final-form": ">=1.3.0" + } + }, + "node_modules/find-root": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", + "license": "MIT" + }, + "node_modules/focus-lock": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/focus-lock/-/focus-lock-1.3.6.tgz", + "integrity": "sha512-Ik/6OCk9RQQ0T5Xw+hKNLWrjSMtv51dD4GRmJjbD5a58TIEpI5a5iXagKVl3Z5UuyslMCA8Xwnu76jQob62Yhg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/focus-trap": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-2.4.6.tgz", + "integrity": "sha512-vWZTPtBU6pBoyWZDRZJHkXsyP2ZCZBHE3DRVXnSVdQKH/mcDtu9S5Kz8CUDyIqpfZfLEyI9rjKJLnc4Y40BRBg==", + "license": "MIT", + "dependencies": { + "tabbable": "^1.0.3" + } + }, "node_modules/for-each": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", @@ -941,9 +3553,9 @@ } }, "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -958,6 +3570,21 @@ "integrity": "sha512-xAxZkM1dRyGV2Ou5bzMxBPNLoRCjcX+ya7KSWybQD2KwLphxsapUVK6x/02o7f4VU6GPSXch9vNY2+gkU8tYWQ==", "license": "MIT" }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "license": "BSD-3-Clause", + "dependencies": { + "react-is": "^16.7.0" + } + }, + "node_modules/hoist-non-react-statics/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "license": "MIT" + }, "node_modules/htmlparser2": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz", @@ -1001,12 +3628,48 @@ "node": ">=0.10.0" } }, + "node_modules/iframe-resizer": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/iframe-resizer/-/iframe-resizer-4.4.5.tgz", + "integrity": "sha512-U8bCywf/Gh07O69RXo6dXAzTtODQrxaHGHRI7Nt4ipXsuq6EMxVsOP/jjaP43YtXz/ibESS0uSVDN3sOGCzSmw==", + "hasInstallScript": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + }, + "funding": { + "type": "individual", + "url": "https://iframe-resizer.com//pricing" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "license": "ISC" }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "license": "MIT" + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -1019,6 +3682,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-core-module": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.18.0.tgz", + "integrity": "sha512-qyax9fgaKOEC4qK8WZn7Q4IcoZC9RC1O1fFxRcRTq/oMMkWT/uXpqpXa12kzWR409zAt1drYN9N9BO26UmBCmw==", + "license": "MIT", + "dependencies": { + "hasown": "^2.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -1131,18 +3809,63 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "license": "MIT" }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "license": "MIT" + }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "license": "MIT" }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "license": "MIT" + }, + "node_modules/linkify-it": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", + "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", + "license": "MIT", + "dependencies": { + "uc.micro": "^1.0.1" + } + }, "node_modules/lodash": { "version": "4.18.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "license": "MIT" }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/lru-cache": { "version": "11.5.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", @@ -1152,6 +3875,58 @@ "node": "20 || >=22" } }, + "node_modules/markdown-it": { + "version": "14.3.3", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.3.tgz", + "integrity": "sha512-L//tDAkjTjJCU6pBUSBTgs3Kg4InVaZuUZog/b6V12UKhcDQ7S78877ibbCanRExwPuYP1CZD7Gd2dxSy1GXRg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.5.0", + "linkify-it": "^5.0.2", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it/node_modules/linkify-it": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", + "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/markdown-it/node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "license": "MIT" + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -1161,6 +3936,18 @@ "node": ">= 0.4" } }, + "node_modules/mdurl": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz", + "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==", + "license": "MIT" + }, + "node_modules/memoize-one": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz", + "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==", + "license": "MIT" + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -1220,6 +4007,12 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", @@ -1232,6 +4025,51 @@ "url": "https://github.com/fb55/nth-check?sponsor=1" } }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/orderedmap": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz", + "integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==", + "license": "MIT" + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/parse5": { "version": "7.3.0", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", @@ -1281,6 +4119,12 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "license": "MIT" + }, "node_modules/path-scurry": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-3.0.0.tgz", @@ -1297,6 +4141,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -1350,12 +4203,251 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/prop-types/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "license": "MIT" + }, + "node_modules/prosemirror-commands": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.7.1.tgz", + "integrity": "sha512-rT7qZnQtx5c0/y/KlYaGvtG411S97UaL6gdp6RIZ23DLHanMYLyfGBV5DtSnZdthQql7W+lEVbpSfwtO8T+L2w==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.10.2" + } + }, + "node_modules/prosemirror-dropcursor": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.2.tgz", + "integrity": "sha512-CCk6Gyx9+Tt2sbYk5NK0nB1ukHi2ryaRgadV/LvyNuO3ena1payM2z6Cg0vO1ebK8cxbzo41ku2DE5Axj1Zuiw==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0", + "prosemirror-view": "^1.1.0" + } + }, + "node_modules/prosemirror-history": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.5.0.tgz", + "integrity": "sha512-zlzTiH01eKA55UAf1MEjtssJeHnGxO0j4K4Dpx+gnmX9n+SHNlDqI2oO1Kv1iPN5B1dm5fsljCfqKF9nFL6HRg==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.2.2", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.31.0", + "rope-sequence": "^1.3.0" + } + }, + "node_modules/prosemirror-keymap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.3.tgz", + "integrity": "sha512-4HucRlpiLd1IPQQXNqeo81BGtkY8Ai5smHhKW9jjPKRc2wQIxksg7Hl1tTI2IfT2B/LgX6bfYvXxEpJl7aKYKw==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.0.0", + "w3c-keyname": "^2.2.0" + } + }, + "node_modules/prosemirror-markdown": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.4.tgz", + "integrity": "sha512-D98dm4cQ3Hs6EmjK500TdAOew4Z03EV71ajEFiWra3Upr7diytJsjF4mPV2dW+eK5uNectiRj0xFxYI9NLXDbw==", + "license": "MIT", + "dependencies": { + "@types/markdown-it": "^14.0.0", + "markdown-it": "^14.0.0", + "prosemirror-model": "^1.25.0" + } + }, + "node_modules/prosemirror-model": { + "version": "1.25.4", + "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.4.tgz", + "integrity": "sha512-PIM7E43PBxKce8OQeezAs9j4TP+5yDpZVbuurd1h5phUxEKIu+G2a+EUZzIC5nS1mJktDJWzbqS23n1tsAf5QA==", + "license": "MIT", + "dependencies": { + "orderedmap": "^2.0.0" + } + }, + "node_modules/prosemirror-state": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz", + "integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.27.0" + } + }, + "node_modules/prosemirror-transform": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.11.0.tgz", + "integrity": "sha512-4I7Ce4KpygXb9bkiPS3hTEk4dSHorfRw8uI0pE8IhxlK2GXsqv5tIA7JUSxtSu7u8APVOTtbUBxTmnHIxVkIJw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.21.0" + } + }, + "node_modules/prosemirror-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/prosemirror-utils/-/prosemirror-utils-1.2.2.tgz", + "integrity": "sha512-7a2MPf99oCW8/587rQYI1/snX71Ban40+apr1hLkY8TmU9YXd7JeR6QsmktcTisJURO3WRjxIia4lTMsYgZVOw==", + "license": "Apache-2.0", + "peerDependencies": { + "prosemirror-model": "^1.19.2", + "prosemirror-state": "^1.4.3" + } + }, + "node_modules/prosemirror-view": { + "version": "1.41.7", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.7.tgz", + "integrity": "sha512-jUwKNCEIGiqdvhlS91/2QAg21e4dfU5bH2iwmSDQeosXJgKF7smG0YSplOWK0cjSNgIqXe7VXqo7EIfUFJdt3w==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.20.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0" + } + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/raf-schd": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/raf-schd/-/raf-schd-4.0.3.tgz", + "integrity": "sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ==", + "license": "MIT" + }, + "node_modules/react": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-clientside-effect": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/react-clientside-effect/-/react-clientside-effect-1.2.8.tgz", + "integrity": "sha512-ma2FePH0z3px2+WOu6h+YycZcEvFmmxIlAb62cF52bG86eMySciO/EQZeQMXd07kPCYB0a1dWDT5J+KE9mCDUw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.13" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + } + }, + "node_modules/react-dom": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", + "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "scheduler": "^0.28.0" + }, + "peerDependencies": { + "react": "^19.3.1" + } + }, + "node_modules/react-dom/node_modules/scheduler": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", + "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", + "license": "MIT", + "peer": true + }, + "node_modules/react-fast-compare": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.4.tgz", + "integrity": "sha512-YbkgZfjvuokdt6zR8Oki8Bt4QXAZim/9HKSUr5J23GVyX2o8sYD/JlKSFrJvEFIPjotWvkGY7DgUS+udyr8cEw==", + "license": "MIT" + }, + "node_modules/react-hook-form": { + "version": "7.65.0", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.65.0.tgz", + "integrity": "sha512-xtOzDz063WcXvGWaHgLNrNzlsdFgtUWcb32E6WFaGTd7kPZG3EeDusjdZfUsPwKCKVXy1ZlntifaHZ4l8pAsmw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-hook-form" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17 || ^18 || ^19" + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", "license": "MIT" }, + "node_modules/react-magnetic-di": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/react-magnetic-di/-/react-magnetic-di-3.2.5.tgz", + "integrity": "sha512-Ys0noNfKOlnU7nPk7j8V/OxvXe66XMnXwtie8phGsHbPLOHzua82C5aWW1UUzMCWR9F4kBej8VErFq2TndFDkw==", + "license": "MIT", + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "prop-types": "^15.0.0", + "react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/react-uid": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/react-uid/-/react-uid-2.4.0.tgz", + "integrity": "sha512-+MVs/25NrcZuGrmlVRWPOSsbS8y72GJOBsR7d68j3/wqOrRBF52U29XAw4+XSelw0Vm6s5VmGH5mCbTCPGVCVg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -1365,6 +4457,42 @@ "node": ">=0.10.0" } }, + "node_modules/resolve": { + "version": "1.22.14", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.14.tgz", + "integrity": "sha512-1ZjYvR9sbkiwC5+9QHetqW5HmA2pHRMaoupD01t2HlYnV/vydC2zPwLixhsMieSWVZt0JJRg5LVIk0Ow1D/TrA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.18.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/rope-sequence": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz", + "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==", + "license": "MIT" + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1391,6 +4519,15 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "license": "MIT" }, + "node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -1428,6 +4565,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/shallow-equal": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/shallow-equal/-/shallow-equal-3.1.0.tgz", + "integrity": "sha512-pfVOw8QZIXpMbhBWvzBISicvToTiM5WBF1EeAUZDDSb5Dt29yl4AYbyywbJFSEsRUMr7gJaxqCdr4L3tQf9wVg==", + "license": "MIT" + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -1437,6 +4580,15 @@ "node": ">=8" } }, + "node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", @@ -1449,6 +4601,12 @@ "node": ">=10" } }, + "node_modules/stylis": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", + "integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==", + "license": "MIT" + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -1461,6 +4619,30 @@ "node": ">=8" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tabbable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-1.1.3.tgz", + "integrity": "sha512-nOWwx35/JuDI4ONuF0ZTo6lYvI0fY0tZCH1ErzY2EXfu4az50ZyiUX8X073FLiZtmWUVlkRnuXsehjJgCw9tYg==", + "license": "MIT" + }, + "node_modules/tiny-invariant": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", + "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==", + "license": "MIT" + }, "node_modules/to-buffer": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.2.2.tgz", @@ -1507,6 +4689,12 @@ "node": ">= 0.4" } }, + "node_modules/uc.micro": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", + "license": "MIT" + }, "node_modules/undici": { "version": "7.30.2", "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.2.tgz", @@ -1516,6 +4704,49 @@ "node": ">=20.18.1" } }, + "node_modules/use-isomorphic-layout-effect": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.2.1.tgz", + "integrity": "sha512-tpZZ+EX0gaghDAiFR37hj5MgY6ZN55kLiPkJsKxBMZ6GZdOSPJXiOzPM984oPYZ5AnehYx5WQp1+ME8I/P/pRA==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "license": "MIT" + }, + "node_modules/warning": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", + "integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.0.0" + } + }, "node_modules/whatwg-encoding": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", diff --git a/coderhelm-jira/package.json b/coderhelm-jira/package.json index b64092755..58f1af792 100644 --- a/coderhelm-jira/package.json +++ b/coderhelm-jira/package.json @@ -4,8 +4,11 @@ }, "dependencies": { "@forge/api": "^7.1.1", + "@forge/bridge": "^5.17.0", + "@forge/react": "^11.17.0", "@forge/resolver": "^1.8.0", - "@forge/ui": "^1.11.4" + "@forge/ui": "^1.11.4", + "react": "^19.3.1" }, "overrides": { "glob": "^14.0.2" diff --git a/coderhelm-jira/src/frontend/link.jsx b/coderhelm-jira/src/frontend/link.jsx new file mode 100644 index 000000000..ea04da089 --- /dev/null +++ b/coderhelm-jira/src/frontend/link.jsx @@ -0,0 +1,63 @@ +// The "Link my CoderHelm account" action, in Jira's own UI Kit: a field for +// the code from CoderHelm's For you page and one button. The resolver +// (src/link.js) does the work; this only shows what it says. + +import React, { useState } from "react"; +import ForgeReconciler, { Box, Button, Form, FormFooter, FormSection, Label, SectionMessage, Stack, Text, Textfield, useForm } from "@forge/react"; +import { invoke, view } from "@forge/bridge"; + +function LinkAccount() { + const { handleSubmit, register, getFieldId } = useForm(); + const [result, setResult] = useState(null); + const [busy, setBusy] = useState(false); + + const link = async (data) => { + setBusy(true); + try { + setResult(await invoke("linkAccount", { code: data.code })); + } catch (e) { + setResult({ ok: false, message: "CoderHelm couldn't be reached. Try again in a minute." }); + } finally { + setBusy(false); + } + }; + + return ( + + + Paste the code from CoderHelm's For you page (Connect Jira). CoderHelm then knows this Jira account is yours and shows your sprint there. Only your account id is sent, never your name or email. + + {result ? ( + + {result.message} + + ) : null} + {result && result.ok ? ( + + ) : ( +
+ + + + + + + + + + +
+ )} +
+ ); +} + +ForgeReconciler.render( + + + , +); diff --git a/coderhelm-jira/src/issues.js b/coderhelm-jira/src/issues.js index 47cda6d69..95c403a64 100644 --- a/coderhelm-jira/src/issues.js +++ b/coderhelm-jira/src/issues.js @@ -112,12 +112,118 @@ function issueOf(raw, links) { /** The most issues one "what is waiting on me" read returns, of each kind. */ const MAX_MINE = 15; +// ── The person's open sprint (CoderHelm's For you page) ───────────────────── + +/** The most sprint issues one read returns. */ +const MAX_SPRINT = 50; +/** The characters of a description sent back (the fit checklist reads it). */ +const MAX_DESCRIPTION_CHARS = 4000; + +/** + * The JQL for "my open sprint": the person's unfinished issues in every open + * sprint, in board order. The app runs as itself (asApp), where + * currentUser() would be the app, so the account id is written in; it is + * checked to be an account id first, so it can't end the string. + */ +function sprintJql(accountId) { + const id = String(accountId || ""); + if (!/^[A-Za-z0-9:-]{8,128}$/.test(id)) return null; + return `assignee = "${id}" AND sprint in openSprints() AND statusCategory != Done ORDER BY rank ASC`; +} + +/** + * The site's story point and sprint fields, from GET /rest/api/3/field. + * Their ids differ per site (customfield_10016 on one, 10026 on another), so + * they are found by their type: Jira Software's story points (or a number + * field named "Story points" / "Story point estimate") and its sprint field. + */ +function fieldIds(fields) { + const list = Array.isArray(fields) ? fields : []; + const custom = (f) => (f && f.schema && f.schema.custom) || ""; + const points = + list.find((f) => custom(f).endsWith(":jsw-story-points")) || + list.find((f) => /^story points?( estimate)?$/i.test(String((f && f.name) || "").trim()) && f.schema && f.schema.type === "number") || + null; + const sprint = list.find((f) => custom(f) === "com.pyxis.greenhopper.jira:gh-sprint") || null; + return { points: points ? points.id : null, sprint: sprint ? sprint.id : null }; +} + +/** The open sprint an issue is in (the active one when it is in several). */ +function openSprintOf(value) { + const all = (Array.isArray(value) ? value : []).filter((s) => s && typeof s === "object"); + const open = all.filter((s) => s.state === "active"); + const s = open[0] || all.find((x) => x.state === "future") || null; + if (!s) return null; + return { id: s.id || null, name: String(s.name || ""), state: String(s.state || ""), end_date: String(s.endDate || "") }; +} + +/** One sprint issue as the fit checklist reads it. */ +function sprintIssueOf(raw, ids) { + const f = (raw && raw.fields) || {}; + const pts = ids && ids.points ? f[ids.points] : null; + return { + key: raw.key, + summary: f.summary || "", + type: (f.issuetype && f.issuetype.name) || "", + status: (f.status && f.status.name) || "", + status_category: (f.status && f.status.statusCategory && f.status.statusCategory.key) || "", + priority: (f.priority && f.priority.name) || "", + assignee_id: accountIdOf(f.assignee), + labels: Array.isArray(f.labels) ? f.labels.filter((l) => typeof l === "string").slice(0, 30) : [], + components: (Array.isArray(f.components) ? f.components : []).map((c) => (c && c.name) || "").filter(Boolean).slice(0, 10), + points: typeof pts === "number" && Number.isFinite(pts) ? pts : null, + description: adfText(f.description).trim().slice(0, MAX_DESCRIPTION_CHARS), + sprint: ids && ids.sprint ? openSprintOf(f[ids.sprint]) : null, + updated: f.updated || "", + }; +} + +/** + * What "Give to CoderHelm" may do to an issue, checked before any call: a + * real key, the team's trigger label (letters, digits and : / . _ -), and + * the giver's account id. `null` when any is wrong. + */ +function giveRequest(give) { + const key = String((give && give.key) || ""); + const label = String((give && give.label) || ""); + const accountId = String((give && give.account_id) || ""); + if (!/^[A-Z][A-Z0-9_]{0,19}-\d{1,7}$/.test(key)) return null; + if (!/^[A-Za-z0-9_:\/.-]{1,100}$/.test(label)) return null; + if (!/^[A-Za-z0-9:-]{8,128}$/.test(accountId)) return null; + return { key, label, accountId }; +} + +/** + * The label updates that make Jira send the change CoderHelm starts on: an + * add, or (when the label is already there, from an earlier run) a remove + * then an add, since an unchanged label sends no event. + */ +function labelSteps(labels, label) { + const has = (Array.isArray(labels) ? labels : []).includes(label); + return has ? [{ remove: label }, { add: label }] : [{ add: label }]; +} + +/** The fields a sprint read asks Jira for. */ +function sprintFields(ids) { + const base = ["summary", "issuetype", "status", "priority", "assignee", "labels", "components", "description", "updated"]; + return [...base, ...[ids && ids.points, ids && ids.sprint].filter(Boolean)]; +} + module.exports = { adfText, adfMentions, jqlFor, mineJql, issueOf, + sprintJql, + giveRequest, + labelSteps, + fieldIds, + openSprintOf, + sprintIssueOf, + sprintFields, + MAX_SPRINT, + MAX_DESCRIPTION_CHARS, MAX_SEARCH, MAX_MINE, MAX_ISSUE_COMMENTS, diff --git a/coderhelm-jira/src/link-resolver.js b/coderhelm-jira/src/link-resolver.js new file mode 100644 index 000000000..55d052ab3 --- /dev/null +++ b/coderhelm-jira/src/link-resolver.js @@ -0,0 +1,12 @@ +// The resolver behind "Link my CoderHelm account" (manifest: linkResolver). +// The work and its tests are in link.js; this file only wires it to Forge. + +const Resolver = require("@forge/resolver").default; +const { linkAccount } = require("./link"); + +const resolver = new Resolver(); + +// `context.accountId` is the person who opened the action, set by Forge. +resolver.define("linkAccount", ({ payload, context }) => linkAccount(payload, context)); + +exports.handler = resolver.getDefinitions(); diff --git a/coderhelm-jira/src/link.js b/coderhelm-jira/src/link.js new file mode 100644 index 000000000..e1b0d65fa --- /dev/null +++ b/coderhelm-jira/src/link.js @@ -0,0 +1,110 @@ +// "Link my CoderHelm account": a person proves which Jira account is theirs. +// +// CoderHelm's For you page shows a person their own sprint, and starts work +// on a ticket with them as its owner. For that it must know which Jira +// account belongs to which CoderHelm user, and an email match can't tell: +// Atlassian lets people hide their email, and work and sign-in emails often +// differ. So the link is made by the person, from both sides at once: +// +// 1. On CoderHelm's For you page they ask for a one-time code (it is +// signed for their team and works for fifteen minutes). +// 2. Here, from any issue's "..." menu, they open "Link my CoderHelm +// account" and paste it. +// 3. This resolver sends the code with the account id Forge gives for the +// person who opened the action (`context.accountId`: Forge sets it, the +// person can't type another one) to CoderHelm, proven by the site's +// Forge secret like every event the app sends. +// +// CoderHelm then stores which CoderHelm user that Jira account is. Nothing +// about the person (no name, no email) is sent: only the account id and the +// code. Unlinking is on the For you page. + +/** The Forge SDK, loaded when first used, so this file (and its tests) load without it. */ +function forge() { + return require("@forge/api"); +} + +const { GATEWAY_URL } = require("./gateway"); +const { versionFields } = require("./version"); + +/** A code as CoderHelm shows it (ABCD-EFGH-JKMN-PQRS), typed loosely. */ +function cleanCode(raw) { + const code = String(raw || "") + .toUpperCase() + .replace(/[^0-9A-Z]/g, ""); + return code.length === 16 ? code : null; +} + +/** The body sent to CoderHelm: the team's proof, the account and the code. */ +function linkBody(config, accountId, code, getAppContext) { + return { + coderhelm: { + team_id: config.teamId, + forge_secret: config.forgeSecret, + ...versionFields(getAppContext), + }, + account_id: accountId, + code, + }; +} + +/** What the person reads after CoderHelm answered `status` with `body`. */ +function linkResult(status, body) { + const said = body && typeof body.message === "string" ? body.message : ""; + if (status === 200) { + return { ok: true, message: said || "Linked. Your sprint shows on CoderHelm's For you page." }; + } + if (status === 410 || status === 404) { + return { ok: false, message: said || "That code has expired or was already used. Make a new one on the For you page." }; + } + if (status === 409) { + return { ok: false, message: said || "This Jira account is already linked to another CoderHelm user." }; + } + if (status === 400) { + return { ok: false, message: said || "That isn't a CoderHelm code. Copy it again from the For you page." }; + } + if (status === 403 || status === 401) { + return { ok: false, message: "CoderHelm didn't recognize this Jira site. Ask your Jira admin to check the app's settings." }; + } + return { ok: false, message: `CoderHelm couldn't link the account right now (${status}). Try again in a minute.` }; +} + +/** + * Links the account of the person who opened the action. `deps` are the + * Forge pieces, passed in by tests. + */ +async function linkAccount(payload, context, deps = {}) { + const storage = deps.storage || forge().storage; + const fetch = deps.fetch || forge().fetch; + const accountId = String((context && context.accountId) || ""); + if (!/^[A-Za-z0-9:-]{8,128}$/.test(accountId)) { + return { ok: false, message: "Jira didn't say who you are. Open the action from an issue while signed in." }; + } + const code = cleanCode(payload && payload.code); + if (!code) { + return { ok: false, message: "That isn't a CoderHelm code. It has 16 letters and numbers, like ABCD-EFGH-JKMN-PQRS." }; + } + const config = await storage.get("coderhelm-config"); + if (!config || !config.teamId || !config.forgeSecret) { + return { ok: false, message: "This Jira site isn't connected to CoderHelm yet. Ask your Jira admin to set it up." }; + } + try { + const res = await fetch(`${GATEWAY_URL}/webhooks/jira-link`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(linkBody(config, accountId, code, deps.getAppContext)), + }); + let body = null; + try { + body = await res.json(); + } catch (_) { + body = null; + } + return linkResult(res.status, body); + } catch (e) { + console.error("Link my CoderHelm account failed:", e); + return { ok: false, message: "CoderHelm couldn't be reached. Try again in a minute." }; + } +} + +module.exports = { cleanCode, linkBody, linkResult, linkAccount }; diff --git a/coderhelm-jira/src/release.js b/coderhelm-jira/src/release.js index 50b10fb52..3650feafc 100644 --- a/coderhelm-jira/src/release.js +++ b/coderhelm-jira/src/release.js @@ -7,7 +7,7 @@ const api = require("@forge/api"); const { storage, route } = api; -const { jqlFor, mineJql, issueOf, MAX_SEARCH, MAX_MINE } = require("./issues"); +const { jqlFor, mineJql, issueOf, MAX_SEARCH, MAX_MINE, sprintJql, fieldIds, sprintIssueOf, sprintFields, MAX_SPRINT, giveRequest, labelSteps } = require("./issues"); const json = (statusCode, obj) => ({ statusCode, @@ -90,9 +90,81 @@ async function mineHandler(mine) { }); } +/** Where the site's story point and sprint field ids are kept, and for how long. */ +const FIELDS_KEY = "coderhelm-fields"; +const FIELDS_FOR_MS = 24 * 3600 * 1000; + +/** The site's story point and sprint field ids, read once a day. */ +async function siteFields() { + const kept = await storage.get(FIELDS_KEY).catch(() => null); + if (kept && kept.at && Date.now() - kept.at < FIELDS_FOR_MS) return kept.ids; + const res = await api.asApp().requestJira(route`/rest/api/3/field`); + if (!res.ok) return { points: null, sprint: null }; + const ids = fieldIds(await res.json()); + await storage.set(FIELDS_KEY, { at: Date.now(), ids }).catch(() => {}); + return ids; +} + +/** + * The "my open sprint" read (CoderHelm's For you page): the person's + * unfinished issues in open sprints, with status, points, labels, + * components and the description, one search. + */ +async function sprintHandler(sprint) { + const accountId = String((sprint && sprint.account_id) || ""); + const jql = sprintJql(accountId); + if (!jql) { + return json(200, { issues: [], sprint: { found: false, why: "no Jira account id was sent" } }); + } + const ids = await siteFields(); + const res = await api.asApp().requestJira(route`/rest/api/3/search/jql`, { + method: "POST", + headers: { Accept: "application/json", "Content-Type": "application/json" }, + body: JSON.stringify({ jql, maxResults: MAX_SPRINT, fields: sprintFields(ids) }), + }); + if (!res.ok) { + return json(200, { issues: [], sprint: { found: false, why: `Jira answered ${res.status} to the sprint search` } }); + } + const found = await res.json(); + const issues = ((found && found.issues) || []).map((raw) => sprintIssueOf(raw, ids)); + return json(200, { + issues, + sprint: { found: true, account_id: accountId, points_field: Boolean(ids.points), sprint_field: Boolean(ids.sprint) }, + }); +} + +/** + * "Give to CoderHelm" from the For you page: the issue gets the team's + * trigger label, exactly as a person adding it in Jira would, so the run + * starts through the same path (the label's event). Only an issue assigned + * to the giver: the app checks the assignee itself before it writes. + */ +async function giveHandler(give) { + const req = giveRequest(give); + if (!req) return json(200, { given: { ok: false, why: "the request was not a valid issue, label and account" } }); + const res = await api.asApp().requestJira(route`/rest/api/3/issue/${req.key}?fields=assignee,labels`); + if (!res.ok) return json(200, { given: { ok: false, why: `Jira answered ${res.status} for ${req.key}` } }); + const fields = ((await res.json()) || {}).fields || {}; + const assignee = (fields.assignee && fields.assignee.accountId) || ""; + if (assignee !== req.accountId) { + return json(200, { given: { ok: false, why: `${req.key} isn't assigned to you` } }); + } + for (const step of labelSteps(fields.labels, req.label)) { + const put = await api.asApp().requestJira(route`/rest/api/3/issue/${req.key}`, { + method: "PUT", + headers: { Accept: "application/json", "Content-Type": "application/json" }, + body: JSON.stringify({ update: { labels: [step] } }), + }); + if (!put.ok) return json(200, { given: { ok: false, why: `Jira answered ${put.status} when adding the label` } }); + } + return json(200, { given: { ok: true, key: req.key } }); +} + /** * POST { forge_secret, keys: ["ABC-1", ...] } or { forge_secret, query: "words" } * or { forge_secret, mine: { account_id?, email? } } + * or { forge_secret, sprint: { account_id } } + * or { forge_secret, give: { key, label, account_id } } * → { issues: [{key, summary, type, status, assignee, priority, updated, created, comments, links}] } * * By keys: each issue the app can read (release notes, Chat). By query: the @@ -105,6 +177,8 @@ exports.getIssuesHandler = async (request) => { const body = JSON.parse(request.body || "{}"); if (!(await authorized(body))) return json(403, { error: "forbidden" }); if (body.mine && typeof body.mine === "object") return await mineHandler(body.mine); + if (body.sprint && typeof body.sprint === "object") return await sprintHandler(body.sprint); + if (body.give && typeof body.give === "object") return await giveHandler(body.give); let keys = (Array.isArray(body.keys) ? body.keys : []) .filter((k) => /^[A-Z][A-Z0-9]+-\d+$/.test(k)) .slice(0, 50); diff --git a/coderhelm-jira/test/issues.test.js b/coderhelm-jira/test/issues.test.js index 0b69060da..63aea17c3 100644 --- a/coderhelm-jira/test/issues.test.js +++ b/coderhelm-jira/test/issues.test.js @@ -70,3 +70,80 @@ test("the waiting-on-me JQL takes only an account id, never more clauses", () => assert.equal(mineJql('x" OR project = SECRET'), null); assert.equal(mineJql(""), null); }); + +// ── The person's open sprint (For you) ─────────────────────────────────────── +const { sprintJql, fieldIds, sprintIssueOf, sprintFields, openSprintOf } = require("../src/issues"); + +test("the sprint search names the person's account id, since the app runs as itself", () => { + assert.equal( + sprintJql("557058:aaaa1111-0000-0000-0000-000000000001"), + 'assignee = "557058:aaaa1111-0000-0000-0000-000000000001" AND sprint in openSprints() AND statusCategory != Done ORDER BY rank ASC', + ); + assert.doesNotMatch(sprintJql("557058:aaaa1111-0000-0000-0000-000000000001"), /currentUser/); + assert.equal(sprintJql('x" OR assignee is not EMPTY'), null); + assert.equal(sprintJql(""), null); +}); + +test("story points and the sprint field are found by type, whatever their ids", () => { + const fields = [ + { id: "summary", name: "Summary", schema: { type: "string" } }, + { id: "customfield_10020", name: "Sprint", schema: { type: "array", custom: "com.pyxis.greenhopper.jira:gh-sprint" } }, + { id: "customfield_10016", name: "Story point estimate", schema: { type: "number", custom: "com.pyxis.greenhopper.jira:jsw-story-points" } }, + ]; + assert.deepEqual(fieldIds(fields), { points: "customfield_10016", sprint: "customfield_10020" }); + assert.deepEqual(fieldIds([{ id: "customfield_10026", name: "Story Points", schema: { type: "number" } }]), { points: "customfield_10026", sprint: null }); + assert.deepEqual(fieldIds([{ id: "customfield_1", name: "Story Points", schema: { type: "string" } }]), { points: null, sprint: null }); + assert.deepEqual(fieldIds(null), { points: null, sprint: null }); + assert.deepEqual(sprintFields({ points: "customfield_10016", sprint: null }).slice(-1), ["customfield_10016"]); +}); + +test("a sprint issue carries what the fit checklist reads", () => { + const ids = { points: "customfield_10016", sprint: "customfield_10020" }; + const raw = { + key: "BOOK-118", + fields: { + summary: "Fix the broken help link in the refund email", + issuetype: { name: "Story" }, + status: { name: "To Do", statusCategory: { key: "new" } }, + priority: { name: "Medium" }, + assignee: { accountId: "557058:a1", displayName: "Dana Ortiz" }, + labels: ["coderhelm:acme/web", 7], + components: [{ name: "Emails" }], + description: doc("Change web/src/emails/refund.tsx"), + customfield_10016: 1, + customfield_10020: [ + { id: 23, name: "Sprint 23", state: "closed", endDate: "2027-01-01T00:00:00.000Z" }, + { id: 24, name: "Sprint 24", state: "active", endDate: "2027-01-21T00:00:00.000Z" }, + ], + updated: "2027-01-15T10:00:00.000+0000", + }, + }; + const i = sprintIssueOf(raw, ids); + assert.equal(i.key, "BOOK-118"); + assert.equal(i.status_category, "new"); + assert.deepEqual(i.labels, ["coderhelm:acme/web"]); + assert.deepEqual(i.components, ["Emails"]); + assert.equal(i.points, 1); + assert.equal(i.description, "Change web/src/emails/refund.tsx"); + assert.deepEqual(i.sprint, { id: 24, name: "Sprint 24", state: "active", end_date: "2027-01-21T00:00:00.000Z" }); + assert.equal(i.assignee_id, "557058:a1"); + assert.equal(sprintIssueOf({ key: "BOOK-1", fields: { customfield_10016: "3" } }, ids).points, null); + assert.equal(openSprintOf([]), null); +}); + +const { giveRequest, labelSteps } = require("../src/issues"); + +test("Give to CoderHelm checks the key, label and account before any call", () => { + const ok = giveRequest({ key: "BOOK-112", label: "coderhelm", account_id: "557058:a1b2c3d4" }); + assert.deepEqual(ok, { key: "BOOK-112", label: "coderhelm", accountId: "557058:a1b2c3d4" }); + assert.equal(giveRequest({ key: "book-112", label: "coderhelm", account_id: "557058:a1b2c3d4" }), null); + assert.equal(giveRequest({ key: "BOOK-112", label: "a b", account_id: "557058:a1b2c3d4" }), null); + assert.equal(giveRequest({ key: "BOOK-112", label: "coderhelm", account_id: 'x" OR 1=1' }), null); + assert.deepEqual(giveRequest({ key: "BOOK-112", label: "coderhelm:acme/web", account_id: "557058:a1b2c3d4" }).label, "coderhelm:acme/web"); +}); + +test("a label already on the issue is taken off and put back, so Jira sends the change", () => { + assert.deepEqual(labelSteps(["ui"], "coderhelm"), [{ add: "coderhelm" }]); + assert.deepEqual(labelSteps(["coderhelm"], "coderhelm"), [{ remove: "coderhelm" }, { add: "coderhelm" }]); + assert.deepEqual(labelSteps(undefined, "coderhelm"), [{ add: "coderhelm" }]); +}); diff --git a/coderhelm-jira/test/link.test.js b/coderhelm-jira/test/link.test.js new file mode 100644 index 000000000..e13e9bdbe --- /dev/null +++ b/coderhelm-jira/test/link.test.js @@ -0,0 +1,75 @@ +// "Link my CoderHelm account": the person who opened the action is the +// account sent (Forge's context, never typed), with only the one-time code +// and the site's proof; nothing else about the person leaves Jira. + +const { test } = require("node:test"); +const assert = require("node:assert/strict"); +const { cleanCode, linkBody, linkResult, linkAccount } = require("../src/link"); + +const ME = "557058:aaaa1111-0000-0000-0000-000000000001"; +const CONFIG = { teamId: "team-acme", forgeSecret: "s3cret" }; + +function deps(status, body, seen = []) { + return { + storage: { get: async () => CONFIG }, + fetch: async (url, init) => { + seen.push({ url, body: JSON.parse(init.body) }); + return { status, json: async () => body }; + }, + getAppContext: () => ({ appVersion: "7.1.0", appAri: "ari:cloud:ecosystem::app/00000000-0000-0000-0000-000000000001" }), + }; +} + +test("a code is read the way people paste it", () => { + assert.equal(cleanCode("abcd-efgh-jkmn-pqrs"), "ABCDEFGHJKMNPQRS"); + assert.equal(cleanCode(" ABCD EFGH JKMN PQRS "), "ABCDEFGHJKMNPQRS"); + assert.equal(cleanCode("ABCD-EFGH"), null); + assert.equal(cleanCode(""), null); +}); + +test("the account sent is the one Forge says opened the action, with the code and the site's proof only", async () => { + const seen = []; + const r = await linkAccount({ code: "abcd-efgh-jkmn-pqrs", accountId: "557058:someone-else" }, { accountId: ME }, deps(200, { message: "Linked to Dana Ortiz in CoderHelm." }, seen)); + assert.deepEqual(r, { ok: true, message: "Linked to Dana Ortiz in CoderHelm." }); + assert.equal(seen.length, 1); + assert.match(seen[0].url, /\/webhooks\/jira-link$/); + assert.equal(seen[0].body.account_id, ME, "never an id from the payload"); + assert.equal(seen[0].body.code, "ABCDEFGHJKMNPQRS"); + assert.equal(seen[0].body.coderhelm.team_id, "team-acme"); + assert.equal(seen[0].body.coderhelm.forge_secret, "s3cret"); + assert.equal(seen[0].body.coderhelm.app_version, "7.1.0"); + assert.deepEqual(Object.keys(seen[0].body).sort(), ["account_id", "code", "coderhelm"]); + assert.doesNotMatch(JSON.stringify(seen[0].body), /email|displayName|name/); +}); + +test("nothing is sent without a signed-in person, a code or the site's setup", async () => { + const seen = []; + assert.equal((await linkAccount({ code: "abcd-efgh-jkmn-pqrs" }, {}, deps(200, {}, seen))).ok, false); + assert.equal((await linkAccount({ code: "nope" }, { accountId: ME }, deps(200, {}, seen))).ok, false); + const unset = { ...deps(200, {}, seen), storage: { get: async () => null } }; + const r = await linkAccount({ code: "abcd-efgh-jkmn-pqrs" }, { accountId: ME }, unset); + assert.equal(r.ok, false); + assert.match(r.message, /isn't connected to CoderHelm/); + assert.equal(seen.length, 0); +}); + +test("each answer from CoderHelm says what to do next", () => { + assert.equal(linkResult(200, {}).ok, true); + assert.match(linkResult(410, {}).message, /expired or was already used/); + assert.match(linkResult(409, {}).message, /already linked to another/); + assert.match(linkResult(400, {}).message, /isn't a CoderHelm code/); + assert.match(linkResult(403, {}).message, /didn't recognize this Jira site/); + assert.match(linkResult(500, {}).message, /\(500\)/); + assert.equal(linkResult(409, { message: "Unlink it on For you first." }).message, "Unlink it on For you first."); +}); + +test("a network failure is said, never thrown", async () => { + const broken = { ...deps(200, {}), fetch: async () => { throw new Error("offline"); } }; + const r = await linkAccount({ code: "abcd-efgh-jkmn-pqrs" }, { accountId: ME }, broken); + assert.deepEqual(r, { ok: false, message: "CoderHelm couldn't be reached. Try again in a minute." }); +}); + +test("the body is built from the stored setup", () => { + const b = JSON.parse(JSON.stringify(linkBody(CONFIG, ME, "ABCDEFGHJKMNPQRS", () => ({})))); + assert.deepEqual(b, { coderhelm: { team_id: "team-acme", forge_secret: "s3cret" }, account_id: ME, code: "ABCDEFGHJKMNPQRS" }); +}); diff --git a/coderhelm-jira/test/manifest.test.js b/coderhelm-jira/test/manifest.test.js index 00641eaec..4d892c9b1 100644 --- a/coderhelm-jira/test/manifest.test.js +++ b/coderhelm-jira/test/manifest.test.js @@ -25,3 +25,13 @@ test("no source file calls Confluence", () => { assert.doesNotMatch(fs.readFileSync(path.join(root, "src", f), "utf8"), /requestConfluence/, f); } }); + +test("Link my CoderHelm account is an issue action that adds no scope or web trigger", () => { + assert.match(manifest, /jira:issueAction:\n\s+- key: coderhelm-link-account\n\s+title: Link my CoderHelm account/); + assert.match(manifest, /handler: link-resolver\.handler/); + // A new web trigger or scope would make a major version every site admin + // must accept; linking needs neither (it posts to the gateway the app + // already reaches). + const triggers = manifest.split("webtrigger:")[1].split("jira:issueAction:")[0]; + assert.equal((triggers.match(/- key:/g) || []).length, 5); +}); diff --git a/docs/for-you.md b/docs/for-you.md new file mode 100644 index 000000000..b9f980880 --- /dev/null +++ b/docs/for-you.md @@ -0,0 +1,86 @@ +# For you + +One person's own page in the dashboard: what needs them now (grouped by whose turn it is), their open sprint with a fit band per ticket, what CoderHelm is doing for them, their pull requests waiting on others, Later, three private numbers, and suggestions. The dashboard's **For you** page reads it from `GET /api/foryou`. + +## Who it is for + +Every route reads the session's team and the session's user. None takes a user, an email or a login (`docs/incidents/ya_for_you_is_only_yours.md`). + +- **GitHub**: the login on the session (`claims.github_login`), set by GitHub sign-in. +- **Jira**: the account the person linked themselves. On the dashboard, `POST /api/foryou/link/jira` makes a one-time code (16 characters, signed for the team, 15 minutes, stored by its hash under `FORYOU#CODE#`). In Jira, the app's **Link my CoderHelm account** issue action (`coderhelm-jira/src/link.js`) sends it with the account id Forge gives for the person who opened it, to `POST /webhooks/jira-link`, proven by the site's Forge secret. The code is checked against its signature first, then used up in the same delete that reads it. The link is two rows on the settings table: `FORYOU#JIRA#` (the account id) and `linked_user` on the account's own `JIRAUSER#` row. An account is linked to one person at a time. `DELETE /api/foryou/link/jira` removes both. +- An email never makes a link. A Jira user seen with the person's sign-in email, linked to nobody, is offered as "Is this you?" (`common::foryou::identity_suggestion`); yes starts the code flow, `POST /api/foryou/link/jira/not-me` stops asking. Chat's "what needs me" (`chat_work_needs::gather`) reads the same link and nothing else. + +## What it reads (nothing forked) + +- **Pull requests**: the records `GET /api/prs` reads (`prs::read_all`, `pr_view::rows`, the state from `pr_needs::decide`), grouped by `common::foryou::pr_group`: reviews asked of you, your pull requests (and CoderHelm's for you) returned to you, and yours waiting on someone else. No GitHub calls. +- **Runs, held tool calls, Jira mentions and assigned tickets**: `chat_work_needs::gather`, with the runs read once and the linked account passed in, GitHub left to the records. +- **The open sprint**: the Jira app's get-issues trigger with `{ "sprint": { "account_id" } }`. The app runs as itself, so the account id is written into the JQL: `assignee = "" AND sprint in openSprints() AND statusCategory != Done ORDER BY rank ASC`. Story points and the sprint field are found per site by type (`fieldIds`). An app without the mode answers without `sprint`: the page says the site's app is older. +- **History**: `pr_history::all_since` (90 days), for the review turnaround and the files a person changed. +- The heavy reads are kept 30 seconds per installation, team and user (`foryou::READS`); the person's settings are read fresh. + +## The fit bands + +`common::foryou::fit`, a checklist with reasons and what is missing, never a percentage: + +- **Not suggested**: on the exclude list by title, type, labels or components (security, auth and permissions, personal data, incidents, production-critical, highest priority, three or more repositories), 8 points or more, or neither a repository nor acceptance criteria. +- **Good fit**: acceptance criteria, one repository known (a `coderhelm:` label, a repository the ticket names, or where the project's earlier runs went), 3 points or less (or a short description with no estimate), files or an area named, and tests not known to be missing. +- **Maybe (plan first)**: the rest. + +## Give to CoderHelm + +- `GET /api/foryou/give?key=` previews: the fit, the repositories, the files named, the criteria, and that the plan comes first (the planner has no dry-run mode). +- `POST /api/foryou/give {key, plan_first}` (the "runs" capability) accepts only a ticket in the person's own open sprint, writes `FORYOU#GIVE#` (the owner, their Jira account, `plan_first`), and asks the Jira app (`{ "give": { key, label, account_id } }`) to add the team's trigger label. The app checks the ticket is assigned to that account first. Jira sends the change like any label, and the run starts on the label path (`jira_webhook::ticket_triggers`); `foryou_give::owner_for_event` credits the person who gave it as the requester, once, within 15 minutes. CoderHelm is the delegate; the ticket stays assigned to the person. Answered `202` at once. +- With `plan_first`, the worker stops once the plan passes its checks and asks `common::foryou::PLAN_QUESTION`. The stop judge settles it by rule (`Picture::plan_first_for`, `PersonOnly::PlanApproval`): no model call, no default, no deadline. Answering "Approve the plan and start coding" on the run page starts the next run, which codes and marks the give approved. + +## Suggestions + +One per row, on a new or changed item only (`common::foryou::reconcile`): + +- **give**: a good-fit ticket in the sprint. The basis is the ticket's text, estimate, status and repositories. +- **review**: an open pull request in its first review with no reviewer asked, in files the person changed in at least two of their merged pull requests. Accepting asks GitHub to add them as a reviewer (`POST /api/foryou/suggestions {action: "accept"}`). + +A suggestion stays about a week when nothing changes, then rests. A changed basis withdraws the old one with its reason; one no longer computed is withdrawn once with why ("Someone else picked it up: @mara took the review of acme/web#478"). Dismissing is one click; a reason then does one fixed thing (`DISMISS_REASONS`): already handled (hidden until the basis changes), not now (tomorrow 9:00), not me (never for that target), don't suggest this kind (the kind is muted until turned back on in Customize). Snooze: later today, tomorrow, after the sprint. Undo reverses the last change and its reason. + +## The person's settings + +`FORYOU#USER#` holds the layout (section order, hidden sections, the right side's cards, the landing page), snoozed and done items, the last change per key for Undo, the suggestions shown with their basis, muted kinds, "not me" targets, and "Is this you?" answers. Written with a version check. `PUT /api/foryou/prefs`, `POST /api/foryou/items {key, action: snooze|done|undo}`, `POST /api/foryou/suggestions {key, action: dismiss|reason|snooze|undo|accept}`. + +## GET /api/foryou + +```json +{ + "viewer": {"name": "Dana Ortiz", "github": "dana-ortiz"}, + "header": {"needs": 6, "working": 2, "waiting": 3}, + "needs": { + "reviews": [NeedItem], "suggested_reviews": [NeedItem], "returned": [NeedItem], "asks": [NeedItem] + }, + "sprint": {"state": "ok|not_linked|not_connected|app_old|failed", "detail": "", "meta": {"name": "Sprint 24", "project": "ENG", "end_date": "...", "days_left": 6, "points": 21}, "tickets": [Ticket]}, + "working": [{"run_id": "...", "ticket": "ENG-142", "repo": "acme/web", "title": "...", "started_at": "...", "stage": "planning|coding|ci|waiting", "stage_label": "CI", "note": "...", "waiting_on_you": false, "plan_first": false, "owner": "you", "delegate": "CoderHelm", "pr": {"url": "...", "number": "491"}, "href": "/runs/detail?id=..."}], + "waiting": [{"key": "pr:acme/api#477", "where": "acme/api#477", "title": "...", "next": {"who": "mara", "what": "needs review", "text": "...", "turn": "person"}, "since": "...", "by_coderhelm": false, "href": "...", "nudge_href": "..."}], + "later": [{"key": "...", "later": "snoozed|not_in_sprint|fyi", "title": "...", "where": "...", "snoozed_until": "...", "href": "..."}], + "stats": { + "waiting_on_you": {"count": 6, "oldest": {"where": "acme/web#482", "since": "..."}}, + "waiting_on_others": {"count": 3, "longest": {"where": "acme/api#477", "since": "..."}}, + "review_turnaround": {"median_secs": 15000, "reviews": 9, "days": 28} + }, + "suggestions": [Suggestion], + "suggestion_summary": {"count": 3, "kinds": [{"kind": "give", "count": 2, "text": "2 tickets CoderHelm can take"}], "top": [], "batch": {"kind": "give", "keys": ["WEB-42", "ENG-142"], "text": "Give both to CoderHelm"}}, + "withdrawn": [{"key": "review:acme/web#478", "kind": "review", "target": "pr:acme/web#478", "text": "...", "withdrawn_reason": "..."}], + "accounts": {"github": {"state": "linked", "login": "dana-ortiz"}, "jira": {"state": "linked|not_linked|not_connected", "name": "Dana Ortiz", "suggestion": null}}, + "prefs": {"layout": {"order": [], "rail": [], "hidden": [], "landing": ""}, "muted_kinds": []}, + "synced_at": "...", + "sources": [{"name": "Jira", "read": "ok|failed|off|old", "detail": ""}] +} +``` + +`NeedItem`: `key`, `group` (`reviews|returned|asks`), `kind` (the pull request's state, or `question|plan|wait|approval|not_requested`), `label`, `where`, `title`, `why`, `since`, `who`, `by_coderhelm`, `action {label, href}`, `href`, `pr`, `run_id`, `ticket`, `suggested`. + +`Ticket`: `key`, `title`, `url`, `status`, `status_category`, `points`, `type`, `repos`, `repo_source` (`label|ticket|history`), `fit {band, label, kind, why[], missing[], excluded}` (only on a ticket not started and not with CoderHelm), `delegated {run_id, status, stage, label, waiting_on_you, plan_first}` (`stage` `starting` or `not_started` before the run appears), `note`. + +`Suggestion`: `key`, `kind` (`give|review`), `target` (`ticket:ENG-142`, `pr:acme/billing#218`), `text`, `action`, `href`, `reason`, `evidence[] {text, href}`, `effect`, `effort`, `deadline`, `as_of`, `kind_words`, `dismiss_reasons[] {code, label, effect}`, `back_because`. + +The stats are the session's own; nothing else computes them, and no route reads another person's. + +## Permissions + +`GET /api/foryou` and the preview need "view". Settings, marks, suggestions and linking are the person's own ("own_account"). Giving a ticket needs "runs". diff --git a/docs/incidents/ya_for_you_is_only_yours.md b/docs/incidents/ya_for_you_is_only_yours.md new file mode 100644 index 000000000..26f4322c6 --- /dev/null +++ b/docs/incidents/ya_for_you_is_only_yours.md @@ -0,0 +1,5 @@ +# ya. `ya_for_you_is_only_yours` + +**What happened:** The For you page shows one person their own reviews, pull requests, sprint tickets and private numbers. Three ways it could go wrong were found while it was designed. A route taking a user would let anyone read anyone's page. The private numbers (what waits on you, your median review turnaround) read for someone else would turn a private rail into a ranking. And Chat's "what needs me" matched a CoderHelm user to a Jira account by email, which the page was to reuse: Atlassian lets people hide their email, and a work email can differ from the sign-in one, so the wrong person's sprint could show, or anyone whose email matched could take over another person's account. + +**The guarantee:** Every For you route reads only the session's team and user. None takes a user, an email or a login, and the short cache is keyed by the installation, the team and the session user. The numbers are computed for the session's own GitHub login only, and only the For you page computes them. A Jira account is linked only by a one-time code the person makes on the dashboard, signed for their team and used up once, redeemed from the Jira app's "Link my CoderHelm account" as that account. An email match is at most an "Is this you?" suggestion, and Chat reads only the link. A Jira event that refreshes a person's name never erases who linked the account. diff --git a/services/Cargo.lock b/services/Cargo.lock index a72917a5a..08b6138c9 100644 --- a/services/Cargo.lock +++ b/services/Cargo.lock @@ -1916,6 +1916,7 @@ dependencies = [ "serde_yaml", "sha2 0.10.9", "sqlparser", + "subtle", "tokio", "tracing", "ulid", diff --git a/services/common/Cargo.toml b/services/common/Cargo.toml index 9c60da329..486e9d42f 100644 --- a/services/common/Cargo.toml +++ b/services/common/Cargo.toml @@ -28,6 +28,7 @@ aws-sdk-sqs = { version = "1", default-features = false, features = ["default-ht aws-sdk-scheduler = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] } # plugins: Slack request signatures hex = "0.4" +subtle = "2" # embed: Titan embeddings on CoderHelm's own AWS account, metered aws-sdk-bedrockruntime = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] } # knowledge: a Bedrock knowledge base connected in place, searched live in diff --git a/services/common/src/foryou.rs b/services/common/src/foryou.rs new file mode 100644 index 000000000..4aede1424 --- /dev/null +++ b/services/common/src/foryou.rs @@ -0,0 +1,1978 @@ +//! The "For you" page: what is one person's, decided in code. +//! +//! Everything here is pure, so each rule is a test: +//! +//! - **Identity.** A Jira account is linked to a dashboard user only by a +//! signed one-time code the person makes on the dashboard and redeems from +//! the Jira app as themselves ([`issue_code`], [`verify_code`]). An email +//! match is never a link: it is at most an "Is this you?" suggestion +//! ([`identity_suggestion`]) whose "yes" starts that same code flow. +//! - **Fit bands.** Whether a sprint ticket suits CoderHelm: Good fit, Maybe +//! (plan first) or Not suggested, with the reasons and what is missing +//! ([`fit`]). A checklist, never a score or a percentage. +//! - **Needs, grouped by whose turn it is** ([`pr_group`]) and the private +//! stats: what waits on you, your pull requests waiting on others, and +//! your median review turnaround ([`review_turnaround`]). +//! - **Suggestions** and their lifecycle ([`reconcile`]): one per row, shown +//! only on a new or changed item, withdrawn with its reason when its basis +//! changes, dismissed in one click with optional reasons that each make a +//! fixed, visible change ([`DISMISS_REASONS`]). +//! - **The person's own settings** ([`Prefs`]): section order and hidden +//! sections, the landing page, snoozed and done items, dismissals and +//! muted kinds. Stored per user, read by nobody else. +//! +//! All rows live on the settings table under the team's partition key; the +//! user's id is part of every sort key, and no route takes a user parameter. + +use std::collections::{BTreeMap, BTreeSet}; + +use hmac::{Hmac, Mac}; +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; + +// ── Keys ──────────────────────────────────────────────────────────────────── + +/// One person's settings and marks: `FORYOU#USER#`. +pub const USER_PREFIX: &str = "FORYOU#USER#"; +/// The Jira account a person linked: `FORYOU#JIRA#` holds +/// `account_id`. The account's own `JIRAUSER#` row holds +/// `linked_user` back. +pub const JIRA_LINK_PREFIX: &str = "FORYOU#JIRA#"; +/// A one-time link code, by its hash: `FORYOU#CODE#`. +pub const CODE_PREFIX: &str = "FORYOU#CODE#"; +/// A ticket given to CoderHelm from For you: `FORYOU#GIVE#`. +pub const GIVE_PREFIX: &str = "FORYOU#GIVE#"; +/// The field on `JIRAUSER#` naming the dashboard user it is +/// linked to. +pub const FIELD_LINKED_USER: &str = "linked_user"; + +pub fn user_sk(user: &str) -> String { + format!("{USER_PREFIX}{user}") +} +pub fn jira_link_sk(user: &str) -> String { + format!("{JIRA_LINK_PREFIX}{user}") +} +pub fn give_sk(ticket: &str) -> String { + format!("{GIVE_PREFIX}{ticket}") +} + +/// How long a link code works. +pub const CODE_TTL_SECS: i64 = 15 * 60; + +// ── Link codes ────────────────────────────────────────────────────────────── + +const ALPHABET: &[u8; 32] = b"0123456789ABCDEFGHJKMNPQRSTVWXYZ"; + +fn b32(bytes: &[u8]) -> String { + let mut out = String::new(); + let mut acc: u32 = 0; + let mut bits = 0; + for b in bytes { + acc = (acc << 8) | *b as u32; + bits += 8; + while bits >= 5 { + bits -= 5; + out.push(ALPHABET[((acc >> bits) & 31) as usize] as char); + } + } + if bits > 0 { + out.push(ALPHABET[((acc << (5 - bits)) & 31) as usize] as char); + } + out +} + +fn tag(secret: &[u8], team: &str, body: &str) -> String { + let mut mac = Hmac::::new_from_slice(secret).expect("any key length"); + mac.update(b"foryou-link\0"); + mac.update(team.as_bytes()); + mac.update(b"\0"); + mac.update(body.as_bytes()); + b32(&mac.finalize().into_bytes()[..5]) +} + +/// A code as people type it: upper case, no dashes or spaces, `I`/`L` read +/// as `1` and `O` as `0`. +pub fn normalize_code(raw: &str) -> String { + raw.chars() + .filter(|c| c.is_ascii_alphanumeric()) + .map(|c| match c.to_ascii_uppercase() { + 'I' | 'L' => '1', + 'O' => '0', + c => c, + }) + .collect() +} + +/// The row a code is stored under: its hash, bound to the team. +pub fn code_sk(team: &str, code: &str) -> String { + let h = Sha256::digest(format!("{team}\0{}", normalize_code(code)).as_bytes()); + format!("{CODE_PREFIX}{}", hex::encode(h)) +} + +/// A new one-time code for the team: 8 random characters and 8 of their +/// signature, shown as `ABCD-EFGH-JKMN-PQRS`. Returns the code shown and the +/// key its row is stored under. +pub fn issue_code(secret: &[u8], team: &str, random: [u8; 5]) -> (String, String) { + let body = b32(&random); + let code = format!("{body}{}", tag(secret, team, &body)); + let shown = code + .as_bytes() + .chunks(4) + .map(|c| std::str::from_utf8(c).unwrap_or_default()) + .collect::>() + .join("-"); + let sk = code_sk(team, &code); + (shown, sk) +} + +/// A code's signature holds for this team. Checked before any read, so a +/// guessed or another team's code costs nothing. +pub fn verify_code(secret: &[u8], team: &str, raw: &str) -> bool { + use subtle::ConstantTimeEq; + let code = normalize_code(raw); + if code.len() != 16 { + return false; + } + let (body, sig) = code.split_at(8); + bool::from(tag(secret, team, body).as_bytes().ct_eq(sig.as_bytes())) +} + +/// A Jira account id as Atlassian issues them (`557058:...` or a 24-hex id): +/// nothing that could end a JQL string. +pub fn valid_account_id(id: &str) -> bool { + (8..=128).contains(&id.len()) + && id + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b':' || b == b'-') +} + +/// A Jira user CoderHelm has seen, for the "Is this you?" suggestion. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct SeenJiraUser { + pub account_id: String, + pub name: String, + pub email: String, + /// Already linked to someone. + pub linked: bool, +} + +/// The one Jira user that may be offered as "Is this you?": seen with this +/// exact email, linked to nobody, and not already answered "No". Only a +/// suggestion: saying yes starts the code flow, it links nothing. +pub fn identity_suggestion<'a>( + seen: &'a [SeenJiraUser], + email: &str, + declined: &BTreeSet, +) -> Option<&'a SeenJiraUser> { + let email = email.trim(); + if email.is_empty() { + return None; + } + let mut hits = seen.iter().filter(|u| { + !u.linked && u.email.eq_ignore_ascii_case(email) && !declined.contains(&u.account_id) + }); + let first = hits.next()?; + // Two accounts with one email: no guess at all. + hits.next().is_none().then_some(first) +} + +// ── The person's own settings ─────────────────────────────────────────────── + +/// The page's sections, in their default order. +pub const SECTIONS: &[&str] = &["needs", "sprint", "working", "waiting", "later"]; +/// The right side's cards. +pub const RAIL: &[&str] = &["stats", "accounts"]; +/// Where CoderHelm opens. Empty is the default: a phone opens on For you, +/// a wider screen on Runs. +pub const LANDINGS: &[&str] = &["foryou", "runs", "prs"]; + +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Layout { + pub order: Vec, + pub rail: Vec, + pub hidden: Vec, + pub landing: String, +} + +impl Layout { + /// The layout as saved, made whole: every section once, in the saved + /// order then the rest; only known names; the landing a known page. + pub fn normalized(&self) -> Layout { + fn order(saved: &[String], all: &[&str]) -> Vec { + let mut out: Vec = Vec::new(); + for s in saved { + if all.contains(&s.as_str()) && !out.contains(s) { + out.push(s.clone()); + } + } + for s in all { + if !out.iter().any(|o| o == s) { + out.push(s.to_string()); + } + } + out + } + let known = |s: &String| SECTIONS.contains(&s.as_str()) || RAIL.contains(&s.as_str()); + let mut hidden: Vec = self.hidden.iter().filter(|s| known(s)).cloned().collect(); + hidden.sort(); + hidden.dedup(); + Layout { + order: order(&self.order, SECTIONS), + rail: order(&self.rail, RAIL), + hidden, + landing: if LANDINGS.contains(&self.landing.as_str()) { + self.landing.clone() + } else { + String::new() + }, + } + } + + /// Only names the page knows: an unknown one is refused, never kept. + pub fn validate(&self) -> Result<(), String> { + for s in self.order.iter().chain(&self.rail).chain(&self.hidden) { + if !SECTIONS.contains(&s.as_str()) && !RAIL.contains(&s.as_str()) { + return Err(format!("unknown section {s:?}")); + } + } + if !self.landing.is_empty() && !LANDINGS.contains(&self.landing.as_str()) { + return Err(format!("unknown landing page {:?}", self.landing)); + } + if self.order.len() > 20 || self.rail.len() > 20 || self.hidden.len() > 20 { + return Err("too many sections".into()); + } + Ok(()) + } +} + +/// What the person did to one item or suggestion. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Mark { + /// Hidden until then (seconds), and listed under Later. + pub snoozed_until: i64, + /// Marked done while it waited since this time; it shows again when it + /// waits since a later time (it came back). + pub done_since: String, + /// A suggestion dismissed with this basis: it shows again only when its + /// basis changes. + pub dismissed_basis: String, + pub reason: String, + pub at: i64, +} + +impl Mark { + pub fn is_empty(&self) -> bool { + *self == Mark::default() + } +} + +/// A suggestion as first shown, for its lifecycle. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Shown { + pub basis: String, + pub first_at: i64, + pub text: String, + /// Why its basis changed, kept from the read that saw it go. + pub withdrawn: String, +} + +/// One person's For you settings, on `FORYOU#USER#`. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Prefs { + pub layout: Layout, + pub marks: BTreeMap, + /// The mark before the last change, per key, for Undo. + pub undo: BTreeMap, + pub shown: BTreeMap, + /// Kinds of ticket or suggestion the person asked not to see. + pub muted_kinds: BTreeSet, + /// Targets (tickets, pull requests) never suggested again ("Not me"). + pub not_me: BTreeSet, + /// Jira accounts answered "No" to "Is this you?". + pub identity_no: BTreeSet, +} + +/// Most marks kept: the oldest go first. +pub const MAX_MARKS: usize = 400; + +impl Prefs { + /// Keeps the document small: expired snoozes go, then the oldest marks. + pub fn tidy(&mut self, now: i64) { + self.marks.retain(|_, m| { + !(m.snoozed_until > 0 + && m.snoozed_until <= now + && m.done_since.is_empty() + && m.dismissed_basis.is_empty()) + }); + if self.marks.len() > MAX_MARKS { + let mut by_age: Vec<(i64, String)> = + self.marks.iter().map(|(k, m)| (m.at, k.clone())).collect(); + by_age.sort(); + for (_, k) in by_age.into_iter().take(self.marks.len() - MAX_MARKS) { + self.marks.remove(&k); + } + } + self.undo + .retain(|k, _| self.marks.contains_key(k) || k.len() < 300); + if self.undo.len() > 50 { + let keys: Vec = self + .undo + .keys() + .take(self.undo.len() - 50) + .cloned() + .collect(); + for k in keys { + self.undo.remove(&k); + } + } + if self.shown.len() > MAX_MARKS { + let mut by_age: Vec<(i64, String)> = self + .shown + .iter() + .map(|(k, s)| (s.first_at, k.clone())) + .collect(); + by_age.sort(); + for (_, k) in by_age.into_iter().take(self.shown.len() - MAX_MARKS) { + self.shown.remove(&k); + } + } + } + + /// Sets a key's mark and keeps the one before for Undo. + pub fn set_mark(&mut self, key: &str, mark: Mark) { + let before = self.marks.get(key).cloned().unwrap_or_default(); + self.undo.insert(key.to_string(), before); + if mark.is_empty() { + self.marks.remove(key); + } else { + self.marks.insert(key.to_string(), mark); + } + } + + /// Puts back the mark before the last change. `false` when there is + /// nothing to undo. + pub fn undo(&mut self, key: &str) -> bool { + let Some(before) = self.undo.remove(key) else { + return false; + }; + if before.is_empty() { + self.marks.remove(key); + } else { + self.marks.insert(key.to_string(), before); + } + true + } +} + +/// Where an item stands for the person now. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Standing { + Open, + /// Snoozed: listed under Later until then. + Snoozed(i64), + /// Marked done and nothing new since. + Done, +} + +/// An item waiting since `since`, with the person's mark. +pub fn standing(mark: Option<&Mark>, since: &str, now: i64) -> Standing { + let Some(m) = mark else { + return Standing::Open; + }; + if !m.done_since.is_empty() && m.done_since == since { + return Standing::Done; + } + if m.snoozed_until > now { + return Standing::Snoozed(m.snoozed_until); + } + Standing::Open +} + +// ── Fit bands ─────────────────────────────────────────────────────────────── + +/// What the fit checklist reads of one ticket. +#[derive(Debug, Clone, Default, PartialEq)] +pub struct TicketFacts { + pub key: String, + pub title: String, + pub description: String, + pub issue_type: String, + pub labels: Vec, + pub components: Vec, + pub priority: String, + pub points: Option, + /// The repositories it would change, best guess first. + pub repos: Vec, + /// How the repositories are known: `label`, `ticket`, `history` or + /// empty. + pub repo_source: String, + /// Whether the (single) repository has tests CoderHelm can run, when + /// known. + pub tests: Option, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +#[serde(rename_all = "snake_case")] +pub enum Band { + Good, + Maybe, + Not, +} + +impl Band { + pub fn label(self) -> &'static str { + match self { + Band::Good => "Good fit", + Band::Maybe => "Maybe (plan first)", + Band::Not => "Not suggested", + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Fit { + pub band: Band, + pub label: &'static str, + /// What kind of ticket it is, for "Don't suggest ". + pub kind: String, + /// What it has. + pub why: Vec, + /// What it lacks, each with what would change it. + pub missing: Vec, + /// Why it is never suggested, when it is on the exclude list. + pub excluded: Option, +} + +/// The exclude list: work CoderHelm is never suggested for, by its words. +const EXCLUDE: &[(&str, &[&str])] = &[ + ( + "security", + &[ + "security", + "vulnerab", + "cve-", + "xss", + "csrf", + "injection", + "secret", + "credential", + "signing key", + "encryption", + "encrypt", + "certificate", + ], + ), + ( + "auth", + &[ + "auth", + "login", + "log in", + "sign-in", + "sign in", + "signin", + "password", + "oauth", + "sso", + "saml", + "2fa", + "mfa", + "two-factor", + "permission", + "rbac", + "access control", + ], + ), + ( + "personal data", + &[ + "pii", + "personal data", + "gdpr", + "ccpa", + "hipaa", + "social security", + "date of birth", + "home address", + "redact", + ], + ), + ( + "an incident", + &[ + "incident", + "outage", + "sev1", + "sev-1", + "sev 1", + "sev0", + "sev-0", + "postmortem", + "post-mortem", + "hotfix", + "on-call", + "pager", + ], + ), + ( + "production-critical", + &[ + "production", + "prod outage", + "live traffic", + "production-critical", + "data loss", + ], + ), +]; + +fn has_word(hay: &str, needle: &str) -> bool { + // Whole words, so "author" is not "auth" and "secretary" not "secret". + let hay = hay.to_ascii_lowercase(); + let mut from = 0; + while let Some(i) = hay[from..].find(needle) { + let at = from + i; + let before = hay[..at].chars().last(); + let after = hay[at + needle.len()..].chars().next(); + let edge = |c: Option| c.is_none_or(|c| !c.is_ascii_alphanumeric()); + // A stem ("vulnerab", "encrypt") may run on into its word. + let stem = needle.ends_with("ab") || needle == "encrypt" || needle.ends_with('-'); + if edge(before) && (stem || edge(after) || after == Some('s')) { + return true; + } + from = at + needle.len(); + } + false +} + +/// Why the ticket is never suggested, from its title, type, labels, +/// components and priority (the description is not read for this: a +/// ticket may mention a word in passing). +pub fn excluded(t: &TicketFacts) -> Option { + let text = format!( + "{} {} {} {}", + t.title, + t.issue_type, + t.labels.join(" "), + t.components.join(" ") + ); + for (what, words) in EXCLUDE { + if words.iter().any(|w| has_word(&text, w)) { + return Some((*what).to_string()); + } + } + if matches!( + t.priority.trim().to_ascii_lowercase().as_str(), + "highest" | "blocker" | "critical" + ) { + return Some("production-critical".into()); + } + if t.repos.len() >= 3 { + return Some(format!( + "it spans {} repositories with no one named", + t.repos.len() + )); + } + None +} + +/// Acceptance criteria written in the description: a heading, an `AC:` +/// line, Given/When/Then, or a checklist. +pub fn has_acceptance(desc: &str) -> bool { + let d = desc.to_ascii_lowercase(); + d.contains("acceptance criteria") + || d.contains("definition of done") + || d.lines().any(|l| { + let l = l.trim(); + l.starts_with("ac:") || l.starts_with("- [ ]") || l.starts_with("[ ]") + }) + || (d.contains("given ") && d.contains("when ") && d.contains("then ")) +} + +/// Paths and code names the description names (`web/src/a.tsx`, +/// `` `SavedCartsList` ``), each once, at most five. +pub fn named_files(desc: &str) -> Vec { + let mut out: Vec = Vec::new(); + let mut push = |s: &str| { + let s = s.trim_matches(|c: char| "`'\"(),.:;".contains(c)); + if !s.is_empty() && s.len() <= 120 && !out.iter().any(|o| o == s) && out.len() < 5 { + out.push(s.to_string()); + } + }; + for w in desc.split_whitespace() { + let w = w.trim_matches(|c: char| "`'\"(),;:".contains(c)); + let looks_path = w.contains('/') + && !w.starts_with("http") + && w.rsplit('/') + .next() + .is_some_and(|f| f.contains('.') || f.is_empty() || w.ends_with('/')) + && w.chars() + .all(|c| c.is_ascii_alphanumeric() || "/._-[]".contains(c)); + let looks_file = !w.contains('/') + && w.contains('.') + && [ + ".ts", ".tsx", ".js", ".jsx", ".rs", ".py", ".go", ".rb", ".java", ".kt", ".css", + ".html", ".sql", ".md", ".json", ".yml", ".yaml", + ] + .iter() + .any(|e| w.ends_with(e)); + if looks_path || looks_file { + push(w); + } + } + // Code names in backticks. + for (i, part) in desc.split('`').enumerate() { + if i % 2 == 1 + && !part.contains(' ') + && part.chars().any(|c| c.is_ascii_uppercase()) + && part + .chars() + .all(|c| c.is_ascii_alphanumeric() || "._/-".contains(c)) + { + push(part); + } + } + out +} + +/// What kind of work the ticket is, for "Don't suggest ". +pub fn kind_of(t: &TicketFacts) -> String { + let title = t.title.to_ascii_lowercase(); + let labels = t.labels.join(" ").to_ascii_lowercase(); + let both = format!("{title} {labels}"); + let any = |ws: &[&str]| ws.iter().any(|w| has_word(&both, w)); + if any(&[ + "copy", + "typo", + "wording", + "text", + "link", + "label", + "translation", + ]) { + return "copy fixes".into(); + } + if any(&["docs", "documentation", "readme", "changelog"]) { + return "docs changes".into(); + } + if any(&["test", "tests", "coverage", "flaky"]) { + return "test work".into(); + } + if any(&["dependency", "dependencies", "upgrade", "bump"]) { + return "dependency updates".into(); + } + if any(&[ + "empty state", + "button", + "page", + "screen", + "ui", + "layout", + "style", + "css", + "modal", + ]) { + return "UI changes".into(); + } + if any(&["retry", "backoff", "webhook", "queue", "job", "worker"]) { + return "background jobs".into(); + } + match t.issue_type.trim().to_ascii_lowercase().as_str() { + "bug" => "bug fixes".into(), + "" => "tickets like this".into(), + other => format!("{other}s"), + } +} + +fn capitalize(s: &str) -> String { + let mut c = s.chars(); + c.next() + .map(|f| f.to_ascii_uppercase().to_string() + c.as_str()) + .unwrap_or_default() +} + +fn points_words(p: f64) -> String { + if p.fract() == 0.0 { + format!("{} pt", p as i64) + } else { + format!("{p} pt") + } +} + +/// The fit band of one ticket, with its reasons and what is missing. +/// +/// - **Not suggested**: on the exclude list, 8 points or more, or neither a +/// repository nor acceptance criteria. +/// - **Good fit**: acceptance criteria, one repository known, small (3 +/// points or less, or a short description with no estimate), files or an +/// area named, and the repository's tests not known to be missing. +/// - **Maybe (plan first)**: everything else. +pub fn fit(t: &TicketFacts) -> Fit { + let kind = kind_of(t); + let mut why: Vec = Vec::new(); + let mut missing: Vec = Vec::new(); + if let Some(ex) = excluded(t) { + return Fit { + band: Band::Not, + label: Band::Not.label(), + kind, + why, + missing: vec![if ex.starts_with("it spans") { + format!("{}: it needs a person's judgment", capitalize(&ex)) + } else { + format!("It is {ex} work, which CoderHelm is never suggested for: it needs a person's judgment") + }], + excluded: Some(ex), + }; + } + let ac = has_acceptance(&t.description); + if ac { + why.push("Acceptance criteria are written".into()); + } else { + missing.push("No acceptance criteria. Add two lines and it can become a good fit".into()); + } + let files = named_files(&t.description); + let area = !files.is_empty() || !t.components.is_empty(); + if !files.is_empty() { + why.push(format!("Names the files: {}", files.join(", "))); + } else if !t.components.is_empty() { + why.push(format!("Names the area: {}", t.components.join(", "))); + } else { + missing.push("No files or area named. Name the page or file it changes".into()); + } + let (small, large) = match t.points { + Some(p) if p >= 8.0 => { + missing.push(format!("{} is large. Split it first", points_words(p))); + (false, true) + } + Some(p) if p > 3.0 => { + missing.push(format!( + "{} is mid-sized: a plan first keeps it on track", + points_words(p) + )); + (false, false) + } + Some(p) => { + why.push(format!("Small: {}", points_words(p))); + (true, false) + } + None if t.description.trim().len() <= 1500 => { + missing.push("No estimate".into()); + (true, false) + } + None => { + missing.push("No estimate, and a long description".into()); + (false, false) + } + }; + let repo_one = t.repos.len() == 1; + match t.repos.len() { + 0 => missing + .push("No repository known. Add the label coderhelm: to name it".into()), + 1 => why.push(format!( + "Repository known: {}{}", + t.repos[0], + match t.repo_source.as_str() { + "label" => " (from its label)", + "ticket" => " (named in the ticket)", + "history" => " (where this project's tickets went before)", + _ => "", + } + )), + n => missing.push(format!( + "Touches {n} repositories: {}. A plan first settles what goes where", + t.repos.join(" and ") + )), + } + match (t.tests, repo_one) { + (Some(true), true) => why.push(format!("Tests exist in {}", t.repos[0])), + (Some(false), true) => missing.push(format!( + "{} has no tests CoderHelm can run, so the change can't be proven", + t.repos[0] + )), + _ => {} + } + let band = if large || (t.repos.is_empty() && !ac) { + Band::Not + } else if ac && repo_one && small && area && t.tests != Some(false) { + Band::Good + } else { + Band::Maybe + }; + Fit { + band, + label: band.label(), + kind, + why, + missing, + excluded: None, + } +} + +// ── Needs, grouped by whose turn it is ────────────────────────────────────── + +/// Where one open pull request goes on the page for this person. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +#[serde(rename_all = "snake_case")] +pub enum PrGroup { + /// Your review was asked for. + Reviews, + /// Your pull request (or CoderHelm's for you) came back to you. + Returned, + /// Yours, and someone else has the turn. + Waiting, +} + +/// The states that ask a reviewer, as `common::pr_needs` names them. +pub const REVIEW_STATES: &[&str] = &[ + "needs_review", + "re_review", + "needs_reviewer", + "needs_code_owner", +]; + +/// Where a row goes for `login`, from the row's own turn (decided by +/// `pr_needs`, the same function the merge gates use). +pub fn pr_group(row: &crate::pr_view::Row, login: &str) -> Option { + if login.is_empty() || row.stage.is_none() { + return None; + } + let me = |l: &str| l.trim_start_matches('@').eq_ignore_ascii_case(login); + let mine = me(&row.author.login) || row.for_person.as_deref().is_some_and(me); + if row.turn == "you" { + if !mine && REVIEW_STATES.contains(&row.state.as_str()) { + return Some(PrGroup::Reviews); + } + if mine { + return Some(PrGroup::Returned); + } + // Asked of you on someone else's pull request (a decision, a thread). + return Some(PrGroup::Reviews); + } + if mine && row.turn != "done" { + return Some(PrGroup::Waiting); + } + None +} + +// ── Private stats ─────────────────────────────────────────────────────────── + +/// How long the stats look back. +pub const TURNAROUND_DAYS: i64 = 28; + +/// The time from each review request of `login` to their first review +/// after it, within the last [`TURNAROUND_DAYS`] days: the median and how +/// many reviews it is over. Requests taken back before a review don't +/// count. `None` when there is none. +pub fn review_turnaround( + logs: &[( + Vec, + Vec, + )], + login: &str, + now: i64, +) -> Option<(i64, usize)> { + let since = now - TURNAROUND_DAYS * 86_400; + let me = |w: &str| w.trim_start_matches('@').eq_ignore_ascii_case(login); + let mut waits: Vec = Vec::new(); + for (requests, reviews) in logs { + for r in requests.iter().filter(|r| me(&r.who) && r.at >= since) { + let first = reviews + .iter() + .filter(|v| me(&v.who) && v.at >= r.at) + .map(|v| v.at) + .min(); + if let Some(at) = first { + if r.removed_at == 0 || r.removed_at >= at { + waits.push(at - r.at); + } + } + } + } + let n = waits.len(); + crate::pr_history::percentile(&waits, 50).map(|m| (m, n)) +} + +// ── Suggestions ───────────────────────────────────────────────────────────── + +/// Why a person may dismiss a suggestion, and the fixed change each makes. +pub const DISMISS_REASONS: &[(&str, &str)] = &[ + ( + "already_handled", + "Hidden. It comes back only if the ticket or pull request changes.", + ), + ("not_now", "Snoozed until tomorrow at 9:00."), + ("not_me", "Never suggested to you again for this one."), + ( + "dont_suggest_kind", + "No more suggestions of this kind. Turn them back on in Customize.", + ), +]; + +/// A suggestion's dismiss reason, with its effect in words. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct DismissReason { + pub code: String, + pub label: String, + pub effect: String, +} + +/// The reasons for one suggestion, worded for it. +pub fn dismiss_reasons(kind_words: &str) -> Vec { + DISMISS_REASONS + .iter() + .map(|(code, effect)| DismissReason { + code: (*code).into(), + label: match *code { + "already_handled" => "Already handled".into(), + "not_now" => "Not now".into(), + "not_me" => "Not me".into(), + _ => format!("Don't suggest {kind_words}"), + }, + effect: if *code == "dont_suggest_kind" { + format!("No more suggestions for {kind_words}. Turn them back on in Customize.") + } else { + (*effect).into() + }, + }) + .collect() +} + +/// Evidence behind a suggestion, each line checkable. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Evidence { + pub text: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub href: Option, +} + +/// One suggestion, as the page shows it. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Suggestion { + /// `give:BOOK-118`, `review:acme/web#482`, `reply:BOOK-115`. + pub key: String, + /// `give`, `plan`, `review` or `reply`. + pub kind: String, + /// The row it sits under (`ticket:BOOK-118`, `pr:acme/web#482`), or + /// none: listed in the summary only. + pub target: Option, + /// The action, named for its result: "Give BOOK-118 to CoderHelm". + pub text: String, + /// The button. + pub action: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub href: Option, + /// One signal, shown on the line. + pub reason: String, + /// Every signal, for Why?. + pub evidence: Vec, + /// What accepting does. + pub effect: String, + /// What it costs the person. + pub effort: String, + /// A real deadline only. + #[serde(skip_serializing_if = "Option::is_none")] + pub deadline: Option, + /// When its facts were read (RFC 3339). + pub as_of: String, + /// What it is about, for "Don't suggest ". + pub kind_words: String, + pub dismiss_reasons: Vec, + /// Back after a dismissal because its basis changed. + #[serde(skip_serializing_if = "Option::is_none")] + pub back_because: Option, + /// What it rests on: a change to any of it withdraws it. Not sent. + #[serde(skip)] + pub basis: String, + /// The basis in words, for the withdrawal's reason. Not sent. + #[serde(skip)] + pub basis_words: String, +} + +/// A suggestion taken back since the person last saw it. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Withdrawn { + pub key: String, + pub text: String, + pub withdrawn_reason: String, +} + +/// How long a suggestion stays when nothing changes: it was offered, and +/// re-showing it on every visit is nagging. +pub const SUGGESTION_DAYS: i64 = 7; +/// Most suggestions in the summary line. +pub const MAX_SUMMARY: usize = 3; + +/// The suggestions to show now, and those withdrawn since the last read. +/// +/// - A suggestion appears when its item is new or its basis changed +/// (`shown` keeps the basis it was first shown with); unchanged, it stays +/// [`SUGGESTION_DAYS`] days and then rests until something changes. +/// - Withdrawn when its basis changes or it no longer applies, with the +/// reason, once. +/// - Dismissed: gone until its basis changes ("back because"); "Not me" +/// never returns; a muted kind never shows; a snooze hides it until then. +pub fn reconcile( + computed: Vec, + prefs: &mut Prefs, + gone: &BTreeMap, + now: i64, +) -> (Vec, Vec) { + let mut out = Vec::new(); + let mut withdrawn = Vec::new(); + let live: BTreeSet = computed.iter().map(|s| s.key.clone()).collect(); + for mut s in computed { + if prefs.muted_kinds.contains(&s.kind_words) || prefs.muted_kinds.contains(&s.kind) { + continue; + } + if s.target.as_ref().is_some_and(|t| prefs.not_me.contains(t)) { + continue; + } + let mark = prefs.marks.get(&s.key).cloned().unwrap_or_default(); + if !mark.dismissed_basis.is_empty() { + if mark.dismissed_basis == s.basis { + continue; + } + s.back_because = Some(format!("Back because it changed: {}", s.basis_words)); + prefs.marks.remove(&s.key); + } + if mark.snoozed_until > now { + continue; + } + match prefs.shown.get(&s.key).cloned() { + Some(old) if old.basis == s.basis => { + if now - old.first_at > SUGGESTION_DAYS * 86_400 { + continue; + } + } + Some(old) => { + withdrawn.push(Withdrawn { + key: s.key.clone(), + text: old.text.clone(), + withdrawn_reason: format!("Its basis changed: {}", s.basis_words), + }); + prefs.shown.insert( + s.key.clone(), + Shown { + basis: s.basis.clone(), + first_at: now, + text: s.text.clone(), + withdrawn: String::new(), + }, + ); + } + None => { + prefs.shown.insert( + s.key.clone(), + Shown { + basis: s.basis.clone(), + first_at: now, + text: s.text.clone(), + withdrawn: String::new(), + }, + ); + } + } + out.push(s); + } + // Shown before and no longer computed: withdrawn once, with why. + let stale: Vec = prefs + .shown + .keys() + .filter(|k| !live.contains(*k)) + .cloned() + .collect(); + for k in stale { + let old = prefs.shown.remove(&k).unwrap_or_default(); + let dismissed = prefs + .marks + .get(&k) + .is_some_and(|m| !m.dismissed_basis.is_empty()); + if now - old.first_at <= SUGGESTION_DAYS * 86_400 && !dismissed { + withdrawn.push(Withdrawn { + key: k.clone(), + text: old.text, + withdrawn_reason: gone + .get(&k) + .cloned() + .unwrap_or_else(|| "It no longer applies".into()), + }); + } + } + (out, withdrawn) +} + +/// A dismissal: one click hides it with its basis; a reason then makes its +/// fixed change. +pub fn dismiss( + prefs: &mut Prefs, + s_key: &str, + basis: &str, + target: Option<&str>, + kind_words: &str, + reason: &str, + now: i64, +) -> Result { + let mut mark = prefs.marks.get(s_key).cloned().unwrap_or_default(); + mark.at = now; + let effect = match reason { + "" | "already_handled" => { + mark.dismissed_basis = basis.to_string(); + mark.reason = reason.to_string(); + if reason.is_empty() { + "Hidden.".to_string() + } else { + DISMISS_REASONS[0].1.to_string() + } + } + "not_now" => { + mark.dismissed_basis.clear(); + mark.snoozed_until = tomorrow_nine(now); + mark.reason = reason.into(); + DISMISS_REASONS[1].1.to_string() + } + "not_me" => { + mark.dismissed_basis = basis.to_string(); + mark.reason = reason.into(); + if let Some(t) = target { + prefs.not_me.insert(t.to_string()); + } + DISMISS_REASONS[2].1.to_string() + } + "dont_suggest_kind" => { + mark.dismissed_basis = basis.to_string(); + mark.reason = reason.into(); + prefs.muted_kinds.insert(kind_words.to_string()); + format!("No more suggestions for {kind_words}. Turn them back on in Customize.") + } + other => return Err(format!("unknown reason {other:?}")), + }; + prefs.set_mark(s_key, mark); + Ok(effect) +} + +/// The next 9:00 UTC at least eight hours away. +pub fn tomorrow_nine(now: i64) -> i64 { + let day = now - now.rem_euclid(86_400); + let nine = day + 9 * 3600; + if nine - now >= 8 * 3600 { + nine + } else { + nine + 86_400 + } +} + +/// A basis: the facts a suggestion rests on, hashed. +pub fn basis_of(parts: &[&str]) -> String { + let h = Sha256::digest(parts.join("\u{1f}").as_bytes()); + hex::encode(&h[..8]) +} + +// ── Plan first ────────────────────────────────────────────────────────────── + +/// The question a "Draft a plan first" run stops on once its plan is +/// written, and the answer that lets it code. +pub const PLAN_QUESTION: &str = + "You asked to see the plan first. Shall CoderHelm start coding from this plan?"; +pub const PLAN_APPROVE: &str = "Approve the plan and start coding"; +pub const PLAN_CHANGE: &str = "Change the plan first (say how)"; + +/// A ticket given from For you, on `FORYOU#GIVE#`. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Given { + pub ticket: String, + /// The dashboard user who gave it: the owner. + pub owner: String, + pub owner_name: String, + /// Their linked Jira account (the requester). + pub owner_jira: String, + pub plan_first: bool, + pub given_at: i64, + /// The plan was approved (the run codes from here on). + pub approved_at: i64, + /// The Jira event that started its run arrived (the owner was credited + /// once; a later edit by someone else isn't credited to them). + pub started_at: i64, +} + +/// How long a give waits for its Jira event to credit the owner. +pub const GIVE_WINDOW_SECS: i64 = 15 * 60; + +/// The ticket's give row, if any. +pub async fn read_given( + dynamo: &aws_sdk_dynamodb::Client, + table: &str, + team: &str, + ticket: &str, +) -> Option { + use aws_sdk_dynamodb::types::AttributeValue; + let item = dynamo + .get_item() + .table_name(table) + .key("pk", AttributeValue::S(team.into())) + .key("sk", AttributeValue::S(give_sk(ticket))) + .consistent_read(true) + .send() + .await + .ok()? + .item?; + item.get("doc") + .and_then(|d| d.as_s().ok()) + .and_then(|d| serde_json::from_str(d).ok()) +} + +/// Writes a give row. +pub async fn put_given( + dynamo: &aws_sdk_dynamodb::Client, + table: &str, + team: &str, + g: &Given, +) -> Result<(), String> { + use aws_sdk_dynamodb::types::AttributeValue; + dynamo + .put_item() + .table_name(table) + .item("pk", AttributeValue::S(team.into())) + .item("sk", AttributeValue::S(give_sk(&g.ticket))) + .item( + "doc", + AttributeValue::S(serde_json::to_string(g).map_err(|e| e.to_string())?), + ) + .send() + .await + .map(|_| ()) + .map_err(|e| aws_sdk_dynamodb::error::DisplayErrorContext(&e).to_string()) +} + +/// Whether a Jira event now is the one a give is waiting for: given in the +/// last [`GIVE_WINDOW_SECS`] and not yet started. +pub fn awaits_event(g: &Given, now: i64) -> bool { + g.started_at == 0 && g.given_at > 0 && now - g.given_at <= GIVE_WINDOW_SECS +} + +/// Whether the answers approve the plan: an answer to [`PLAN_QUESTION`] +/// that starts with "Approve" (the button) or says yes. +pub fn plan_approved(answers: &[crate::run_questions::Answer]) -> bool { + answers.iter().any(|a| { + a.question.trim() == PLAN_QUESTION && { + let t = a.answer.trim().to_ascii_lowercase(); + t.starts_with("approve") || t == "yes" || t.starts_with("yes,") || t.starts_with("yes ") + } + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::pr_record::{RequestEvent, ReviewEvent}; + + const SECRET: &[u8] = b"test-secret"; + const NOW: i64 = 1_800_000_000; + + fn t(title: &str, desc: &str) -> TicketFacts { + TicketFacts { + key: "BOOK-118".into(), + title: title.into(), + description: desc.into(), + issue_type: "Story".into(), + points: Some(1.0), + repos: vec!["acme/web".into()], + repo_source: "label".into(), + tests: Some(true), + ..Default::default() + } + } + + const AC: &str = "The refund email links to the help page.\n\nAcceptance criteria\n- [ ] The link opens /help/refunds\n\nChange web/src/emails/refund.tsx"; + + #[test] + fn a_code_is_signed_for_its_team_and_typed_loosely() { + let (code, sk) = issue_code(SECRET, "TEAM#a", [1, 2, 3, 4, 5]); + assert_eq!(code.len(), 19, "{code}"); + assert!(verify_code(SECRET, "TEAM#a", &code)); + assert!(verify_code( + SECRET, + "TEAM#a", + &code.to_lowercase().replace('-', " ") + )); + assert_eq!(code_sk("TEAM#a", &code.to_lowercase()), sk); + // Another team's app can't redeem it, nor a changed character. + assert!(!verify_code(SECRET, "TEAM#b", &code)); + let mut bad = code.clone().into_bytes(); + bad[0] = if bad[0] == b'A' { b'B' } else { b'A' }; + assert!(!verify_code( + SECRET, + "TEAM#a", + std::str::from_utf8(&bad).unwrap() + )); + assert!(!verify_code(b"other", "TEAM#a", &code)); + assert!(!verify_code(SECRET, "TEAM#a", "short")); + } + + #[test] + fn account_ids_are_checked_before_they_reach_jql() { + assert!(valid_account_id( + "557058:aaaa1111-0000-0000-0000-000000000001" + )); + assert!(valid_account_id("5b10ac8d82e05b22cc7d4ef5")); + assert!(!valid_account_id("x\" OR assignee is not EMPTY")); + assert!(!valid_account_id("short")); + } + + #[test] + fn email_alone_is_only_a_suggestion_and_never_a_guess() { + let u = |id: &str, email: &str, linked: bool| SeenJiraUser { + account_id: id.into(), + name: "Dana Ortiz".into(), + email: email.into(), + linked, + }; + let none = BTreeSet::new(); + let seen = vec![u("557058:a1", "dana@example.com", false)]; + assert_eq!( + identity_suggestion(&seen, "Dana@Example.com", &none).map(|s| s.account_id.as_str()), + Some("557058:a1") + ); + // Linked to someone, answered no, two with one email, or no email. + assert!(identity_suggestion( + &[u("557058:a1", "dana@example.com", true)], + "dana@example.com", + &none + ) + .is_none()); + let no: BTreeSet = ["557058:a1".to_string()].into(); + assert!(identity_suggestion(&seen, "dana@example.com", &no).is_none()); + let two = vec![ + u("557058:a1", "dana@example.com", false), + u("557058:a2", "dana@example.com", false), + ]; + assert!(identity_suggestion(&two, "dana@example.com", &none).is_none()); + assert!(identity_suggestion(&seen, "", &none).is_none()); + } + + #[test] + fn a_layout_keeps_every_section_once_and_refuses_unknown_names() { + let l = Layout { + order: vec![ + "later".into(), + "needs".into(), + "later".into(), + "bogus".into(), + ], + rail: vec![], + hidden: vec!["accounts".into()], + landing: "elsewhere".into(), + }; + let n = l.normalized(); + assert_eq!( + n.order, + vec!["later", "needs", "sprint", "working", "waiting"] + ); + assert_eq!(n.rail, vec!["stats", "accounts"]); + assert_eq!(n.landing, "", "an unknown page is the default"); + assert!(l.validate().is_err()); + assert!(Layout { + order: vec!["sprint".into()], + landing: "prs".into(), + ..Default::default() + } + .validate() + .is_ok()); + } + + #[test] + fn snooze_done_and_undo() { + let mut p = Prefs::default(); + assert_eq!( + standing(p.marks.get("pr:acme/web#482"), "2030-01-01T00:00:00Z", NOW), + Standing::Open + ); + p.set_mark( + "pr:acme/web#482", + Mark { + snoozed_until: NOW + 3600, + at: NOW, + ..Default::default() + }, + ); + assert_eq!( + standing(p.marks.get("pr:acme/web#482"), "s", NOW), + Standing::Snoozed(NOW + 3600) + ); + assert_eq!( + standing(p.marks.get("pr:acme/web#482"), "s", NOW + 3601), + Standing::Open + ); + assert!(p.undo("pr:acme/web#482")); + assert!(!p.marks.contains_key("pr:acme/web#482")); + assert!(!p.undo("pr:acme/web#482"), "one undo per change"); + // Done holds while it waits since the same time; a new wait is new. + p.set_mark( + "pr:acme/api#479", + Mark { + done_since: "t1".into(), + at: NOW, + ..Default::default() + }, + ); + assert_eq!( + standing(p.marks.get("pr:acme/api#479"), "t1", NOW), + Standing::Done + ); + assert_eq!( + standing(p.marks.get("pr:acme/api#479"), "t2", NOW), + Standing::Open + ); + } + + #[test] + fn tidy_drops_spent_snoozes_and_bounds_the_document() { + let mut p = Prefs::default(); + p.marks.insert( + "old".into(), + Mark { + snoozed_until: NOW - 1, + at: 1, + ..Default::default() + }, + ); + for i in 0..(MAX_MARKS + 10) { + p.marks.insert( + format!("k{i}"), + Mark { + done_since: "x".into(), + at: i as i64, + ..Default::default() + }, + ); + } + p.tidy(NOW); + assert!(!p.marks.contains_key("old")); + assert_eq!(p.marks.len(), MAX_MARKS); + assert!(!p.marks.contains_key("k0"), "the oldest go first"); + } + + #[test] + fn a_small_well_written_ticket_is_a_good_fit_with_its_reasons() { + let f = fit(&t("Fix the broken help link in the refund email", AC)); + assert_eq!(f.band, Band::Good, "{f:?}"); + assert_eq!(f.label, "Good fit"); + assert!(f.why.iter().any(|w| w == "Acceptance criteria are written")); + assert!(f + .why + .iter() + .any(|w| w.contains("web/src/emails/refund.tsx"))); + assert!(f + .why + .iter() + .any(|w| w.contains("acme/web (from its label)"))); + assert!(f.why.iter().any(|w| w == "Tests exist in acme/web")); + assert!(f.missing.is_empty(), "{:?}", f.missing); + assert_eq!(f.kind, "copy fixes"); + let json = serde_json::to_string(&f).unwrap(); + assert!(!json.contains('%') && !json.contains("confidence") && !json.contains("score")); + } + + #[test] + fn missing_pieces_make_it_a_maybe_and_say_what_would_change_it() { + let mut x = t( + "Retry failed webhook deliveries with backoff", + "Retry them.", + ); + x.points = Some(3.0); + x.repos = vec!["acme/api".into(), "acme/billing".into()]; + let f = fit(&x); + assert_eq!(f.band, Band::Maybe); + assert!(f + .missing + .iter() + .any(|m| m.starts_with("No acceptance criteria. Add two lines"))); + assert!(f + .missing + .iter() + .any(|m| m.contains("Touches 2 repositories: acme/api and acme/billing"))); + assert_eq!(f.kind, "background jobs"); + // Mid-sized, or tests missing, is also a maybe. + let mut y = t("Add an empty state to the saved carts list", AC); + y.points = Some(5.0); + assert_eq!(fit(&y).band, Band::Maybe); + let mut z = t("Add an empty state to the saved carts list", AC); + z.tests = Some(false); + let fz = fit(&z); + assert_eq!(fz.band, Band::Maybe); + assert!(fz.missing.iter().any(|m| m.contains("no tests"))); + } + + #[test] + fn the_exclude_list_is_never_suggested() { + for (title, why) in [ + ("Rotate the payment provider signing keys", "security"), + ("Let people reset their password from the app", "auth"), + ("Redact personal data in exports", "personal data"), + ("Follow up the checkout incident", "an incident"), + ("Raise the production database pool", "production-critical"), + ] { + let f = fit(&t(title, AC)); + assert_eq!(f.band, Band::Not, "{title}"); + assert_eq!(f.excluded.as_deref(), Some(why), "{title}"); + assert!( + f.missing[0].contains("needs a person's judgment"), + "{:?}", + f.missing + ); + } + // Words inside other words don't count. + assert_eq!( + fit(&t("Show the author on each review", AC)).band, + Band::Good + ); + // Highest priority and three repositories are excluded too. + let mut p = t("Tidy the footer links", AC); + p.priority = "Highest".into(); + assert_eq!(fit(&p).band, Band::Not); + let mut r = t("Tidy the footer links", AC); + r.repos = vec!["acme/a".into(), "acme/b".into(), "acme/c".into()]; + assert!(fit(&r).excluded.unwrap().contains("spans 3 repositories")); + } + + #[test] + fn large_or_unplaced_tickets_are_not_suggested() { + let mut big = t("Rework the export page", AC); + big.points = Some(8.0); + assert_eq!(fit(&big).band, Band::Not); + let mut lost = t("Rework the export page", "Make it better"); + lost.repos.clear(); + assert_eq!(fit(&lost).band, Band::Not); + } + + #[test] + fn files_and_criteria_are_read_from_the_words() { + assert_eq!( + named_files("Change `SavedCartsList` in web/src/carts/SavedCartsList.tsx and README.md, see https://example.com/a/b.html"), + vec!["web/src/carts/SavedCartsList.tsx", "README.md", "SavedCartsList"] + ); + assert!(has_acceptance("AC: it works")); + assert!(has_acceptance( + "Given a cart\nWhen it is empty\nThen it says so" + )); + assert!(!has_acceptance("Make it nicer")); + } + + fn row(author: &str, for_person: Option<&str>, state: &str, turn: &str) -> crate::pr_view::Row { + crate::pr_view::Row { + key: "acme/web#1".into(), + org: "acme".into(), + repo: "acme/web".into(), + number: 1, + title: "t".into(), + url: String::new(), + author: crate::pr_view::Author { + login: author.into(), + coderhelm: false, + }, + for_person: for_person.map(str::to_string), + draft: false, + base: "main".into(), + head: "b".into(), + created_at: None, + updated_at: None, + state: state.into(), + state_label: String::new(), + stage: Some("in_review".into()), + ready_at: None, + turn: turn.into(), + next: crate::pr_view::NextOut { + code: state.into(), + text: String::new(), + from: vec![], + since: None, + rule: None, + }, + modifiers: vec![], + people: vec![], + checks: Default::default(), + reviews: Default::default(), + conflict: None, + open_threads: 0, + labels: vec![], + size: None, + last_action: None, + coderhelm: None, + links: vec![], + waiting_since: None, + rank: (0, 0, 0), + involves: vec![], + stale: false, + } + } + + #[test] + fn pull_requests_group_by_whose_turn_it_is() { + assert_eq!( + pr_group(&row("theo", None, "needs_review", "you"), "dana"), + Some(PrGroup::Reviews) + ); + assert_eq!( + pr_group(&row("dana", None, "checks_failing", "you"), "dana"), + Some(PrGroup::Returned) + ); + assert_eq!( + pr_group( + &row("coderhelm[bot]", Some("dana"), "changes_requested", "you"), + "Dana" + ), + Some(PrGroup::Returned) + ); + assert_eq!( + pr_group(&row("dana", None, "needs_review", "person"), "dana"), + Some(PrGroup::Waiting) + ); + assert_eq!( + pr_group( + &row("coderhelm[bot]", Some("dana"), "needs_review", "person"), + "dana" + ), + Some(PrGroup::Waiting) + ); + assert_eq!( + pr_group(&row("theo", None, "needs_review", "person"), "dana"), + None, + "someone else's, not your turn" + ); + assert_eq!(pr_group(&row("dana", None, "merged", "done"), "dana"), None); + assert_eq!( + pr_group(&row("dana", None, "needs_review", "you"), ""), + None + ); + } + + fn req(who: &str, at: i64, removed: i64) -> RequestEvent { + RequestEvent { + who: who.into(), + at, + removed_at: removed, + } + } + fn rev(who: &str, at: i64) -> ReviewEvent { + ReviewEvent { + who: who.into(), + state: "APPROVED".into(), + sha: String::new(), + at, + human: true, + has_body: false, + } + } + + #[test] + fn review_turnaround_is_your_own_median_from_request_to_first_review() { + let day = 86_400; + let logs = vec![ + ( + vec![req("dana", NOW - 3 * day, 0)], + vec![rev("dana", NOW - 3 * day + 3600), rev("dana", NOW - day)], + ), + ( + vec![req("dana", NOW - 2 * day, 0)], + vec![ + rev("mara", NOW - 2 * day + 60), + rev("Dana", NOW - 2 * day + 5 * 3600), + ], + ), + ( + vec![req("dana", NOW - 2 * day, 0)], + vec![rev("dana", NOW - 2 * day + 9 * 3600)], + ), + // Taken back before a review; another person's; too old. + ( + vec![req("dana", NOW - day, NOW - day + 10)], + vec![rev("dana", NOW - day + 3600)], + ), + ( + vec![req("theo", NOW - day, 0)], + vec![rev("theo", NOW - day + 60)], + ), + ( + vec![req("dana", NOW - 40 * day, 0)], + vec![rev("dana", NOW - 40 * day + 60)], + ), + ]; + assert_eq!(review_turnaround(&logs, "dana", NOW), Some((5 * 3600, 3))); + assert_eq!(review_turnaround(&logs, "jun", NOW), None); + } + + fn sug(key: &str, basis: &str) -> Suggestion { + Suggestion { + key: key.into(), + kind: "give".into(), + target: Some(format!("ticket:{}", key.trim_start_matches("give:"))), + text: format!("Give {} to CoderHelm", key.trim_start_matches("give:")), + action: "Give to CoderHelm".into(), + href: None, + reason: "Good fit: small, criteria written".into(), + evidence: vec![], + effect: "CoderHelm opens one pull request; you review it".into(), + effort: "1 pt".into(), + deadline: None, + as_of: "2027-01-15T08:00:00Z".into(), + kind_words: "copy fixes".into(), + dismiss_reasons: dismiss_reasons("copy fixes"), + back_because: None, + basis: basis.into(), + basis_words: "its description changed".into(), + } + } + + #[test] + fn a_suggestion_shows_on_new_or_changed_items_and_rests_when_unchanged() { + let mut p = Prefs::default(); + let none = BTreeMap::new(); + let (v, w) = reconcile(vec![sug("give:BOOK-118", "b1")], &mut p, &none, NOW); + assert_eq!(v.len(), 1); + assert!(w.is_empty()); + // Unchanged: still shown for a week, then it rests. + let (v, _) = reconcile( + vec![sug("give:BOOK-118", "b1")], + &mut p, + &none, + NOW + 86_400, + ); + assert_eq!(v.len(), 1); + let (v, _) = reconcile( + vec![sug("give:BOOK-118", "b1")], + &mut p, + &none, + NOW + 8 * 86_400, + ); + assert!(v.is_empty(), "not re-shown on every visit"); + // Its basis changed: the old one is withdrawn with why, the new shows. + let (v, w) = reconcile( + vec![sug("give:BOOK-118", "b2")], + &mut p, + &none, + NOW + 9 * 86_400, + ); + assert_eq!(v.len(), 1); + assert_eq!(w.len(), 1); + assert_eq!( + w[0].withdrawn_reason, + "Its basis changed: its description changed" + ); + } + + #[test] + fn a_suggestion_whose_basis_is_gone_is_withdrawn_once_with_its_reason() { + let mut p = Prefs::default(); + reconcile( + vec![sug("give:BOOK-118", "b1")], + &mut p, + &BTreeMap::new(), + NOW, + ); + let gone: BTreeMap = [( + "give:BOOK-118".to_string(), + "BOOK-118 left your sprint".to_string(), + )] + .into(); + let (v, w) = reconcile(vec![], &mut p, &gone, NOW + 60); + assert!(v.is_empty()); + assert_eq!(w[0].withdrawn_reason, "BOOK-118 left your sprint"); + let (_, w) = reconcile(vec![], &mut p, &gone, NOW + 120); + assert!(w.is_empty(), "said once"); + } + + #[test] + fn dismiss_is_one_click_and_each_reason_makes_its_fixed_change() { + let none = BTreeMap::new(); + // One click: hidden for this basis. + let mut p = Prefs::default(); + reconcile(vec![sug("give:BOOK-118", "b1")], &mut p, &none, NOW); + assert_eq!( + dismiss( + &mut p, + "give:BOOK-118", + "b1", + Some("ticket:BOOK-118"), + "copy fixes", + "", + NOW + ) + .unwrap(), + "Hidden." + ); + assert!( + reconcile(vec![sug("give:BOOK-118", "b1")], &mut p, &none, NOW + 1) + .0 + .is_empty() + ); + // Back, saying why, once the basis changes. + let (v, _) = reconcile(vec![sug("give:BOOK-118", "b2")], &mut p, &none, NOW + 2); + assert_eq!( + v[0].back_because.as_deref(), + Some("Back because it changed: its description changed") + ); + // Undo puts it back at once. + let mut p = Prefs::default(); + dismiss( + &mut p, + "give:BOOK-118", + "b1", + Some("ticket:BOOK-118"), + "copy fixes", + "", + NOW, + ) + .unwrap(); + assert!(p.undo("give:BOOK-118")); + assert_eq!( + reconcile(vec![sug("give:BOOK-118", "b1")], &mut p, &none, NOW) + .0 + .len(), + 1 + ); + // Not now: snoozed to tomorrow 9:00, then back. + let mut p = Prefs::default(); + let e = dismiss( + &mut p, + "give:BOOK-118", + "b1", + None, + "copy fixes", + "not_now", + NOW, + ) + .unwrap(); + assert_eq!(e, "Snoozed until tomorrow at 9:00."); + assert!( + reconcile(vec![sug("give:BOOK-118", "b1")], &mut p, &none, NOW + 60) + .0 + .is_empty() + ); + assert_eq!( + reconcile( + vec![sug("give:BOOK-118", "b1")], + &mut p, + &none, + tomorrow_nine(NOW) + 1 + ) + .0 + .len(), + 1 + ); + // Not me: never again for that target, whatever changes. + let mut p = Prefs::default(); + dismiss( + &mut p, + "give:BOOK-118", + "b1", + Some("ticket:BOOK-118"), + "copy fixes", + "not_me", + NOW, + ) + .unwrap(); + assert!( + reconcile(vec![sug("give:BOOK-118", "b9")], &mut p, &none, NOW) + .0 + .is_empty() + ); + // Don't suggest this kind: the kind is muted, other kinds still show. + let mut p = Prefs::default(); + let e = dismiss( + &mut p, + "give:BOOK-118", + "b1", + None, + "copy fixes", + "dont_suggest_kind", + NOW, + ) + .unwrap(); + assert_eq!( + e, + "No more suggestions for copy fixes. Turn them back on in Customize." + ); + assert!( + reconcile(vec![sug("give:BOOK-120", "c1")], &mut p, &none, NOW) + .0 + .is_empty() + ); + let mut other = sug("give:BOOK-121", "d1"); + other.kind_words = "UI changes".into(); + assert_eq!(reconcile(vec![other], &mut p, &none, NOW).0.len(), 1); + assert!(dismiss(&mut p, "k", "b", None, "x", "bogus", NOW).is_err()); + } + + #[test] + fn every_suggestion_carries_its_dismiss_reasons_with_their_effects() { + let r = dismiss_reasons("copy fixes"); + let codes: Vec<&str> = r.iter().map(|d| d.code.as_str()).collect(); + assert_eq!( + codes, + vec!["already_handled", "not_now", "not_me", "dont_suggest_kind"] + ); + assert_eq!(r[3].label, "Don't suggest copy fixes"); + assert!(r.iter().all(|d| !d.effect.is_empty())); + let s = serde_json::to_value(sug("give:BOOK-118", "b1")).unwrap(); + for f in [ + "reason", + "evidence", + "effect", + "effort", + "as_of", + "dismiss_reasons", + ] { + assert!(s.get(f).is_some(), "{f}"); + } + assert!(s.get("basis").is_none(), "the basis stays on the server"); + } + + #[test] + fn tomorrow_nine_is_never_minutes_away() { + let day0 = NOW - NOW.rem_euclid(86_400); + assert_eq!(tomorrow_nine(day0 + 3600), day0 + 9 * 3600); + assert_eq!(tomorrow_nine(day0 + 8 * 3600), day0 + 86_400 + 9 * 3600); + } + + #[test] + fn a_give_credits_its_owner_once_and_only_soon_after() { + let g = Given { + ticket: "BOOK-112".into(), + owner: "u1".into(), + given_at: NOW, + ..Default::default() + }; + assert!(awaits_event(&g, NOW + 60)); + assert!(!awaits_event(&g, NOW + GIVE_WINDOW_SECS + 1)); + assert!(!awaits_event( + &Given { + started_at: NOW + 5, + ..g.clone() + }, + NOW + 60 + )); + } + + #[test] + fn only_an_approval_lets_a_plan_first_run_code() { + let a = |q: &str, ans: &str| crate::run_questions::Answer { + question: q.into(), + answer: ans.into(), + ..Default::default() + }; + assert!(plan_approved(&[a(PLAN_QUESTION, PLAN_APPROVE)])); + assert!(plan_approved(&[a(PLAN_QUESTION, "Yes, go")])); + assert!(!plan_approved(&[a(PLAN_QUESTION, PLAN_CHANGE)])); + assert!(!plan_approved(&[a( + PLAN_QUESTION, + "Change step 2: keep the old column" + )])); + assert!(!plan_approved(&[a("Which column?", "Approve")])); + assert!(!plan_approved(&[])); + } +} diff --git a/services/common/src/handback.rs b/services/common/src/handback.rs index 5be10b37e..43802f890 100644 --- a/services/common/src/handback.rs +++ b/services/common/src/handback.rs @@ -156,6 +156,8 @@ impl HandBack { } } P::DivergentReadings => HumanOnly::AmbiguousTicket, + // The person asked to see the plan before any code. + P::PlanApproval => HumanOnly::Approval, }; HandBack::new(why, question) } diff --git a/services/common/src/lib.rs b/services/common/src/lib.rs index 32f2da030..9df461eb8 100644 --- a/services/common/src/lib.rs +++ b/services/common/src/lib.rs @@ -247,6 +247,7 @@ pub mod diff_shape; /// Each ticket criterion mapped to an end-to-end test and proven both /// ways: failing on staging, passing on the preview. pub mod e2e_proof; +pub mod foryou; #[cfg(test)] mod model_call_sites; /// Which pull requests CoderHelm may push to, edit or close: its own. diff --git a/services/common/src/pr_history.rs b/services/common/src/pr_history.rs index 3e5d6301d..64bba2b3c 100644 --- a/services/common/src/pr_history.rs +++ b/services/common/src/pr_history.rs @@ -130,6 +130,9 @@ pub struct History { /// person had to act (`handback` code). pub run_outcome: String, pub stop_reason: String, + /// The paths it changed (the record's, up to 100): who knows which + /// files, for the For you page's review suggestions. + pub files: Vec, } /// A later pull request suspected of fixing an earlier one. @@ -257,6 +260,7 @@ impl History { drift_overlap: r.drift_overlap, run_outcome: String::new(), stop_reason: String::new(), + files: r.files.clone(), } } diff --git a/services/common/src/stop_judge.rs b/services/common/src/stop_judge.rs index 7480a3e71..d729793df 100644 --- a/services/common/src/stop_judge.rs +++ b/services/common/src/stop_judge.rs @@ -105,6 +105,9 @@ pub enum PersonOnly { Access, /// Readings of the ticket that lead to different code. DivergentReadings, + /// The person asked to see the plan before any code (For you's "Draft a + /// plan first"). Set only by that rule, never by the model. + PlanApproval, } impl PersonOnly { @@ -301,6 +304,11 @@ pub struct Picture { /// one of them breaks a rule. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub connected: Vec, + /// The person who gave the ticket asked to approve the plan before any + /// code (`common::foryou::Given::plan_first`): their name. The ask is + /// theirs, so it is settled by rule, with no default and no deadline. + #[serde(default, skip_serializing_if = "String::is_empty")] + pub plan_first_for: String, } /// Longest text of one field in the prompt and the stored record. @@ -403,11 +411,18 @@ impl Question { /// Whether the run may take the default by itself once the deadline /// passes: never for access, which only a person can grant. pub fn has_default(&self) -> bool { - self.person_only != PersonOnly::Access + !matches!( + self.person_only, + PersonOnly::Access | PersonOnly::PlanApproval + ) } /// What happens without an answer, in one sentence. pub fn unanswered(&self) -> String { + if self.person_only == PersonOnly::PlanApproval { + return "You asked to see the plan first, so nothing is coded until you approve it." + .to_string(); + } if self.has_default() { format!( "If there is no answer within {} hours, I go ahead with the recommended option ({}).", @@ -964,6 +979,28 @@ pub fn fallback(p: &Picture) -> Verdict { /// another cycle with no cycles left (the run's hard limits are not the /// judge's to lift). fn settled_by_rule(p: &Picture) -> Option<(Verdict, String)> { + if p.kind() == Kind::Ask && !p.plan_first_for.trim().is_empty() { + return Some(( + Verdict::Ask(Question { + question: crate::foryou::PLAN_QUESTION.into(), + person_only: PersonOnly::PlanApproval, + tried: vec![format!( + "Wrote the plan: it is on the run page ({})", + crate::truncate_str(p.reason.trim(), 200) + )], + options: vec![ + crate::foryou::PLAN_APPROVE.into(), + crate::foryou::PLAN_CHANGE.into(), + ], + default: crate::foryou::PLAN_APPROVE.into(), + deadline_hours: 0, + }), + format!( + "{} asked to approve the plan first", + p.plan_first_for.trim() + ), + )); + } if !p.cannot_proceed.trim().is_empty() { return Some(( Verdict::Hold(Hold { @@ -1150,6 +1187,36 @@ mod tests { "evidence":evidence,"category":category,"location":location}) } + #[tokio::test] + async fn a_plan_first_ask_is_the_persons_with_no_default_and_no_model_call() { + struct NoModel; + impl JudgeModel for NoModel { + async fn answer(&self, _: &str, _: &str, _: &Value) -> Result { + panic!("the model is never asked"); + } + } + let mut p = Picture::new(Kind::Ask, "plan_first", "3 tasks in acme/web"); + p.plan_first_for = "Dana Ortiz".into(); + let j = judge(&NoModel, p).await; + let q = j.question().unwrap(); + assert_eq!(q.question, crate::foryou::PLAN_QUESTION); + assert_eq!(q.person_only, PersonOnly::PlanApproval); + assert!(!q.has_default(), "the run never goes ahead by itself"); + assert_eq!( + q.options, + vec![crate::foryou::PLAN_APPROVE, crate::foryou::PLAN_CHANGE] + ); + assert!(q + .unanswered() + .contains("nothing is coded until you approve")); + assert_eq!( + j.source(), + &Source::Rule("Dana Ortiz asked to approve the plan first".into()) + ); + // The model can never pick it. + assert!(PersonOnly::parse("plan_approval").is_none()); + } + #[test] fn overturned_decisions_reach_the_prompt_bounded() { let mut p = picture(Kind::Block); diff --git a/services/gateway/src/main.rs b/services/gateway/src/main.rs index b02b645a1..6babd0abc 100644 --- a/services/gateway/src/main.rs +++ b/services/gateway/src/main.rs @@ -693,6 +693,24 @@ fn build_app(state: Arc) -> Router { .route("/reviewer/live", get(routes::reviewer::live_prs)) .route("/prs", get(routes::prs::list_prs)) .route("/prs/detail", get(routes::prs::get_pr)) + // For you: the session user's own page and settings. No route takes + // a user; every read and write is the session's. + .route("/foryou", get(routes::foryou::get_for_you)) + .route("/foryou/prefs", put(routes::foryou::put_prefs)) + .route("/foryou/items", post(routes::foryou::mark_item)) + .route("/foryou/suggestions", post(routes::foryou::suggestion_act)) + .route( + "/foryou/give", + get(routes::foryou_give::preview).post(routes::foryou_give::give), + ) + .route( + "/foryou/link/jira", + post(routes::foryou_link::make_code).delete(routes::foryou_link::unlink), + ) + .route( + "/foryou/link/jira/not-me", + post(routes::foryou_link::not_me), + ) .route("/reviewer/open-prs", get(routes::reviewer::open_prs)) .route( "/reviewer/gate", @@ -1712,6 +1730,8 @@ fn build_app(state: Arc) -> Router { .route("/github", post(routes::github_webhook::handle)) .route("/jira/:token", post(routes::jira_webhook::handle)) .route("/jira", post(routes::jira_webhook::handle_forge)) + // The Jira app's "Link my CoderHelm account" (a person's one-time code). + .route("/jira-link", post(routes::foryou_link::forge_link)) .route("/alerts/sns", post(routes::alerts::handle_sns)) // Knowledge sources: a provider says pages changed (signed). .route( diff --git a/services/gateway/src/permissions.rs b/services/gateway/src/permissions.rs index 6f488995f..4b7e3f40a 100644 --- a/services/gateway/src/permissions.rs +++ b/services/gateway/src/permissions.rs @@ -127,6 +127,8 @@ pub const CAPABILITIES: &[Capability] = &[ "reviewer::open_prs", "prs::list_prs", "prs::get_pr", + "foryou::get_for_you", + "foryou_give::preview", "review_lessons::list_lessons", "learning::get_learning", "learning::get_health", @@ -196,6 +198,12 @@ pub const CAPABILITIES: &[Capability] = &[ "sign_in::app_verify", "sign_in::app_disable", "api::update_notification_prefs", + "foryou::put_prefs", + "foryou::mark_item", + "foryou::suggestion_act", + "foryou_link::make_code", + "foryou_link::unlink", + "foryou_link::not_me", ], }, Capability { @@ -282,6 +290,7 @@ pub const CAPABILITIES: &[Capability] = &[ min_role: "member", handlers: &[ "run_start::start_run", + "foryou_give::give", "api::retry_run", "decisions::export_decisions", "run_answer::answer_run", diff --git a/services/gateway/src/routes/chat_work.rs b/services/gateway/src/routes/chat_work.rs index 41c38ebc9..05a9114ec 100644 --- a/services/gateway/src/routes/chat_work.rs +++ b/services/gateway/src/routes/chat_work.rs @@ -721,6 +721,7 @@ async fn needs_me( budget: needs::SOURCE_BUDGET, }; let me = needs::Me { + user: ctx.claims.sub.clone(), email: ctx.claims.email.trim().to_string(), github: ctx .claims diff --git a/services/gateway/src/routes/chat_work_needs.rs b/services/gateway/src/routes/chat_work_needs.rs index c5cd58ac7..090c07dc5 100644 --- a/services/gateway/src/routes/chat_work_needs.rs +++ b/services/gateway/src/routes/chat_work_needs.rs @@ -14,7 +14,9 @@ //! mention them they haven't answered. //! //! The person is who signed in: their email, their GitHub login, and the -//! Jira account CoderHelm has seen with their email. Every read is of the +//! Jira account they linked themselves (`common::foryou`: a one-time code +//! redeemed from the Jira app). An email match never stands in for that +//! link: Atlassian emails can be hidden or differ from the sign-in email. Every read is of the //! asker's team only. The sources are read side by side, each within //! [`SOURCE_BUDGET`]; one that fails, times out or isn't connected is named //! in the result, never skipped quietly. Items are grouped by urgency and @@ -30,6 +32,10 @@ use super::chat_work_prs::{scoped_queries, Client}; use super::chat_work_runs::Item; use super::chat_work_tickets::JiraApp; +/// Why Jira isn't read for someone who hasn't linked their Jira account. +pub const NOT_LINKED: &str = + "your Jira account isn't linked to CoderHelm yet: link it on the For you page (Connect Jira)"; + /// How long one source may take before it's reported as not answering. pub const SOURCE_BUDGET: Duration = Duration::from_secs(12); /// Most items one answer lists. @@ -133,9 +139,11 @@ pub struct SourceNote { /// Who is asking. #[derive(Debug, Clone, Default, PartialEq)] pub struct Me { + /// Their dashboard user id (`claims.sub`). + pub user: String, pub email: String, pub github: Option, - /// Their Jira account, once known ([`Store::jira_accounts`]). + /// Their Jira account, once they linked it ([`Store::jira_link`]). pub jira_id: Option, /// An admin or owner: decides held tool calls. pub is_admin: bool, @@ -148,8 +156,9 @@ pub trait Store: Send + Sync { async fn runs(&self, team: &str) -> Result, String>; /// The team's tool calls held for a person's yes, pending only. async fn approvals(&self, team: &str) -> Result, String>; - /// The Jira account ids CoderHelm has seen with this email. - async fn jira_accounts(&self, team: &str, email: &str) -> Vec; + /// The Jira account this dashboard user linked themselves, if any. Never + /// guessed from an email. + async fn jira_link(&self, team: &str, user: &str) -> Option; } /// GitHub through the team's installation. @@ -256,22 +265,6 @@ fn run_what(item: &Item) -> String { } } -/// The Jira account ids runs recorded with this email (who assigned them). -pub fn jira_ids_from_runs(items: &[Item], email: &str) -> Vec { - let mut out: Vec = Vec::new(); - for i in items { - if email.is_empty() || !st(i, "requester_email").eq_ignore_ascii_case(email) { - continue; - } - if let Some(id) = st(i, "requester_key").strip_prefix("jira:") { - if !id.is_empty() && !out.iter().any(|o| o == id) { - out.push(id.to_string()); - } - } - } - out -} - /// What a `needs_input` run waits on, from the evidence its record holds. #[derive(Debug, Clone, PartialEq)] pub enum Wait { @@ -1068,16 +1061,17 @@ pub async fn gather(src: &Sources<'_>, mut me: Me, now: Time) -> Report { } }, async { - if me.email.is_empty() { - Vec::new() + if me.jira_id.is_some() || me.user.is_empty() { + None } else { timed( src.budget, - "Jira users", - src.store.jira_accounts(src.team, &me.email), + "Jira link", + src.store.jira_link(src.team, &me.user), ) .await - .unwrap_or_default() + .ok() + .flatten() } }, ); @@ -1086,12 +1080,9 @@ pub async fn gather(src: &Sources<'_>, mut me: Me, now: Time) -> Report { Some(Err(e)) => Err(e), None => Ok(Vec::new()), }; + // Only the link the person made; never an account seen with their email. if me.jira_id.is_none() { - me.jira_id = known.into_iter().next().or_else(|| { - runs.as_ref() - .ok() - .and_then(|r| jira_ids_from_runs(r, &me.email).into_iter().next()) - }); + me.jira_id = known.filter(|id| common::foryou::valid_account_id(id)); } // Then the outside systems, side by side. @@ -1117,15 +1108,7 @@ pub async fn gather(src: &Sources<'_>, mut me: Me, now: Time) -> Report { ); }; let Some(account) = me.jira_id.clone() else { - return ( - Vec::new(), - Vec::new(), - 0, - Read::Off(format!( - "CoderHelm hasn't seen a Jira account with your email ({}) yet", - me.email - )), - ); + return (Vec::new(), Vec::new(), 0, Read::Off(NOT_LINKED.into())); }; match timed(src.budget, "Jira", ask_jira_mine(src.http, app, &account)).await { Ok(Ok(resp)) => { @@ -1512,41 +1495,8 @@ impl Store for Dynamo<'_> { .collect()) } - async fn jira_accounts(&self, team: &str, email: &str) -> Vec { - use aws_sdk_dynamodb::types::AttributeValue; - let prefix = common::requester::JIRA_USER_PREFIX; - let mut out: Vec = Vec::new(); - let mut start: Option = None; - for _ in 0..5 { - let r = self - .state - .dynamo - .query() - .table_name(&self.state.config.settings_table_name) - .key_condition_expression("pk = :p AND begins_with(sk, :s)") - .expression_attribute_values(":p", AttributeValue::S(team.to_string())) - .expression_attribute_values(":s", AttributeValue::S(prefix.to_string())) - .set_exclusive_start_key(start.take()) - .send() - .await; - let Ok(r) = r else { - tracing::warn!("Chat: Jira users couldn't be read for what needs the asker"); - break; - }; - for i in r.items() { - if st(i, "email").eq_ignore_ascii_case(email) { - let id = st(i, "sk").trim_start_matches(prefix).to_string(); - if !id.is_empty() && !out.contains(&id) { - out.push(id); - } - } - } - match r.last_evaluated_key() { - Some(k) if !k.is_empty() => start = Some(k.clone()), - _ => break, - } - } - out + async fn jira_link(&self, team: &str, user: &str) -> Option { + super::foryou_link::linked_jira(self.state, team, user).await } } @@ -1601,13 +1551,13 @@ pub(crate) mod tests { .map(|(_, a)| a.clone()) .collect()) } - async fn jira_accounts(&self, team: &str, email: &str) -> Vec { + async fn jira_link(&self, team: &str, user: &str) -> Option { self.asked.lock().unwrap().push(team.into()); + // (team, account id, user): links people made, never emails. self.jira_users .iter() - .filter(|(t, _, e)| t == team && e.eq_ignore_ascii_case(email)) + .find(|(t, _, u)| t == team && u == user) .map(|(_, id, _)| id.clone()) - .collect() } } @@ -1800,6 +1750,7 @@ pub(crate) mod tests { pub fn me() -> Me { Me { + user: ME.into(), email: ME.into(), github: Some("dana".into()), jira_id: None, @@ -1922,6 +1873,47 @@ pub(crate) mod tests { assert!(r.who.contains("GitHub @dana") && r.who.contains("Jira")); } + #[tokio::test] + async fn an_email_match_never_links_a_jira_account() { + // Dana's email is on a Jira account CoderHelm has seen, and a run + // she asked for recorded that account, but she never linked it. + let mut s = store(); + s.jira_users = vec![(TEAM.into(), JIRA_ME.into(), "USER#someone-else".into())]; + s.runs.push(( + TEAM.into(), + crate::routes::chat_work_runs::tests::run( + "01J", + "completed", + "ABC-9", + "Old", + "acme/web", + ) + .into_iter() + .chain([ + ( + "requester_key".to_string(), + AttributeValue::S(format!("jira:{JIRA_ME}")), + ), + ("requester_email".to_string(), AttributeValue::S(ME.into())), + ]) + .collect(), + )); + let h = http(); + let a = app(); + let r = report_with(&s, &h, Some(&a), None).await; + let jira = r.sources.iter().find(|x| x.name == "Jira").unwrap(); + assert_eq!(jira.read, Read::Off(NOT_LINKED.into())); + assert!(r.needs.iter().all(|n| n.loc != "Jira"), "{:?}", r.needs); + assert!( + h.sent + .lock() + .unwrap() + .iter() + .all(|x| !x.url.contains("jira-app")), + "Jira is never asked for an account the person didn't link" + ); + } + #[tokio::test] async fn another_teams_records_never_show() { let s = store(); diff --git a/services/gateway/src/routes/foryou.rs b/services/gateway/src/routes/foryou.rs new file mode 100644 index 000000000..6be007468 --- /dev/null +++ b/services/gateway/src/routes/foryou.rs @@ -0,0 +1,1818 @@ +//! `GET /api/foryou`: one person's own page, read for the session's user +//! only. No route here takes a user: every read and write is keyed by the +//! session's team and the session's user. +//! +//! What it joins, all of it already read elsewhere (nothing forked): +//! +//! - **Pull requests** from the records `GET /api/prs` reads +//! (`prs::read_all`, `common::pr_view::rows`), grouped by whose turn it is +//! (`common::foryou::pr_group`): reviews asked of you, your pull requests +//! returned to you, and yours waiting on someone else. +//! - **CoderHelm's runs, held tool calls and Jira** from +//! `chat_work_needs::gather`, the same function Chat's "what needs me" +//! uses, with the person's linked Jira account (never an email match). +//! - **The open sprint** from the team's Jira app (`sprint` read, the +//! account id written into the JQL), with a fit band per ticket +//! (`common::foryou::fit`). +//! - **Private stats**: what waits on you, your pull requests waiting on +//! others, and your median review turnaround from the pull request +//! history. Nothing is ranked or compared with anyone. +//! - **Suggestions**, one per row, with their lifecycle +//! (`common::foryou::reconcile`). +//! +//! The heavy reads are kept for 30 seconds per installation, team and user +//! ([`READS`]); the person's own settings are read fresh on every call. + +use std::collections::{BTreeMap, BTreeSet, HashMap}; +use std::sync::{Arc, LazyLock}; +use std::time::{Duration, Instant}; + +use aws_sdk_dynamodb::types::AttributeValue; +use axum::{extract::State, http::StatusCode, Extension, Json}; +use common::foryou::{self, Band, Evidence, Mark, Prefs, Standing, Suggestion, TicketFacts}; +use common::pr_history::History; +use common::pr_view::Row; +use serde::Deserialize; +use serde_json::{json, Value}; +use tracing::warn; + +use super::chat_work_needs as needs; +use super::foryou_link::user_of; +use super::run_checks::{read_key, TtlCache}; +use crate::models::Claims; +use crate::AppState; + +pub type Item = HashMap; + +/// How long one person's heavy reads are reused. +const READ_TTL: Duration = Duration::from_secs(30); +/// How far the history is read: expertise for review suggestions. +const HISTORY_DAYS: i64 = 90; + +/// One person's heavy reads, keyed by +/// `read_key(installation_id, "foryou##")`: never shared +/// between people or teams. +static READS: LazyLock>> = LazyLock::new(TtlCache::new); + +/// What the Jira app said about the person's open sprint. +#[derive(Debug, Clone, PartialEq)] +pub enum Sprint { + Ok(Vec), + /// The person hasn't linked a Jira account. + NotLinked, + /// The team's Jira isn't connected (why). + NotConnected(String), + /// The site runs an app from before the sprint read. + Old, + Failed(String), +} + +/// Everything read for one person, besides their settings. +#[derive(Debug, Clone)] +pub struct Reads { + pub report: needs::Report, + pub runs: Vec, + pub sprint: Sprint, + pub history: Vec, + pub given: BTreeMap, + pub seen_users: Vec, + pub sources: Vec, + pub site: String, + pub read_at: i64, +} + +fn now() -> i64 { + chrono::Utc::now().timestamp() +} + +fn st<'a>(item: &'a Item, k: &str) -> &'a str { + item.get(k) + .and_then(|v| v.as_s().ok()) + .map(String::as_str) + .unwrap_or("") +} + +fn parse_time(s: &str) -> i64 { + needs::parse_time(s).map(|t| t.timestamp()).unwrap_or(0) +} + +fn iso(t: i64) -> Option { + common::pr_view::rfc3339(t) +} + +// ── The person's settings ─────────────────────────────────────────────────── + +/// The person's settings, or the defaults. +pub async fn read_prefs(state: &AppState, team: &str, user: &str) -> (Prefs, Option) { + let r = state + .dynamo + .get_item() + .table_name(&state.config.settings_table_name) + .key("pk", AttributeValue::S(team.into())) + .key("sk", AttributeValue::S(foryou::user_sk(user))) + .consistent_read(true) + .send() + .await; + let Ok(Some(item)) = r.map(|o| o.item) else { + return (Prefs::default(), None); + }; + let v = item + .get("v") + .and_then(|v| v.as_n().ok()) + .and_then(|n| n.parse().ok()); + let prefs = item + .get("doc") + .and_then(|d| d.as_s().ok()) + .and_then(|d| serde_json::from_str(d).ok()) + .unwrap_or_default(); + (prefs, v) +} + +/// Writes the settings with a version check; `false` when someone else +/// wrote first (the caller reads again). +async fn write_prefs( + state: &AppState, + team: &str, + user: &str, + prefs: &Prefs, + v: Option, +) -> Result { + let doc = serde_json::to_string(prefs).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + let next = v.unwrap_or(0) + 1; + let mut put = state + .dynamo + .put_item() + .table_name(&state.config.settings_table_name) + .item("pk", AttributeValue::S(team.into())) + .item("sk", AttributeValue::S(foryou::user_sk(user))) + .item("doc", AttributeValue::S(doc)) + .item("v", AttributeValue::N(next.to_string())); + put = match v { + Some(old) => put + .condition_expression("v = :old") + .expression_attribute_values(":old", AttributeValue::N(old.to_string())), + None => put.condition_expression("attribute_not_exists(sk)"), + }; + match put.send().await { + Ok(_) => Ok(true), + Err(e) + if e.as_service_error() + .is_some_and(|x| x.is_conditional_check_failed_exception()) => + { + Ok(false) + } + Err(e) => { + warn!(error = %e, "For you: settings not written"); + Err(StatusCode::INTERNAL_SERVER_ERROR) + } + } +} + +/// Changes the session user's settings: read, change, write with a version +/// check, a few tries. +pub async fn update_prefs( + state: &AppState, + claims: &Claims, + mut change: impl FnMut(&mut Prefs) -> Result, +) -> Result<(Prefs, T), StatusCode> { + let user = user_of(claims); + for _ in 0..4 { + let (mut prefs, v) = read_prefs(state, &claims.team_id, &user).await; + let out = change(&mut prefs).map_err(|_| StatusCode::BAD_REQUEST)?; + prefs.tidy(now()); + if write_prefs(state, &claims.team_id, &user, &prefs, v).await? { + return Ok((prefs, out)); + } + } + Err(StatusCode::CONFLICT) +} + +// ── Reads ─────────────────────────────────────────────────────────────────── + +/// `gather`'s store with the runs already read (the page reads them once, +/// for its own lists too). +struct Prefetched<'a> { + runs: Result, String>, + inner: needs::Dynamo<'a>, +} + +#[async_trait::async_trait] +impl needs::Store for Prefetched<'_> { + async fn runs(&self, _team: &str) -> Result, String> { + self.runs.clone() + } + async fn approvals(&self, team: &str) -> Result, String> { + self.inner.approvals(team).await + } + async fn jira_link(&self, _team: &str, _user: &str) -> Option { + // The caller passes the link it read; nothing is looked up here. + None + } +} + +/// Asks the team's Jira app for the person's open sprint. +pub async fn ask_sprint( + http: &dyn common::mcp_remote::http::Http, + app: &super::chat_work_tickets::JiraApp, + account: &str, +) -> Sprint { + use common::mcp_remote::http::{HttpRequest, Limit}; + let body = json!({ "forge_secret": app.secret, "sprint": { "account_id": account } }); + let r = match http + .send(HttpRequest::json(&app.issues_url, &body, Limit::Metadata)) + .await + { + Ok(r) => r, + Err(e) => return Sprint::Failed(format!("Jira couldn't be reached: {e}")), + }; + if r.status != 200 { + return Sprint::Failed(format!("Jira's app answered {}", r.status)); + } + let Some(v) = r.json() else { + return Sprint::Failed("Jira's app sent something unreadable".into()); + }; + if !v["sprint"].is_object() { + return Sprint::Old; + } + if v["sprint"]["found"] != true { + return Sprint::Failed( + v["sprint"]["why"] + .as_str() + .unwrap_or("the sprint couldn't be read") + .to_string(), + ); + } + Sprint::Ok(v["issues"].as_array().cloned().unwrap_or_default()) +} + +async fn given_rows(state: &AppState, team: &str) -> BTreeMap { + let mut out = BTreeMap::new(); + let Ok(r) = state + .dynamo + .query() + .table_name(&state.config.settings_table_name) + .key_condition_expression("pk = :p AND begins_with(sk, :s)") + .expression_attribute_values(":p", AttributeValue::S(team.into())) + .expression_attribute_values(":s", AttributeValue::S(foryou::GIVE_PREFIX.into())) + .send() + .await + else { + return out; + }; + for i in r.items() { + if let Some(g) = i + .get("doc") + .and_then(|d| d.as_s().ok()) + .and_then(|d| serde_json::from_str::(d).ok()) + { + out.insert(g.ticket.clone(), g); + } + } + out +} + +/// The heavy reads for one person, from the short cache or fresh. +pub async fn reads( + state: &Arc, + claims: &Claims, + jira_account: Option<&str>, +) -> Arc { + let installation = super::api::get_team_installation_id(state, &claims.team_id) + .await + .unwrap_or(0); + let user = user_of(claims); + let key = read_key(installation, &format!("foryou#{}#{user}", claims.team_id)); + let at = Instant::now(); + if let Some(hit) = READS.get(&key, at) { + return hit; + } + let team = claims.team_id.as_str(); + let holder = super::roles::holder_for(state, claims).await; + let open = { + let auds = crate::bases::audiences(state, team).await; + let who = crate::bases::Asker { + holder: &holder, + email: &claims.email, + }; + crate::bases::decide_all(&who, &auds, None) + }; + let readable = crate::bases::readable_kinds(&holder, &open); + let dynamo = needs::Dynamo { state }; + let (runs, jira) = tokio::join!( + async { + if readable.contains(&"runs") { + needs::Store::runs(&dynamo, team).await + } else { + Ok(Vec::new()) + } + }, + super::chat_work_tickets::load(state, team), + ); + let store = Prefetched { + runs: runs.clone(), + inner: needs::Dynamo { state }, + }; + let http = common::mcp_remote::http::GuardedHttps; + let src = needs::Sources { + team, + store: &store, + http: &http, + jira: jira.app.as_ref(), + jira_off: jira.off_words(), + // Pull requests come from the records, which cost no GitHub calls. + github: None, + repos: &[], + readable: &readable, + budget: needs::SOURCE_BUDGET, + }; + let me = needs::Me { + user: claims.sub.clone(), + email: claims.email.trim().to_string(), + github: claims.github_login.clone().filter(|g| !g.trim().is_empty()), + jira_id: jira_account.map(str::to_string), + is_admin: matches!(claims.role.as_str(), "admin" | "owner"), + }; + let t = now(); + let sprint_fut = async { + if !readable.contains(&"tickets") { + return Sprint::NotConnected("your role can't see tickets".into()); + } + let Some(app) = jira.app.as_ref() else { + return Sprint::NotConnected(jira.off_words().to_string()); + }; + let Some(account) = jira_account else { + return Sprint::NotLinked; + }; + match tokio::time::timeout(needs::SOURCE_BUDGET, ask_sprint(&http, app, account)).await { + Ok(s) => s, + Err(_) => Sprint::Failed("Jira didn't answer in time".into()), + } + }; + let (report, sprint, history, given, seen_users) = tokio::join!( + Box::pin(needs::gather(&src, me, chrono::Utc::now())), + sprint_fut, + async { + common::pr_history::all_since( + &state.dynamo, + &state.config.settings_table_name, + team, + t - HISTORY_DAYS * 86_400, + ) + .await + .unwrap_or_else(|e| { + warn!(error = %e, "For you: history not read"); + Vec::new() + }) + }, + given_rows(state, team), + async { + if jira_account.is_none() { + super::foryou_link::seen_jira_users(state, team).await + } else { + Vec::new() + } + }, + ); + let mut sources: Vec = report + .sources + .iter() + .filter(|s| s.name != "GitHub") + .map(|s| match &s.read { + needs::Read::Ok(_) => json!({"name": s.name, "read": "ok", "detail": ""}), + needs::Read::Failed(e) => json!({"name": s.name, "read": "failed", "detail": e}), + needs::Read::Off(w) => json!({"name": s.name, "read": "off", "detail": w}), + }) + .collect(); + sources.push(match &sprint { + Sprint::Ok(_) => json!({"name": "Sprint", "read": "ok", "detail": ""}), + Sprint::NotLinked => json!({"name": "Sprint", "read": "off", "detail": needs::NOT_LINKED}), + Sprint::NotConnected(w) => json!({"name": "Sprint", "read": "off", "detail": w}), + Sprint::Old => json!({"name": "Sprint", "read": "old", "detail": "the team's Jira app is an older version that can't read a sprint; an admin updates it in Atlassian Administration"}), + Sprint::Failed(e) => json!({"name": "Sprint", "read": "failed", "detail": e}), + }); + let v = Arc::new(Reads { + report, + runs: runs.unwrap_or_default(), + sprint, + history, + given, + seen_users, + sources, + site: jira + .app + .as_ref() + .map(|a| a.site.clone()) + .unwrap_or_default(), + read_at: t, + }); + READS.put(key, v.clone(), READ_TTL, at); + v +} + +/// Forgets one person's reads (after they give a ticket, so the next read +/// shows it). +pub async fn forget(state: &AppState, claims: &Claims) { + let installation = super::api::get_team_installation_id(state, &claims.team_id) + .await + .unwrap_or(0); + let key = read_key( + installation, + &format!("foryou#{}#{}", claims.team_id, user_of(claims)), + ); + READS.put(key, Arc::new(empty_reads()), Duration::ZERO, Instant::now()); +} + +fn empty_reads() -> Reads { + Reads { + report: needs::Report::default(), + runs: Vec::new(), + sprint: Sprint::NotLinked, + history: Vec::new(), + given: BTreeMap::new(), + seen_users: Vec::new(), + sources: Vec::new(), + site: String::new(), + read_at: 0, + } +} + +// ── The page, pure ────────────────────────────────────────────────────────── + +/// Who the page is for. +#[derive(Debug, Clone, Default)] +pub struct Viewer { + pub user: String, + pub name: String, + pub email: String, + pub github: Option, + pub jira: Option, + pub jira_name: String, +} + +/// One sprint ticket, read from the Jira app. +#[derive(Debug, Clone, Default)] +pub struct SprintTicket { + pub key: String, + pub title: String, + pub status: String, + pub category: String, + pub priority: String, + pub issue_type: String, + pub labels: Vec, + pub components: Vec, + pub points: Option, + pub description: String, + pub sprint_name: String, + pub sprint_end: String, +} + +pub fn sprint_ticket(v: &Value) -> SprintTicket { + let s = |k: &str| v[k].as_str().unwrap_or("").to_string(); + let list = |k: &str| -> Vec { + v[k].as_array() + .into_iter() + .flatten() + .filter_map(|x| x.as_str().map(str::to_string)) + .collect() + }; + SprintTicket { + key: s("key"), + title: s("summary"), + status: s("status"), + category: s("status_category"), + priority: s("priority"), + issue_type: s("type"), + labels: list("labels"), + components: list("components"), + points: v["points"].as_f64(), + description: s("description"), + sprint_name: v["sprint"]["name"].as_str().unwrap_or("").to_string(), + sprint_end: v["sprint"]["end_date"].as_str().unwrap_or("").to_string(), + } +} + +/// The repositories a ticket would change, and how that is known: a +/// `coderhelm:` label, the ticket naming a repository, or where +/// this project's earlier runs went. +pub fn repo_hints( + t: &SprintTicket, + team_repos: &[String], + runs: &[Item], +) -> (Vec, &'static str) { + let pinned: Vec = t + .labels + .iter() + .filter_map(|l| l.split_once(':')) + .filter(|(p, r)| p.eq_ignore_ascii_case("coderhelm") && r.contains('/')) + .map(|(_, r)| r.to_string()) + .collect(); + if !pinned.is_empty() { + return (pinned, "label"); + } + let text = format!("{} {}", t.title, t.description).to_ascii_lowercase(); + let named: Vec = team_repos + .iter() + .filter(|r| { + let r = r.to_ascii_lowercase(); + text.contains(&r) + }) + .cloned() + .collect(); + if !named.is_empty() { + return (named, "ticket"); + } + let project = t.key.split('-').next().unwrap_or(""); + let mut counts: BTreeMap = BTreeMap::new(); + for r in runs { + let tk = st(r, "ticket_id"); + let repo = st(r, "repo"); + if !project.is_empty() && !repo.is_empty() && tk.starts_with(&format!("{project}-")) { + *counts.entry(repo.to_string()).or_default() += 1; + } + } + let mut best: Vec<(usize, String)> = counts.into_iter().map(|(r, n)| (n, r)).collect(); + best.sort_by(|a, b| b.0.cmp(&a.0).then(a.1.cmp(&b.1))); + match best.first() { + Some((n, r)) if *n >= 2 => (vec![r.clone()], "history"), + _ => (Vec::new(), ""), + } +} + +/// Repositories whose pull requests run a test check, with that check's +/// name (from the records' check attempts). +pub fn test_checks(recs: &[common::pr_record::PrRecord]) -> BTreeMap { + let mut out = BTreeMap::new(); + for r in recs { + for c in &r.check_attempts { + let n = c.name.to_ascii_lowercase(); + if ["test", "spec", "jest", "pytest", "vitest", "e2e"] + .iter() + .any(|w| n.contains(w)) + { + out.entry(r.repo.clone()).or_insert_with(|| c.name.clone()); + } + } + } + out +} + +/// A run's stage on the page's bar. +pub fn stage_of(item: &Item) -> (&'static str, String) { + let status = st(item, "status"); + if status == common::run_status::NEEDS_INPUT { + return ("waiting", "Waiting on you".into()); + } + match st(item, "current_pass") { + "" | "triage" | "plan" => ("planning", "Planning".into()), + "ci" | "ci_fix" | "fix_ci" => ("ci", "CI".into()), + "feedback" | "fix_round" => ("coding", "Addressing review".into()), + _ => ("coding", "Coding".into()), + } +} + +fn first_person(from: &[String]) -> Option { + from.iter() + .find_map(|f| f.strip_prefix("person:")) + .map(str::to_string) +} + +fn pr_label(state: &str) -> (&'static str, &'static str) { + match state { + "needs_review" | "needs_reviewer" => ("Review requested", "Review"), + "re_review" => ("Review again", "Review"), + "needs_code_owner" => ("Code owner review", "Review"), + "checks_failing" => ("Checks failing", "Open checks"), + "changes_requested" => ("Changes requested", "See comments"), + "conflicts" => ("Conflicts", "Resolve"), + "open_threads" => ("Open conversations", "Reply"), + "ready_to_merge" | "ready_auto_merge" => ("Ready to merge", "Merge"), + "needs_decision" => ("Decision needed", "Decide"), + _ => ("Your turn", "Open"), + } +} + +fn pr_href(row: &Row, action: &str) -> String { + match action { + "Review" | "Merge" | "Decide" => { + let q = format!( + "repo={}&number={}", + urlencoding::encode(&row.repo), + row.number + ); + match row.coderhelm.as_ref().and_then(|c| c.run_id.clone()) { + Some(run) => format!("/inbox/pr?{q}&run={}", urlencoding::encode(&run)), + None => format!("/inbox/pr?{q}"), + } + } + "Open checks" => format!("{}/checks", row.url), + _ => row.url.clone(), + } +} + +fn since_of(row: &Row) -> String { + row.waiting_since + .clone() + .or_else(|| row.next.since.clone()) + .or_else(|| row.updated_at.clone()) + .unwrap_or_default() +} + +/// A ticket key at the start of a need's "what" ("BOOK-101 Store ..."). +fn key_of(what: &str) -> Option { + let w = what.split_whitespace().next()?; + super::chat_work_tickets::valid_key(w).then(|| w.to_string()) +} + +/// Everything the page builds from, read and pure. +pub struct Input<'a> { + pub viewer: &'a Viewer, + pub rows: &'a [Row], + pub records: &'a [common::pr_record::PrRecord], + pub reads: &'a Reads, + pub team_repos: &'a [String], + pub layout: foryou::Layout, + pub now: i64, +} + +/// The page, for one person, from what was read. Changes `prefs` only in +/// what the suggestions' lifecycle keeps (`shown`, re-shown dismissals). +pub fn build(input: &Input, prefs: &mut Prefs) -> Value { + let v = input.viewer; + let now = input.now; + let login = v.github.clone().unwrap_or_default(); + let reads = input.reads; + let mut needs_out: BTreeMap<&str, Vec> = BTreeMap::new(); + let mut waiting: Vec = Vec::new(); + let mut later: Vec = Vec::new(); + + let mut place = |group: &'static str, item: Value, since: &str, later: &mut Vec| { + let key = item["key"].as_str().unwrap_or("").to_string(); + match foryou::standing(prefs.marks.get(&key), since, now) { + Standing::Open => match group { + "waiting" => waiting.push(item), + g => needs_out.entry(g).or_default().push(item), + }, + Standing::Snoozed(until) => { + let mut it = item; + it["snoozed_until"] = json!(iso(until)); + it["later"] = json!("snoozed"); + later.push(it); + } + Standing::Done => {} + } + }; + + // Pull requests. + for row in input.rows { + let Some(g) = foryou::pr_group(row, &login) else { + continue; + }; + let since = since_of(row); + let key = format!("pr:{}#{}", row.repo, row.number); + let by_coderhelm = row.author.coderhelm; + match g { + foryou::PrGroup::Reviews | foryou::PrGroup::Returned => { + let (label, action) = pr_label(&row.state); + let who = if g == foryou::PrGroup::Reviews { + Some(row.author.login.clone()) + } else { + row.reviews + .changes_requested_by + .first() + .cloned() + .or_else(|| first_person(&row.next.from)) + .filter(|p| !p.eq_ignore_ascii_case(&login)) + }; + let item = json!({ + "key": key, + "group": if g == foryou::PrGroup::Reviews { "reviews" } else { "returned" }, + "kind": row.state, + "label": label, + "where": format!("{}#{}", row.repo, row.number), + "title": row.title, + "why": row.next.text, + "since": since, + "who": who, + "by_coderhelm": by_coderhelm, + "action": {"label": action, "href": pr_href(row, action)}, + "href": row.url, + "pr": {"repo": row.repo, "number": row.number}, + "run_id": row.coderhelm.as_ref().and_then(|c| c.run_id.clone()), + }); + let group = if g == foryou::PrGroup::Reviews { + "reviews" + } else { + "returned" + }; + place(group, item, &since, &mut later); + } + foryou::PrGroup::Waiting => { + let next_who = first_person(&row.next.from); + let item = json!({ + "key": key, + "where": format!("{}#{}", row.repo, row.number), + "title": row.title, + "next": { + "who": next_who, + "what": row.state_label.to_lowercase(), + "text": row.next.text, + "turn": row.turn, + }, + "since": since, + "by_coderhelm": by_coderhelm, + "href": row.url, + "nudge_href": row.url, + "pr": {"repo": row.repo, "number": row.number}, + }); + place("waiting", item, &since, &mut later); + } + } + } + + // CoderHelm asks you (from gather), and Jira's FYI. + let mut sprint_keys: BTreeSet = BTreeSet::new(); + let tickets: Vec = match &reads.sprint { + Sprint::Ok(list) => list.iter().map(sprint_ticket).collect(), + _ => Vec::new(), + }; + for t in &tickets { + sprint_keys.insert(t.key.clone()); + } + for n in &reads.report.needs { + if !n.urgency.is_need() { + continue; + } + match n.kind { + "run" => { + let run_id = n + .link + .split("id=") + .nth(1) + .map(|s| s.split('&').next().unwrap_or(s).to_string()) + .unwrap_or_default(); + let is_plan = n.detail.contains(foryou::PLAN_QUESTION); + let question = n + .detail + .lines() + .find(|l| !l.trim().is_empty()) + .unwrap_or("") + .trim() + .trim_start_matches(['-', '1', '.', ' ']) + .to_string(); + let label = if is_plan { + "Plan to approve" + } else if n.action.starts_with("Answer") { + "Question" + } else { + "Waiting on you" + }; + let ticket = key_of(&n.what); + let title = match &ticket { + Some(k) => n.what.trim_start_matches(k.as_str()).trim().to_string(), + None => n.what.clone(), + }; + let where_ = [ticket.clone().unwrap_or_default(), n.loc.clone()] + .into_iter() + .filter(|x| !x.is_empty()) + .collect::>() + .join(" \u{b7} "); + let kind = if is_plan { + "plan" + } else if label == "Question" { + "question" + } else { + "wait" + }; + let why = if question.is_empty() { + n.action.clone() + } else if is_plan { + "CoderHelm wrote the plan and waits for your OK before coding.".to_string() + } else { + format!("CoderHelm asks: {question}") + }; + let action = match kind { + "plan" => "Review plan", + "question" => "Answer", + _ => "Open", + }; + let href = if run_id.is_empty() { + n.link.clone() + } else { + format!("/inbox/answer?run={}", urlencoding::encode(&run_id)) + }; + let item = json!({ + "key": format!("run:{run_id}"), + "group": "asks", + "kind": kind, + "label": label, + "where": where_, + "title": title, + "why": why, + "since": n.since, + "who": Value::Null, + "by_coderhelm": true, + "action": {"label": action, "href": href}, + "href": n.link, + "run_id": run_id, + "ticket": ticket, + }); + place("asks", item, &n.since.clone(), &mut later); + } + "record" => { + let why = if n.detail.is_empty() { + n.action.clone() + } else { + format!("CoderHelm asks to {}", n.detail.trim_end_matches('.')) + }; + let item = json!({ + "key": format!("approval:{}:{}", n.what, n.since), + "group": "asks", + "kind": "approval", + "label": "Approval", + "where": n.loc, + "title": n.what, + "why": why, + "since": n.since, + "who": Value::Null, + "by_coderhelm": true, + "action": {"label": "Review and approve", "href": n.link}, + "href": n.link, + }); + place("asks", item, &n.since.clone(), &mut later); + } + "ticket" => { + let key = key_of(&n.what).unwrap_or_default(); + if sprint_keys.contains(&key) && !n.action.starts_with("Reply") { + continue; + } + let fyi = n.action.starts_with("Reply"); + later.push(json!({ + "key": format!("jira:{key}"), + "later": if fyi { "fyi" } else { "not_in_sprint" }, + "title": n.what.trim_start_matches(key.as_str()).trim(), + "where": key, + "why": n.action, + "since": n.since, + "href": n.link, + })); + } + _ => {} + } + } + + // CoderHelm working for you. + let me_needs = needs::Me { + user: v.user.clone(), + email: v.email.clone(), + github: v.github.clone(), + jira_id: v.jira.clone(), + is_admin: false, + }; + let mine: Vec = sprint_keys.iter().cloned().collect(); + let mut working: Vec = Vec::new(); + let mut runs_by_ticket: BTreeMap = BTreeMap::new(); + for r in &reads.runs { + let tk = st(r, "ticket_id"); + if !tk.is_empty() { + let newer = runs_by_ticket + .get(tk) + .is_none_or(|o| st(o, "created_at") < st(r, "created_at")); + if newer { + runs_by_ticket.insert(tk.to_string(), r); + } + } + let status = st(r, "status"); + let active = common::pr_view::RUN_ACTIVE.contains(&status) + || status == common::run_status::NEEDS_INPUT; + let given_to_me = reads.given.get(tk).is_some_and(|g| g.owner == v.user); + if !active || !(needs::run_is_mine(r, &me_needs, &mine) || given_to_me) { + continue; + } + let (stage, stage_label) = stage_of(r); + let id = st(r, "run_id"); + let pr = st(r, "pr_url"); + working.push(json!({ + "run_id": id, + "ticket": (!tk.is_empty()).then(|| tk.to_string()), + "repo": st(r, "repo"), + "title": st(r, "title"), + "started_at": st(r, "created_at"), + "stage": stage, + "stage_label": stage_label, + "note": format!("CoderHelm is {}.", common::pr_view::what_of(st(r, "current_pass"))), + "waiting_on_you": stage == "waiting", + "plan_first": reads.given.get(tk).is_some_and(|g| g.plan_first), + "owner": "you", + "delegate": "CoderHelm", + "pr": (!pr.is_empty()).then(|| json!({"url": pr, "number": st(r, "pr_number")})), + "href": format!("/runs/detail?id={}", urlencoding::encode(id)), + })); + } + + // The sprint, with a fit per ticket. + let tests = test_checks(input.records); + let mut sprint_tickets: Vec = Vec::new(); + let mut facts: Vec<(SprintTicket, foryou::Fit, TicketFacts)> = Vec::new(); + for t in &tickets { + let (repos, source) = repo_hints(t, input.team_repos, &reads.runs); + let run = runs_by_ticket.get(&t.key); + let given = reads.given.get(&t.key); + let delegated = run.map(|r| { + let (stage, label) = stage_of(r); + let status = st(r, "status"); + let done = !common::pr_view::RUN_ACTIVE.contains(&status) + && status != common::run_status::NEEDS_INPUT; + json!({ + "run_id": st(r, "run_id"), + "status": status, + "stage": if done { "done" } else { stage }, + "label": if done { status.replace('_', " ") } else { label }, + "waiting_on_you": stage == "waiting", + "plan_first": given.is_some_and(|g| g.plan_first), + }) + }); + // Given here, and no run yet: starting, or not started after a while. + let starting = given + .filter(|g| run.is_none_or(|r| parse_time(st(r, "created_at")) < g.given_at)) + .map(|g| { + let late = now - g.given_at > 180; + json!({ + "run_id": Value::Null, + "status": if late { "not_started" } else { "starting" }, + "stage": if late { "not_started" } else { "starting" }, + "label": if late { "Not started yet" } else { "Starting" }, + "waiting_on_you": false, + "plan_first": g.plan_first, + }) + }); + let active_run = run.is_some_and(|r| { + let s = st(r, "status"); + common::pr_view::RUN_ACTIVE.contains(&s) || s == common::run_status::NEEDS_INPUT + }); + let delegated = if starting.is_some() && !active_run { + starting + } else if active_run { + delegated + } else { + None + }; + let tf = TicketFacts { + key: t.key.clone(), + title: t.title.clone(), + description: t.description.clone(), + issue_type: t.issue_type.clone(), + labels: t.labels.clone(), + components: t.components.clone(), + priority: t.priority.clone(), + points: t.points, + repos: repos.clone(), + repo_source: source.into(), + tests: (repos.len() == 1 && tests.contains_key(&repos[0])).then_some(true), + }; + let fit = (t.category == "new" && delegated.is_none()).then(|| foryou::fit(&tf)); + let pr_note = input + .rows + .iter() + .find(|r| r.title.contains(&t.key) || r.head.to_ascii_uppercase().contains(&t.key)) + .map(|r| match first_person(&r.next.from) { + Some(p) if r.turn != "you" => format!("{}#{} waits on @{p}", r.repo, r.number), + _ => format!("{}#{} {}", r.repo, r.number, r.state_label.to_lowercase()), + }); + let note = + pr_note.or_else(|| (t.category == "indeterminate").then(|| "In progress".to_string())); + sprint_tickets.push(json!({ + "key": t.key, + "title": t.title, + "url": if reads.site.is_empty() { Value::Null } else { json!(format!("{}/browse/{}", reads.site.trim_end_matches('/'), t.key)) }, + "status": t.status, + "status_category": t.category, + "points": t.points, + "type": t.issue_type, + "repos": repos, + "repo_source": source, + "fit": fit, + "delegated": delegated, + "note": note, + })); + if let Some(f) = fit { + facts.push((t.clone(), f, tf)); + } + } + let sprint_meta = { + let mut names: BTreeMap<&str, usize> = BTreeMap::new(); + for t in &tickets { + if !t.sprint_name.is_empty() { + *names.entry(t.sprint_name.as_str()).or_default() += 1; + } + } + let name = names + .iter() + .max_by_key(|(_, n)| **n) + .map(|(k, _)| k.to_string()); + let end = tickets + .iter() + .find(|t| Some(&t.sprint_name) == name.as_ref()) + .map(|t| t.sprint_end.clone()) + .filter(|e| !e.is_empty()); + let points: f64 = tickets.iter().filter_map(|t| t.points).sum(); + let project = tickets + .first() + .and_then(|t| t.key.split('-').next()) + .map(str::to_string); + let end_at = end.as_deref().map(parse_time).unwrap_or(0); + json!({ + "name": name, + "project": project, + "end_date": end, + "days_left": (end_at > 0).then(|| ((end_at - now) as f64 / 86_400.0).ceil().max(0.0) as i64), + "points": points, + }) + }; + let sprint_end_at = sprint_meta["end_date"] + .as_str() + .map(parse_time) + .unwrap_or(0); + let sprint_out = match &reads.sprint { + Sprint::Ok(_) => { + json!({"state": "ok", "detail": "", "meta": sprint_meta, "tickets": sprint_tickets}) + } + Sprint::NotLinked => { + json!({"state": "not_linked", "detail": needs::NOT_LINKED, "meta": Value::Null, "tickets": []}) + } + Sprint::NotConnected(w) => { + json!({"state": "not_connected", "detail": w, "meta": Value::Null, "tickets": []}) + } + Sprint::Old => { + json!({"state": "app_old", "detail": "Your Jira site runs an older CoderHelm app that can't read a sprint. An admin updates it in Atlassian Administration.", "meta": Value::Null, "tickets": []}) + } + Sprint::Failed(e) => { + json!({"state": "failed", "detail": e, "meta": Value::Null, "tickets": []}) + } + }; + + // Suggestions. + let as_of = iso(reads.read_at.max(1)).unwrap_or_default(); + let weekday = |t: i64| { + chrono::DateTime::from_timestamp(t, 0) + .map(|d| d.format("%A").to_string()) + .unwrap_or_default() + }; + let mut computed: Vec = Vec::new(); + let mut gone: BTreeMap = BTreeMap::new(); + let durations: BTreeMap = { + let mut by: BTreeMap> = BTreeMap::new(); + for r in &reads.runs { + if [common::run_status::COMPLETED, common::run_status::SUCCESS] + .contains(&st(r, "status")) + { + if let Some(d) = r + .get("duration_s") + .and_then(|v| v.as_n().ok()) + .and_then(|n| n.parse::().ok()) + { + by.entry(st(r, "repo").to_string()) + .or_default() + .push(d as i64); + } + } + } + by.into_iter() + .filter(|(_, v)| v.len() >= 3) + .filter_map(|(k, v)| common::pr_history::percentile(&v, 50).map(|m| (k, m))) + .collect() + }; + for (t, fit, tf) in &facts { + if fit.band != Band::Good { + continue; + } + let repo = tf.repos.first().cloned().unwrap_or_default(); + let mut evidence: Vec = fit + .why + .iter() + .map(|w| Evidence { + text: w.clone(), + href: None, + }) + .collect(); + if let Some(c) = tests.get(&repo) { + evidence.push(Evidence { + text: format!("{repo} runs the check {c} on its pull requests"), + href: None, + }); + } + if !t.sprint_name.is_empty() { + evidence.push(Evidence { + text: format!( + "In your open sprint ({}), assigned to you, not started", + t.sprint_name + ), + href: None, + }); + } + let reason = { + let mut bits: Vec = Vec::new(); + if fit.why.iter().any(|w| w.starts_with("Acceptance")) { + bits.push("Acceptance criteria".into()); + } + if fit.why.iter().any(|w| w.starts_with("Names the files")) { + bits.push("the files are named".into()); + } else if fit.why.iter().any(|w| w.starts_with("Names the area")) { + bits.push("the area is named".into()); + } + let mut r = bits.join(" and "); + if let Some(p) = t.points { + r.push_str(&format!( + "; {} {}", + p, + if p == 1.0 { "point" } else { "points" } + )); + } + r + }; + let effort = match durations.get(&repo) { + Some(secs) => format!( + "~{} min for CoderHelm, then one PR for you to review", + (secs / 60).max(1) + ), + None => "One PR for you to review".into(), + }; + computed.push(Suggestion { + key: format!("give:{}", t.key), + kind: "give".into(), + target: Some(format!("ticket:{}", t.key)), + text: format!("Give {} to CoderHelm", t.key), + action: "Give to CoderHelm".into(), + href: None, + reason, + evidence, + effect: "Opens a preview first. Nothing starts until you confirm. CoderHelm opens one draft pull request, and the ticket stays yours.".into(), + effort, + deadline: (sprint_end_at > now).then(|| format!("Sprint ends {}", weekday(sprint_end_at))), + as_of: as_of.clone(), + kind_words: fit.kind.clone(), + dismiss_reasons: foryou::dismiss_reasons(&fit.kind), + back_because: None, + basis: foryou::basis_of(&[ + &t.key, + &t.title, + &t.description, + &t.points.map(|p| p.to_string()).unwrap_or_default(), + &t.category, + &tf.repos.join(","), + ]), + basis_words: format!("{} changed (its text, estimate, status or repository)", t.key), + }); + } + // Review suggestions: pull requests nobody was asked to review, in files + // you changed in your own merged pull requests. + let my_merged: Vec<&History> = reads + .history + .iter() + .filter(|h| h.merged && !login.is_empty() && h.author.eq_ignore_ascii_case(&login)) + .collect(); + let mut by_rec: BTreeMap = BTreeMap::new(); + for r in input.records { + by_rec.insert(format!("{}#{}", r.repo, r.number), r); + } + for row in input.rows { + let k = format!("{}#{}", row.repo, row.number); + let open_for_review = row.stage.as_deref() == Some("first_review") + && !row.draft + && row.reviews.requested.is_empty() + && row.reviews.approvals == 0 + && row.reviews.changes_requested_by.is_empty() + && !row.author.login.eq_ignore_ascii_case(&login) + && row.turn != "you"; + let Some(rec) = by_rec.get(&k) else { continue }; + if !open_for_review || !rec.requested_teams.is_empty() || my_merged.is_empty() { + if prefs.shown.contains_key(&format!("review:{k}")) { + let who = row.reviews.requested.first().cloned().or_else(|| { + rec.review_log + .iter() + .rev() + .find(|r| r.human) + .map(|r| r.who.clone()) + }); + gone.insert( + format!("review:{k}"), + match who { + Some(w) => { + format!("Someone else picked it up: @{w} took the review of {k}") + } + None => format!("It no longer needs a reviewer: {k} moved on"), + }, + ); + } + continue; + } + let mut best: Option<(&str, usize)> = None; + for f in &rec.files { + let n = my_merged + .iter() + .filter(|h| h.files.iter().any(|x| x == f)) + .count(); + if n >= 2 && best.is_none_or(|(_, b)| n > b) { + best = Some((f.as_str(), n)); + } + } + let Some((file, n)) = best else { continue }; + let lines = row + .size + .as_ref() + .map(|s| s.additions + s.deletions) + .unwrap_or(0); + let minutes = (lines / 10).clamp(5, 60); + let opened = row + .ready_at + .clone() + .or(row.created_at.clone()) + .unwrap_or_default(); + let key = format!("review:{k}"); + computed.push(Suggestion { + key: key.clone(), + kind: "review".into(), + target: Some(format!("pr:{k}")), + text: if sprint_end_at > now { + format!("Review {k} before {}", weekday(sprint_end_at)) + } else { + format!("Review {k}") + }, + action: "Add to my reviews".into(), + href: Some(row.url.clone()), + reason: format!( + "You changed {file} in {n} of your {} merged pull requests here; no reviewer yet", + my_merged.len() + ), + evidence: vec![ + Evidence { + text: format!("{k} changes {file}"), + href: Some(row.url.clone()), + }, + Evidence { + text: format!( + "You changed {file} in {n} of your {} merged pull requests in the last {HISTORY_DAYS} days", + my_merged.len() + ), + href: None, + }, + Evidence { + text: format!("Opened by @{}; nobody has been asked to review it", row.author.login), + href: None, + }, + ], + effect: "Adds you as a reviewer on GitHub. No comment is posted.".into(), + effort: if lines > 0 { + format!("{lines} lines, about {minutes} min") + } else { + "A first review".into() + }, + deadline: (sprint_end_at > now).then(|| format!("Before {} (sprint end)", weekday(sprint_end_at))), + as_of: as_of.clone(), + kind_words: "review suggestions".into(), + dismiss_reasons: foryou::dismiss_reasons("review suggestions"), + back_because: None, + basis: foryou::basis_of(&[&k, file, &row.state, &opened]), + basis_words: format!("{k} changed"), + }); + } + // Give suggestions shown before and gone now: say why. + for (k, _) in prefs.shown.iter().filter(|(k, _)| k.starts_with("give:")) { + let key = k.trim_start_matches("give:"); + let reason = match tickets.iter().find(|t| t.key == key) { + None => format!("{key} left your sprint"), + Some(t) if t.category != "new" => format!("{key} was started"), + Some(_) if runs_by_ticket.contains_key(key) || reads.given.contains_key(key) => { + format!("{key} is already with CoderHelm") + } + Some(_) => format!("{key} is no longer a good fit"), + }; + gone.insert(k.clone(), reason); + } + let (visible, withdrawn) = foryou::reconcile(computed, prefs, &gone, now); + + // A suggested review sits in the reviews group as its own row. + for s in visible.iter().filter(|s| s.kind == "review") { + let k = s.target.as_deref().unwrap_or("").trim_start_matches("pr:"); + if let Some(row) = input + .rows + .iter() + .find(|r| format!("{}#{}", r.repo, r.number) == k) + { + needs_out.entry("suggested").or_default().push(json!({ + "key": format!("pr:{k}"), + "group": "reviews", + "kind": "not_requested", + "label": "Not requested of you", + "where": k, + "title": row.title, + "why": format!("Opened by @{} \u{b7} no reviewer yet", row.author.login), + "since": row.ready_at.clone().or(row.created_at.clone()), + "who": row.author.login, + "by_coderhelm": row.author.coderhelm, + "action": Value::Null, + "href": row.url, + "suggested": true, + "pr": {"repo": row.repo, "number": row.number}, + })); + } + } + + let summary = { + let gives: Vec<&Suggestion> = visible.iter().filter(|s| s.kind == "give").collect(); + let reviews: Vec<&Suggestion> = visible.iter().filter(|s| s.kind == "review").collect(); + let mut kinds = Vec::new(); + if !gives.is_empty() { + kinds.push(json!({"kind": "give", "count": gives.len(), "text": format!("{} {} CoderHelm can take", gives.len(), if gives.len() == 1 { "ticket" } else { "tickets" })})); + } + if !reviews.is_empty() { + let when = if sprint_end_at > now { + format!(" before {}", weekday(sprint_end_at)) + } else { + String::new() + }; + kinds.push(json!({"kind": "review", "count": reviews.len(), "text": format!("{} {}{when}", reviews.len(), if reviews.len() == 1 { "review" } else { "reviews" })})); + } + json!({ + "count": visible.len(), + "kinds": kinds, + "top": visible.iter().take(foryou::MAX_SUMMARY).map(|s| json!({"key": s.key, "text": s.text, "reason": s.reason})).collect::>(), + "batch": (gives.len() > 1).then(|| json!({"kind": "give", "keys": gives.iter().map(|s| s.key.trim_start_matches("give:").to_string()).collect::>(), "text": format!("Give {} to CoderHelm", if gives.len() == 2 { "both".to_string() } else { gives.len().to_string() })})), + }) + }; + + // Order within groups: oldest wait first. + let by_since = |a: &Value, b: &Value| { + a["since"] + .as_str() + .unwrap_or("") + .cmp(b["since"].as_str().unwrap_or("")) + }; + for list in needs_out.values_mut() { + list.sort_by(by_since); + } + waiting.sort_by(by_since); + let reviews_list = needs_out.remove("reviews").unwrap_or_default(); + let returned = needs_out.remove("returned").unwrap_or_default(); + let asks = needs_out.remove("asks").unwrap_or_default(); + let suggested_rows = needs_out.remove("suggested").unwrap_or_default(); + let need_count = reviews_list.len() + returned.len() + asks.len(); + let oldest = reviews_list + .iter() + .chain(&returned) + .chain(&asks) + .min_by(|a, b| by_since(a, b)) + .map(|i| json!({"where": i["where"], "since": i["since"]})); + let longest = waiting + .first() + .map(|i| json!({"where": i["where"], "since": i["since"]})); + let turnaround = { + let mut logs: Vec<( + Vec, + Vec, + )> = input + .records + .iter() + .map(|r| (r.request_log.clone(), r.review_log.clone())) + .collect(); + let open: BTreeSet = input + .records + .iter() + .map(|r| format!("{}#{}", r.repo, r.number)) + .collect(); + for h in &reads.history { + if !open.contains(&format!("{}#{}", h.repo, h.number)) { + logs.push((h.request_log.clone(), h.review_log.clone())); + } + } + foryou::review_turnaround(&logs, &login, now) + }; + + // Accounts. + let suggestion = foryou::identity_suggestion(&reads.seen_users, &v.email, &prefs.identity_no).map(|u| { + json!({"account_id": u.account_id, "name": u.name, "why": "Seen in Jira with your sign-in email. Not linked: saying yes gives you a code to link it from Jira."}) + }); + let jira_state = match (&v.jira, &reads.sprint) { + (Some(_), _) => "linked", + (None, Sprint::NotConnected(_)) => "not_connected", + (None, _) => "not_linked", + }; + + json!({ + "viewer": {"name": v.name, "github": v.github}, + "header": {"needs": need_count, "working": working.len(), "waiting": waiting.len()}, + "needs": {"reviews": reviews_list, "suggested_reviews": suggested_rows, "returned": returned, "asks": asks}, + "sprint": sprint_out, + "working": working, + "waiting": waiting, + "later": later, + "stats": { + "waiting_on_you": {"count": need_count, "oldest": oldest}, + "waiting_on_others": {"count": waiting.len(), "longest": longest}, + "review_turnaround": turnaround.map(|(m, n)| json!({"median_secs": m, "reviews": n, "days": foryou::TURNAROUND_DAYS})), + }, + "suggestions": visible, + "suggestion_summary": summary, + "withdrawn": withdrawn.iter().map(|w| json!({ + "key": w.key, + "kind": w.key.split(':').next().unwrap_or(""), + "target": w.key.split_once(':').map(|(k, t)| if k == "review" { format!("pr:{t}") } else { format!("ticket:{t}") }), + "text": w.text, + "withdrawn_reason": w.withdrawn_reason, + })).collect::>(), + "accounts": { + "github": {"state": if v.github.is_some() { "linked" } else { "not_linked" }, "login": v.github}, + "jira": {"state": jira_state, "name": if v.jira.is_some() && !v.jira_name.is_empty() { json!(v.jira_name) } else { Value::Null }, "suggestion": suggestion}, + }, + "prefs": { + "layout": input.layout, + "muted_kinds": prefs.muted_kinds, + }, + "synced_at": iso(reads.read_at), + "sources": reads.sources, + }) +} + +// ── Handlers ──────────────────────────────────────────────────────────────── + +async fn jira_name(state: &AppState, team: &str, account: &str) -> String { + state + .dynamo + .get_item() + .table_name(&state.config.settings_table_name) + .key("pk", AttributeValue::S(team.into())) + .key( + "sk", + AttributeValue::S(common::requester::jira_user_sk(account)), + ) + .send() + .await + .ok() + .and_then(|o| o.item) + .map(|i| st(&i, "name").to_string()) + .unwrap_or_default() +} + +/// GET /api/foryou — the session user's own page. Takes no user: a person +/// can only ever read their own. +pub async fn get_for_you( + State(state): State>, + Extension(claims): Extension, +) -> Result, StatusCode> { + let user = user_of(&claims); + let jira = super::foryou_link::linked_jira(&state, &claims.team_id, &user).await; + let (reads, prs, name, jira_name, repos) = tokio::join!( + reads(&state, &claims, jira.as_deref()), + super::prs::read_all(&state, &claims.team_id), + super::run_close::profile_name(&state, &claims), + async { + match &jira { + Some(a) => jira_name(&state, &claims.team_id, a).await, + None => String::new(), + } + }, + super::brain::load_repos(&state, &claims.team_id), + ); + let t = now(); + let (rows, records, mut sources) = match prs { + Ok((data, _)) => { + let viewer = claims.github_login.as_deref(); + ( + common::pr_view::rows(&claims.team_id, &data.0, &data.1, viewer, t), + common::pr_view::records_of(&claims.team_id, &data.0), + vec![json!({"name": "Pull requests", "read": "ok", "detail": ""})], + ) + } + Err(_) => ( + Vec::new(), + Vec::new(), + vec![ + json!({"name": "Pull requests", "read": "failed", "detail": "the pull request records couldn't be read"}), + ], + ), + }; + if claims + .github_login + .as_deref() + .is_none_or(|l| l.trim().is_empty()) + { + sources[0] = json!({"name": "Pull requests", "read": "off", "detail": "your CoderHelm sign-in isn't linked to a GitHub account"}); + } + let viewer = Viewer { + user: claims.sub.clone(), + name: name.unwrap_or_default(), + email: claims.email.clone(), + github: claims.github_login.clone().filter(|g| !g.trim().is_empty()), + jira, + jira_name, + }; + let team_repos: Vec = repos.iter().map(|r| r.name.clone()).collect(); + for _ in 0..3 { + let (mut prefs, v) = read_prefs(&state, &claims.team_id, &user).await; + let before = prefs.clone(); + let layout = prefs.layout.normalized(); + let mut out = build( + &Input { + viewer: &viewer, + rows: &rows, + records: &records, + reads: &reads, + team_repos: &team_repos, + layout, + now: t, + }, + &mut prefs, + ); + if let Some(list) = out["sources"].as_array_mut() { + list.append(&mut sources); + } + if prefs == before { + return Ok(Json(out)); + } + prefs.tidy(t); + if write_prefs(&state, &claims.team_id, &user, &prefs, v).await? { + return Ok(Json(out)); + } + } + Err(StatusCode::CONFLICT) +} + +#[derive(Deserialize)] +pub struct PrefsBody { + pub layout: Option, + /// Kinds to show again. + #[serde(default)] + pub unmute: Vec, +} + +/// PUT /api/foryou/prefs — the person's own layout, landing page and muted +/// kinds. +pub async fn put_prefs( + State(state): State>, + Extension(claims): Extension, + Json(body): Json, +) -> Result, StatusCode> { + if let Some(l) = &body.layout { + l.validate().map_err(|_| StatusCode::BAD_REQUEST)?; + } + let (prefs, ()) = update_prefs(&state, &claims, |p| { + if let Some(l) = &body.layout { + p.layout = l.normalized(); + } + for k in &body.unmute { + p.muted_kinds.remove(k); + } + Ok(()) + }) + .await?; + Ok(Json( + json!({"layout": prefs.layout.normalized(), "muted_kinds": prefs.muted_kinds}), + )) +} + +#[derive(Deserialize)] +pub struct MarkBody { + pub key: String, + /// `snooze`, `done` or `undo`. + pub action: String, + /// For a snooze: until when (RFC 3339); tomorrow 9:00 when left out. + pub until: Option, + /// For done: the time the item waits since, as the page showed it. + pub since: Option, +} + +fn valid_key(k: &str) -> bool { + !k.is_empty() && k.len() <= 300 && !k.chars().any(char::is_control) +} + +/// POST /api/foryou/items — snooze, done, or undo one of your own items. +pub async fn mark_item( + State(state): State>, + Extension(claims): Extension, + Json(body): Json, +) -> Result, StatusCode> { + if !valid_key(&body.key) { + return Err(StatusCode::BAD_REQUEST); + } + let t = now(); + let (_, said) = update_prefs(&state, &claims, |p| match body.action.as_str() { + "snooze" => { + let until = body + .until + .as_deref() + .map(parse_time) + .filter(|u| *u > t) + .unwrap_or_else(|| foryou::tomorrow_nine(t)); + p.set_mark( + &body.key, + Mark { + snoozed_until: until, + at: t, + ..Default::default() + }, + ); + Ok(json!({"snoozed_until": iso(until)})) + } + "done" => { + p.set_mark( + &body.key, + Mark { + done_since: body.since.clone().unwrap_or_default(), + at: t, + ..Default::default() + }, + ); + Ok(json!({"done": true})) + } + "undo" => { + if p.undo(&body.key) { + Ok(json!({"undone": true})) + } else { + Ok(json!({"undone": false})) + } + } + _ => Err("unknown action".to_string()), + }) + .await?; + Ok(Json(said)) +} + +#[derive(Deserialize)] +pub struct SuggestionBody { + pub key: String, + /// `dismiss`, `reason`, `snooze`, `undo` or `accept` (reviews; a + /// ticket is given through `/api/foryou/give`). + pub action: String, + #[serde(default)] + pub reason: String, + /// `later_today`, `tomorrow` or `after_sprint`. + #[serde(default)] + pub when: String, +} + +/// When a snooze ends. +pub fn snooze_until(when: &str, now: i64, sprint_end: i64) -> Option { + match when { + "later_today" => Some(now + 4 * 3600), + "" | "tomorrow" => Some(foryou::tomorrow_nine(now)), + "after_sprint" if sprint_end > now => Some(sprint_end + 3600), + "after_sprint" => Some(now + 7 * 86_400), + _ => None, + } +} + +/// POST /api/foryou/suggestions — act on one of your suggestions. +pub async fn suggestion_act( + State(state): State>, + Extension(claims): Extension, + Json(body): Json, +) -> Result, (StatusCode, Json)> { + let bad = |c: StatusCode, m: &str| (c, Json(json!({"error": m}))); + if !valid_key(&body.key) { + return Err(bad(StatusCode::BAD_REQUEST, "No such suggestion.")); + } + let t = now(); + let user = user_of(&claims); + let jira = super::foryou_link::linked_jira(&state, &claims.team_id, &user).await; + let (prefs, _) = read_prefs(&state, &claims.team_id, &user).await; + let shown = prefs.shown.get(&body.key).cloned(); + let target = body.key.split_once(':').map(|(k, rest)| { + if k == "review" { + format!("pr:{rest}") + } else { + format!("ticket:{rest}") + } + }); + let r = reads(&state, &claims, jira.as_deref()).await; + let sprint_end = match &r.sprint { + Sprint::Ok(list) => list + .iter() + .map(sprint_ticket) + .filter_map(|t| (!t.sprint_end.is_empty()).then(|| parse_time(&t.sprint_end))) + .max() + .unwrap_or(0), + _ => 0, + }; + let kind_words = if body.key.starts_with("review:") { + "review suggestions".to_string() + } else { + // The fit kind of the ticket, as it was suggested. + match &r.sprint { + Sprint::Ok(list) => list + .iter() + .map(sprint_ticket) + .find(|t| format!("give:{}", t.key) == body.key) + .map(|t| { + foryou::kind_of(&TicketFacts { + title: t.title, + issue_type: t.issue_type, + labels: t.labels, + ..Default::default() + }) + }) + .unwrap_or_else(|| "tickets like this".into()), + _ => "tickets like this".into(), + } + }; + if body.action == "accept" { + let Some(rest) = body.key.strip_prefix("review:") else { + return Err(bad( + StatusCode::BAD_REQUEST, + "A ticket is given through Give to CoderHelm.", + )); + }; + return add_reviewer(&state, &claims, rest).await.map(Json); + } + let basis = shown.map(|s| s.basis).unwrap_or_default(); + let (_, said) = update_prefs(&state, &claims, |p| match body.action.as_str() { + "dismiss" => foryou::dismiss(p, &body.key, &basis, target.as_deref(), &kind_words, "", t).map(|e| json!({"effect": e})), + "reason" => foryou::dismiss(p, &body.key, &basis, target.as_deref(), &kind_words, &body.reason, t).map(|e| json!({"effect": e})), + "snooze" => { + let until = snooze_until(&body.when, t, sprint_end).ok_or("unknown snooze")?; + let mut m = p.marks.get(&body.key).cloned().unwrap_or_default(); + m.snoozed_until = until; + m.dismissed_basis.clear(); + m.at = t; + p.set_mark(&body.key, m); + Ok(json!({"snoozed_until": iso(until), "effect": "Snoozed. It comes back only if it still applies."})) + } + "undo" => { + let undone = p.undo(&body.key); + // A reason's lasting change goes too. + if let Some(tg) = &target { + p.not_me.remove(tg); + } + if body.reason == "dont_suggest_kind" { + p.muted_kinds.remove(&kind_words); + } + Ok(json!({"undone": undone})) + } + _ => Err("unknown action".to_string()), + }) + .await + .map_err(|c| bad(c, "That couldn't be saved."))?; + Ok(Json(said)) +} + +/// Adds the person as a reviewer of a pull request their review was +/// suggested on. +async fn add_reviewer( + state: &AppState, + claims: &Claims, + key: &str, +) -> Result)> { + let bad = |c: StatusCode, m: &str| (c, Json(json!({"error": m}))); + let Some(login) = claims.github_login.clone().filter(|l| !l.trim().is_empty()) else { + return Err(bad(StatusCode::CONFLICT, "Connect GitHub first.")); + }; + let Some((repo, number)) = key.rsplit_once('#') else { + return Err(bad(StatusCode::BAD_REQUEST, "No such pull request.")); + }; + super::reviewer::validate_repo(repo).map_err(|c| bad(c, "No such pull request."))?; + let number: u64 = number + .parse() + .map_err(|_| bad(StatusCode::BAD_REQUEST, "No such pull request."))?; + // Only a pull request of the team's, open now. + let (data, _) = super::prs::read_all(state, &claims.team_id) + .await + .map_err(|c| bad(c, "Pull requests couldn't be read."))?; + let recs = common::pr_view::records_of(&claims.team_id, &data.0); + if !recs + .iter() + .any(|r| r.repo.eq_ignore_ascii_case(repo) && r.number == number && r.is_open()) + { + return Err(bad( + StatusCode::NOT_FOUND, + "That pull request isn't open in your team's repositories.", + )); + } + let Some(token) = super::brain::github_token(state, &claims.team_id).await else { + return Err(bad( + StatusCode::SERVICE_UNAVAILABLE, + "CoderHelm can't reach GitHub for this team right now.", + )); + }; + let url = format!("https://api.github.com/repos/{repo}/pulls/{number}/requested_reviewers"); + let r = state + .http + .post(&url) + .bearer_auth(token) + .header("Accept", "application/vnd.github+json") + .header("User-Agent", "coderhelm") + .json(&json!({"reviewers": [login]})) + .send() + .await + .map_err(|_| bad(StatusCode::BAD_GATEWAY, "GitHub couldn't be reached."))?; + if !r.status().is_success() { + return Err(bad( + StatusCode::BAD_GATEWAY, + &format!( + "GitHub didn't add you as a reviewer ({}).", + r.status().as_u16() + ), + )); + } + Ok(json!({"added": true, "effect": "You are reviewing it."})) +} + +#[cfg(test)] +mod tests; diff --git a/services/gateway/src/routes/foryou/tests.rs b/services/gateway/src/routes/foryou/tests.rs new file mode 100644 index 000000000..13b31e0d0 --- /dev/null +++ b/services/gateway/src/routes/foryou/tests.rs @@ -0,0 +1,627 @@ +//! For you: the page, built from fake reads (invented data: acme, BOOK). + +use super::*; +use common::pr_record::{PrRecord, RequestEvent, ReviewEvent}; +use common::pr_view::{Author, NextOut, Row, SizeOut}; + +pub const NOW: i64 = 1_800_000_000; +const DAY: i64 = 86_400; + +pub fn row(repo: &str, number: u64, author: &str, state: &str, turn: &str, from: &[&str]) -> Row { + Row { + key: format!("{repo}#{number}"), + org: "acme".into(), + repo: repo.into(), + number, + title: format!("Change {number}"), + url: format!("https://github.com/{repo}/pull/{number}"), + author: Author { + login: author.into(), + coderhelm: author.ends_with("[bot]"), + }, + for_person: None, + draft: false, + base: "main".into(), + head: format!("branch-{number}"), + created_at: iso(NOW - DAY), + updated_at: iso(NOW - 3600), + state: state.into(), + state_label: state.replace('_', " "), + stage: Some("in_review".into()), + ready_at: iso(NOW - DAY), + turn: turn.into(), + next: NextOut { + code: state.into(), + text: format!("{state} sentence"), + from: from.iter().map(|s| s.to_string()).collect(), + since: iso(NOW - 2 * 3600), + rule: None, + }, + modifiers: vec![], + people: vec![], + checks: Default::default(), + reviews: Default::default(), + conflict: None, + open_threads: 0, + labels: vec![], + size: Some(SizeOut { + additions: 70, + deletions: 14, + }), + last_action: None, + coderhelm: None, + links: vec![], + waiting_since: iso(NOW - 2 * 3600), + rank: (0, 0, 0), + involves: vec![], + stale: false, + } +} + +pub fn reads() -> Reads { + Reads { + report: needs::Report::default(), + runs: Vec::new(), + sprint: Sprint::Ok(Vec::new()), + history: Vec::new(), + given: BTreeMap::new(), + seen_users: Vec::new(), + sources: Vec::new(), + site: "https://acme.atlassian.net".into(), + read_at: NOW, + } +} + +pub fn dana() -> Viewer { + Viewer { + user: "USER#dana".into(), + name: "Dana Ortiz".into(), + email: "dana@example.com".into(), + github: Some("dana-ortiz".into()), + jira: Some("557058:dana0001".into()), + jira_name: "Dana Ortiz".into(), + } +} + +pub fn page(v: &Viewer, rows: &[Row], records: &[PrRecord], r: &Reads, prefs: &mut Prefs) -> Value { + build( + &Input { + viewer: v, + rows, + records, + reads: r, + team_repos: &[ + "acme/web".to_string(), + "acme/api".to_string(), + "acme/billing".to_string(), + ], + layout: prefs.layout.normalized(), + now: NOW, + }, + prefs, + ) +} + +fn ticket( + key: &str, + title: &str, + desc: &str, + points: f64, + category: &str, + labels: &[&str], +) -> Value { + json!({ + "key": key, "summary": title, "status": if category == "new" { "To Do" } else { "In Progress" }, + "status_category": category, "type": "Story", "priority": "Medium", + "labels": labels, "components": [], "points": points, "description": desc, + "sprint": {"name": "Sprint 24", "end_date": iso(NOW + 3 * DAY)}, + }) +} + +const GOOD: &str = + "Acceptance criteria\n- [ ] The list says it is empty\nChange web/src/carts/SavedCartsList.tsx"; + +fn keys(v: &Value) -> Vec { + v.as_array() + .into_iter() + .flatten() + .filter_map(|i| i["key"].as_str().map(str::to_string)) + .collect() +} + +#[test] +fn needs_are_grouped_by_whose_turn_it_is_and_counted() { + let rows = vec![ + row( + "acme/web", + 482, + "theo", + "needs_review", + "you", + &["person:dana-ortiz"], + ), + row( + "acme/api", + 479, + "dana-ortiz", + "checks_failing", + "you", + &["person:dana-ortiz"], + ), + row( + "acme/api", + 477, + "dana-ortiz", + "needs_review", + "person", + &["person:mara"], + ), + row( + "acme/web", + 1, + "theo", + "needs_review", + "person", + &["person:mara"], + ), + ]; + let mut p = Prefs::default(); + let out = page(&dana(), &rows, &[], &reads(), &mut p); + assert_eq!(keys(&out["needs"]["reviews"]), vec!["pr:acme/web#482"]); + assert_eq!(out["needs"]["reviews"][0]["label"], "Review requested"); + assert_eq!(out["needs"]["reviews"][0]["who"], "theo"); + assert!(out["needs"]["reviews"][0]["action"]["href"] + .as_str() + .unwrap() + .starts_with("/inbox/pr?repo=acme%2Fweb&number=482")); + assert_eq!(keys(&out["needs"]["returned"]), vec!["pr:acme/api#479"]); + assert_eq!( + out["needs"]["returned"][0]["action"]["label"], + "Open checks" + ); + assert_eq!(keys(&out["waiting"]), vec!["pr:acme/api#477"]); + assert_eq!(out["waiting"][0]["next"]["who"], "mara"); + assert_eq!(out["header"]["needs"], 2); + assert_eq!(out["stats"]["waiting_on_you"]["count"], 2); + assert_eq!(out["stats"]["waiting_on_others"]["count"], 1); + assert!( + !out.to_string().contains("acme/web#1\""), + "someone else's pull request that isn't your turn stays off your page" + ); + // Only the three numbers: no streaks, counts of lines or rankings. + let stats = out["stats"].as_object().unwrap(); + assert_eq!( + stats.keys().cloned().collect::>(), + vec!["review_turnaround", "waiting_on_others", "waiting_on_you"] + ); +} + +#[test] +fn snoozed_items_go_to_later_and_done_ones_stay_gone_until_they_come_back() { + let rows = vec![ + row( + "acme/web", + 482, + "theo", + "needs_review", + "you", + &["person:dana-ortiz"], + ), + row( + "acme/billing", + 215, + "jun", + "needs_review", + "you", + &["person:dana-ortiz"], + ), + ]; + let mut p = Prefs::default(); + p.set_mark( + "pr:acme/web#482", + Mark { + snoozed_until: NOW + 3600, + at: NOW, + ..Default::default() + }, + ); + let since = iso(NOW - 2 * 3600).unwrap(); + p.set_mark( + "pr:acme/billing#215", + Mark { + done_since: since, + at: NOW, + ..Default::default() + }, + ); + let out = page(&dana(), &rows, &[], &reads(), &mut p); + assert!(keys(&out["needs"]["reviews"]).is_empty()); + assert_eq!(keys(&out["later"]), vec!["pr:acme/web#482"]); + assert_eq!(out["later"][0]["later"], "snoozed"); + // A new wait on the done one brings it back. + let mut moved = rows.clone(); + moved[1].waiting_since = iso(NOW - 60); + let out = page(&dana(), &moved, &[], &reads(), &mut p); + assert_eq!(keys(&out["needs"]["reviews"]), vec!["pr:acme/billing#215"]); +} + +#[test] +fn coderhelm_asks_come_from_gather_with_their_question() { + let mut r = reads(); + r.report.needs = vec![ + needs::Need { + urgency: needs::Urgency::Now, + rank: 60, + kind: "run", + what: "BOOK-101 Store stock counts as whole numbers".into(), + action: "Answer the run's question".into(), + link: "/runs/detail?id=01RUN".into(), + since: iso(NOW - 1500).unwrap(), + detail: "Should counts stored as 2.5 round down to 2 or up to 3?".into(), + loc: "acme/api".into(), + }, + needs::Need { + urgency: needs::Urgency::Now, + rank: 60, + kind: "run", + what: "BOOK-112 Add an empty state".into(), + action: "Answer the run's question".into(), + link: "/runs/detail?id=02RUN".into(), + since: iso(NOW - 600).unwrap(), + detail: format!("{}\n - {}", foryou::PLAN_QUESTION, foryou::PLAN_APPROVE), + loc: "acme/web".into(), + }, + ]; + let mut p = Prefs::default(); + let out = page(&dana(), &[], &[], &r, &mut p); + let asks = &out["needs"]["asks"]; + assert_eq!(asks[0]["label"], "Question"); + assert_eq!(asks[0]["where"], "BOOK-101 \u{b7} acme/api"); + assert_eq!(asks[0]["title"], "Store stock counts as whole numbers"); + assert_eq!( + asks[0]["why"], + "CoderHelm asks: Should counts stored as 2.5 round down to 2 or up to 3?" + ); + assert_eq!(asks[0]["action"]["href"], "/inbox/answer?run=01RUN"); + assert_eq!(asks[1]["label"], "Plan to approve"); + assert_eq!(asks[1]["action"]["label"], "Review plan"); +} + +#[test] +fn the_sprint_carries_fit_bands_and_a_good_fit_gets_one_inline_suggestion() { + let mut r = reads(); + r.sprint = Sprint::Ok(vec![ + ticket( + "BOOK-112", + "Add an empty state to the saved carts list", + GOOD, + 2.0, + "new", + &["coderhelm:acme/web"], + ), + ticket( + "BOOK-118", + "Fix the broken help link in the refund email", + GOOD, + 1.0, + "new", + &["coderhelm:acme/web"], + ), + ticket( + "BOOK-115", + "Retry failed webhook deliveries with backoff", + "Retry them in acme/api and acme/billing.", + 3.0, + "new", + &[], + ), + ticket( + "BOOK-121", + "Rotate the payment provider signing keys", + GOOD, + 5.0, + "new", + &["coderhelm:acme/billing"], + ), + ticket( + "BOOK-109", + "Split invoice PDFs by billing period", + "", + 5.0, + "indeterminate", + &[], + ), + ]); + let mut p = Prefs::default(); + let out = page(&dana(), &[], &[], &r, &mut p); + let t = &out["sprint"]["tickets"]; + assert_eq!(out["sprint"]["state"], "ok"); + assert_eq!(out["sprint"]["meta"]["name"], "Sprint 24"); + assert_eq!(out["sprint"]["meta"]["points"], 16.0); + assert_eq!(out["sprint"]["meta"]["days_left"], 3); + assert_eq!(t[0]["fit"]["band"], "good"); + assert_eq!(t[2]["fit"]["band"], "maybe"); + assert_eq!(t[2]["repos"], json!(["acme/api", "acme/billing"])); + assert_eq!(t[3]["fit"]["band"], "not"); + assert_eq!(t[3]["fit"]["excluded"], "security"); + assert!(t[4]["fit"].is_null(), "only tickets not started get a band"); + assert_eq!(t[0]["url"], "https://acme.atlassian.net/browse/BOOK-112"); + // One suggestion per good-fit row, with the reason on the line. + let s = &out["suggestions"]; + assert_eq!(keys(s), vec!["give:BOOK-112", "give:BOOK-118"]); + assert_eq!(s[0]["target"], "ticket:BOOK-112"); + assert_eq!( + s[0]["reason"], + "Acceptance criteria and the files are named; 2 points" + ); + for f in [ + "reason", + "evidence", + "effect", + "effort", + "deadline", + "as_of", + "dismiss_reasons", + ] { + assert!(!s[0][f].is_null(), "{f}"); + } + assert!(s[0]["deadline"] + .as_str() + .unwrap() + .starts_with("Sprint ends ")); + assert_eq!( + s[0]["dismiss_reasons"][3]["label"], + "Don't suggest UI changes" + ); + // The summary under the heading, with a batch behind a preview. + assert_eq!(out["suggestion_summary"]["count"], 2); + assert_eq!( + out["suggestion_summary"]["kinds"][0]["text"], + "2 tickets CoderHelm can take" + ); + assert_eq!( + out["suggestion_summary"]["batch"]["keys"], + json!(["BOOK-112", "BOOK-118"]) + ); + assert_eq!( + out["suggestion_summary"]["batch"]["text"], + "Give both to CoderHelm" + ); + // No percentages or scores anywhere in a fit or suggestion. + let text = format!("{}{}", t, s); + assert!(!text.contains('%') && !text.contains("confidence") && !text.contains("score")); +} + +#[test] +fn a_suggestion_is_withdrawn_when_its_ticket_goes_to_coderhelm() { + let mut r = reads(); + r.sprint = Sprint::Ok(vec![ticket( + "BOOK-118", + "Fix the broken help link in the refund email", + GOOD, + 1.0, + "new", + &["coderhelm:acme/web"], + )]); + let mut p = Prefs::default(); + page(&dana(), &[], &[], &r, &mut p); + assert!(p.shown.contains_key("give:BOOK-118")); + r.given.insert( + "BOOK-118".into(), + foryou::Given { + ticket: "BOOK-118".into(), + owner: "USER#dana".into(), + given_at: NOW - 10, + ..Default::default() + }, + ); + let out = page(&dana(), &[], &[], &r, &mut p); + assert!(keys(&out["suggestions"]).is_empty()); + assert_eq!( + out["withdrawn"][0]["withdrawn_reason"], + "BOOK-118 is already with CoderHelm" + ); + assert_eq!( + out["sprint"]["tickets"][0]["delegated"]["stage"], + "starting" + ); + assert!(out["sprint"]["tickets"][0]["fit"].is_null()); +} + +fn rec(repo: &str, number: u64, author: &str, files: &[&str]) -> PrRecord { + PrRecord { + repo: repo.into(), + number, + author: author.into(), + files: files.iter().map(|f| f.to_string()).collect(), + ..Default::default() + } +} + +fn merged_by(login: &str, n: u64, files: &[&str]) -> History { + History { + repo: "acme/billing".into(), + number: n, + author: login.into(), + merged: true, + merged_at: NOW - 5 * DAY, + closed_at: NOW - 5 * DAY, + files: files.iter().map(|f| f.to_string()).collect(), + ..Default::default() + } +} + +#[test] +fn a_review_nobody_was_asked_for_is_suggested_on_its_own_row_and_withdrawn_when_taken() { + let mut r = reads(); + r.history = vec![ + merged_by("dana-ortiz", 200, &["invoice/tax.ts"]), + merged_by("dana-ortiz", 201, &["invoice/tax.ts", "invoice/pdf.ts"]), + merged_by("dana-ortiz", 202, &["README.md"]), + merged_by("mara", 203, &["invoice/tax.ts"]), + ]; + let mut open = row( + "acme/billing", + 218, + "jun", + "needs_reviewer", + "person", + &["nobody"], + ); + open.stage = Some("first_review".into()); + let records = vec![rec("acme/billing", 218, "jun", &["invoice/tax.ts"])]; + let mut p = Prefs::default(); + let out = page(&dana(), &[open.clone()], &records, &r, &mut p); + let s = &out["suggestions"][0]; + assert_eq!(s["key"], "review:acme/billing#218"); + assert_eq!(s["action"], "Add to my reviews"); + assert_eq!( + s["reason"], + "You changed invoice/tax.ts in 2 of your 3 merged pull requests here; no reviewer yet" + ); + assert_eq!(s["effort"], "84 lines, about 8 min"); + assert_eq!( + s["effect"], + "Adds you as a reviewer on GitHub. No comment is posted." + ); + let row_out = &out["needs"]["suggested_reviews"][0]; + assert_eq!(row_out["label"], "Not requested of you"); + assert_eq!(row_out["why"], "Opened by @jun \u{b7} no reviewer yet"); + assert_eq!( + out["header"]["needs"], 0, + "a suggested review isn't counted as waiting on you" + ); + // Mara takes the review: withdrawn, saying who. + open.reviews.requested = vec!["mara".into()]; + let out = page(&dana(), &[open], &records, &r, &mut p); + assert!(keys(&out["suggestions"]).is_empty()); + assert!(keys(&out["needs"]["suggested_reviews"]).is_empty()); + assert_eq!( + out["withdrawn"][0]["withdrawn_reason"], + "Someone else picked it up: @mara took the review of acme/billing#218" + ); + assert_eq!(out["withdrawn"][0]["target"], "pr:acme/billing#218"); +} + +#[test] +fn review_turnaround_is_only_yours() { + let mut r = reads(); + let mut h = merged_by("jun", 300, &[]); + h.request_log = vec![ + RequestEvent { + who: "dana-ortiz".into(), + at: NOW - 3 * DAY, + removed_at: 0, + }, + RequestEvent { + who: "mara".into(), + at: NOW - 3 * DAY, + removed_at: 0, + }, + ]; + h.review_log = vec![ + ReviewEvent { + who: "dana-ortiz".into(), + state: "APPROVED".into(), + sha: String::new(), + at: NOW - 3 * DAY + 15_000, + human: true, + has_body: false, + }, + ReviewEvent { + who: "mara".into(), + state: "APPROVED".into(), + sha: String::new(), + at: NOW - 3 * DAY + 60, + human: true, + has_body: false, + }, + ]; + r.history = vec![h]; + let mut p = Prefs::default(); + let out = page(&dana(), &[], &[], &r, &mut p); + assert_eq!(out["stats"]["review_turnaround"]["median_secs"], 15_000); + assert_eq!(out["stats"]["review_turnaround"]["reviews"], 1); + assert_eq!(out["stats"]["review_turnaround"]["days"], 28); + let mut mara = dana(); + mara.github = Some("mara".into()); + let out = page(&mara, &[], &[], &r, &mut Prefs::default()); + assert_eq!(out["stats"]["review_turnaround"]["median_secs"], 60); +} + +#[test] +fn an_unlinked_person_gets_a_suggestion_never_a_link() { + let mut r = reads(); + r.sprint = Sprint::NotLinked; + r.seen_users = vec![foryou::SeenJiraUser { + account_id: "557058:dana0001".into(), + name: "Dana Ortiz".into(), + email: "dana@example.com".into(), + linked: false, + }]; + let mut v = dana(); + v.jira = None; + let mut p = Prefs::default(); + let out = page(&v, &[], &[], &r, &mut p); + assert_eq!(out["accounts"]["jira"]["state"], "not_linked"); + assert_eq!(out["accounts"]["jira"]["suggestion"]["name"], "Dana Ortiz"); + assert_eq!(out["sprint"]["state"], "not_linked"); + assert!(out["sprint"]["tickets"].as_array().unwrap().is_empty()); + // "No" makes it go. + p.identity_no.insert("557058:dana0001".into()); + let out = page(&v, &[], &[], &r, &mut p); + assert!(out["accounts"]["jira"]["suggestion"].is_null()); +} + +#[test] +fn snoozes_end_later_today_tomorrow_or_after_the_sprint() { + assert_eq!(snooze_until("later_today", NOW, 0), Some(NOW + 4 * 3600)); + assert_eq!( + snooze_until("tomorrow", NOW, 0), + Some(foryou::tomorrow_nine(NOW)) + ); + assert_eq!( + snooze_until("after_sprint", NOW, NOW + 2 * DAY), + Some(NOW + 2 * DAY + 3600) + ); + assert_eq!(snooze_until("after_sprint", NOW, 0), Some(NOW + 7 * DAY)); + assert_eq!(snooze_until("someday", NOW, 0), None); +} + +#[test] +fn repositories_are_known_from_a_label_the_ticket_or_past_runs() { + let t = |labels: &[&str], desc: &str| SprintTicket { + key: "BOOK-7".into(), + labels: labels.iter().map(|s| s.to_string()).collect(), + description: desc.into(), + ..Default::default() + }; + let repos = vec!["acme/web".to_string(), "acme/api".to_string()]; + assert_eq!( + repo_hints(&t(&["coderhelm:acme/web"], ""), &repos, &[]), + (vec!["acme/web".into()], "label") + ); + assert_eq!( + repo_hints(&t(&[], "In acme/api, retry"), &repos, &[]), + (vec!["acme/api".into()], "ticket") + ); + let run = |tk: &str, repo: &str| -> Item { + HashMap::from([ + ("ticket_id".to_string(), AttributeValue::S(tk.into())), + ("repo".to_string(), AttributeValue::S(repo.into())), + ]) + }; + let runs = vec![ + run("BOOK-1", "acme/web"), + run("BOOK-2", "acme/web"), + run("OTHER-1", "acme/api"), + ]; + assert_eq!( + repo_hints(&t(&[], ""), &repos, &runs), + (vec!["acme/web".into()], "history") + ); + assert_eq!( + repo_hints(&t(&[], ""), &repos, &runs[..1]), + (Vec::new(), "") + ); +} diff --git a/services/gateway/src/routes/foryou_give.rs b/services/gateway/src/routes/foryou_give.rs new file mode 100644 index 000000000..d2550d9d3 --- /dev/null +++ b/services/gateway/src/routes/foryou_give.rs @@ -0,0 +1,347 @@ +//! Give to CoderHelm, from the For you page. +//! +//! - `GET /api/foryou/give?key=BOOK-112` ([`preview`]): what CoderHelm knows +//! before it starts: the fit, the repositories, the files the ticket names, +//! the tests, and that the plan comes first. The planner has no dry-run +//! mode, so the preview says what is known and that the plan is written +//! at the start of the run (and, with "Draft a plan first", waits for the +//! person's OK before any code). +//! - `POST /api/foryou/give` ([`give`]): records the person as the owner +//! (`FORYOU#GIVE#`), then asks the team's Jira app to add the +//! team's trigger label to the ticket. Jira sends that change like any +//! person's label, and the run starts through the label path +//! (`jira_webhook::ticket_triggers`), crediting the owner +//! ([`owner_for_event`]). CoderHelm is the delegate; the ticket stays +//! assigned to the person. Answered at once; the page then shows the run +//! from the runs table as it starts. + +use std::sync::Arc; + +use axum::{ + extract::{Query, State}, + http::StatusCode, + Extension, Json, +}; +use common::foryou::{self, Given}; +use serde::Deserialize; +use serde_json::{json, Value}; +use tracing::{info, warn}; + +use super::foryou::{reads, repo_hints, sprint_ticket, Sprint}; +use super::foryou_link::user_of; +use crate::models::Claims; +use crate::AppState; + +type Refusal = (StatusCode, Json); + +fn refuse(code: StatusCode, msg: &str) -> Refusal { + (code, Json(json!({ "error": msg }))) +} + +#[derive(Deserialize)] +pub struct KeyQuery { + pub key: String, +} + +/// The ticket, from the person's own sprint: only a ticket assigned to them. +async fn own_ticket( + state: &Arc, + claims: &Claims, + key: &str, +) -> Result< + ( + super::foryou::SprintTicket, + String, + Arc, + ), + Refusal, +> { + if !super::chat_work_tickets::valid_key(key) { + return Err(refuse(StatusCode::BAD_REQUEST, "That isn't a Jira key.")); + } + let user = user_of(claims); + let Some(account) = super::foryou_link::linked_jira(state, &claims.team_id, &user).await else { + return Err(refuse( + StatusCode::CONFLICT, + "Link your Jira account first (Connect Jira on the For you page).", + )); + }; + let r = reads(state, claims, Some(&account)).await; + let Sprint::Ok(list) = &r.sprint else { + return Err(refuse( + StatusCode::CONFLICT, + "Your sprint couldn't be read from Jira, so nothing was started.", + )); + }; + let Some(raw) = list.iter().find(|v| v["key"].as_str() == Some(key)) else { + return Err(refuse( + StatusCode::FORBIDDEN, + "Only a ticket in your open sprint, assigned to you, can be given from here.", + )); + }; + Ok((sprint_ticket(raw), account, r)) +} + +/// GET /api/foryou/give?key= — what is known before anything starts. +pub async fn preview( + State(state): State>, + Extension(claims): Extension, + Query(q): Query, +) -> Result, Refusal> { + let (t, _, r) = own_ticket(&state, &claims, q.key.trim()).await?; + let repos = super::brain::load_repos(&state, &claims.team_id).await; + let names: Vec = repos.iter().map(|x| x.name.clone()).collect(); + let (hint, source) = repo_hints(&t, &names, &r.runs); + let facts = foryou::TicketFacts { + key: t.key.clone(), + title: t.title.clone(), + description: t.description.clone(), + issue_type: t.issue_type.clone(), + labels: t.labels.clone(), + components: t.components.clone(), + priority: t.priority.clone(), + points: t.points, + repos: hint.clone(), + repo_source: source.into(), + tests: None, + }; + let fit = foryou::fit(&facts); + let criteria: Vec = t + .description + .lines() + .map(str::trim) + .filter(|l| l.starts_with("- [ ]") || l.starts_with("[ ]") || l.starts_with("AC:")) + .map(|l| { + l.trim_start_matches("- [ ]") + .trim_start_matches("[ ]") + .trim_start_matches("AC:") + .trim() + .to_string() + }) + .filter(|l| !l.is_empty()) + .take(8) + .collect(); + Ok(Json(json!({ + "key": t.key, + "title": t.title, + "points": t.points, + "fit": fit, + "repos": hint, + "repo_source": source, + "files": foryou::named_files(&t.description), + "criteria": criteria, + // No dry-run planner exists: say what is known, and that the plan + // comes first. + "plan": { + "available": false, + "text": "CoderHelm writes its plan first, from the ticket and the code, before any change. With \"Pause after the plan\" it waits for your OK on the run page before it codes.", + }, + "plan_first_default": fit.band != foryou::Band::Good, + "owner": "you", + "delegate": "CoderHelm", + "effect": "The ticket stays assigned to you in Jira. CoderHelm opens one pull request on its own branch, and someone other than you approves it. You can stop it at any time.", + }))) +} + +#[derive(Deserialize)] +pub struct GiveBody { + pub key: String, + #[serde(default)] + pub plan_first: bool, +} + +/// POST /api/foryou/give — start CoderHelm on one of your sprint tickets. +pub async fn give( + State(state): State>, + Extension(claims): Extension, + Json(body): Json, +) -> Result<(StatusCode, Json), Refusal> { + let allowed = claims.require_role(1); + allowed.map_err(|_| refuse(StatusCode::FORBIDDEN, "Your role can't start runs."))?; + let key = body.key.trim().to_string(); + let (_, account, r) = own_ticket(&state, &claims, &key).await?; + // A run already working on it: nothing doubles. + let busy = r.runs.iter().any(|i| { + i.get("ticket_id") + .and_then(|v| v.as_s().ok()) + .map(String::as_str) + == Some(key.as_str()) + && i.get("status") + .and_then(|v| v.as_s().ok()) + .is_some_and(|s| { + common::pr_view::RUN_ACTIVE.contains(&s.as_str()) + || s == common::run_status::NEEDS_INPUT + }) + }); + if busy { + return Err(refuse( + StatusCode::CONFLICT, + &format!("CoderHelm is already working on {key}."), + )); + } + let jira = super::chat_work_tickets::load(&state, &claims.team_id).await; + let Some(app) = jira.app.as_ref() else { + return Err(refuse(StatusCode::CONFLICT, jira.off_words())); + }; + let label = super::jira_webhook::trigger_label_of(&state, &claims.team_id).await; + let t_now = chrono::Utc::now().timestamp(); + let owner_name = super::run_close::profile_name(&state, &claims) + .await + .unwrap_or_default(); + let given = Given { + ticket: key.clone(), + owner: claims.sub.clone(), + owner_name, + owner_jira: account.clone(), + plan_first: body.plan_first, + given_at: t_now, + approved_at: 0, + started_at: 0, + }; + foryou::put_given( + &state.dynamo, + &state.config.settings_table_name, + &claims.team_id, + &given, + ) + .await + .map_err(|e| { + warn!(error = %e, "For you: give not recorded"); + refuse( + StatusCode::INTERNAL_SERVER_ERROR, + "That couldn't be saved. Try again.", + ) + })?; + let http = common::mcp_remote::http::GuardedHttps; + match ask_give(&http, app, &key, &label, &account).await { + GiveAnswer::Given => {} + GiveAnswer::Old => { + return Err(refuse( + StatusCode::CONFLICT, + &format!( + "Your Jira site runs an older CoderHelm app that can't start work from here. Add the label {label} to {key} in Jira (you stay the owner), or ask your Jira admin to update the app." + ), + )) + } + GiveAnswer::Refused(why) => { + return Err(refuse(StatusCode::CONFLICT, &format!("Jira didn't take it: {why}."))) + } + } + super::foryou::forget(&state, &claims).await; + info!(team_id = %claims.team_id, plan_first = body.plan_first, "For you: a ticket was given to CoderHelm"); + Ok(( + StatusCode::ACCEPTED, + Json(json!({ + "state": "starting", + "ticket": key, + "plan_first": body.plan_first, + "owner": "you", + "delegate": "CoderHelm", + "message": format!("CoderHelm picked up {key}. You stay the owner."), + })), + )) +} + +/// What the Jira app said to a give. +#[derive(Debug, PartialEq)] +pub enum GiveAnswer { + Given, + /// The site's app predates the give mode. + Old, + Refused(String), +} + +pub async fn ask_give( + http: &dyn common::mcp_remote::http::Http, + app: &super::chat_work_tickets::JiraApp, + key: &str, + label: &str, + account: &str, +) -> GiveAnswer { + use common::mcp_remote::http::{HttpRequest, Limit}; + let body = json!({"forge_secret": app.secret, "give": {"key": key, "label": label, "account_id": account}}); + let r = match http + .send(HttpRequest::json(&app.issues_url, &body, Limit::Metadata)) + .await + { + Ok(r) => r, + Err(e) => return GiveAnswer::Refused(format!("Jira couldn't be reached ({e})")), + }; + if r.status != 200 { + return GiveAnswer::Refused(format!("Jira's app answered {}", r.status)); + } + let v = r.json().unwrap_or(Value::Null); + if !v["given"].is_object() { + return GiveAnswer::Old; + } + if v["given"]["ok"] == true { + GiveAnswer::Given + } else { + GiveAnswer::Refused( + v["given"]["why"] + .as_str() + .unwrap_or("it gave no reason") + .to_string(), + ) + } +} + +/// The owner to credit for a Jira event on `ticket`: the person who gave it +/// from For you in the last minutes, once. `None` for any other event. +pub async fn owner_for_event( + state: &AppState, + team: &str, + ticket: &str, +) -> Option { + let table = &state.config.settings_table_name; + let mut g = foryou::read_given(&state.dynamo, table, team, ticket).await?; + let now = chrono::Utc::now().timestamp(); + if !foryou::awaits_event(&g, now) { + return None; + } + g.started_at = now; + if let Err(e) = foryou::put_given(&state.dynamo, table, team, &g).await { + warn!(error = %e, "For you: give not marked started"); + } + common::requester::Requester::jira_user(&json!({ + "accountId": g.owner_jira, + "displayName": g.owner_name, + })) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::routes::chat_work_needs::tests::app; + use crate::routes::chat_work_prs::tests::fake; + + #[tokio::test] + async fn the_jira_app_adds_the_label_or_says_why_not() { + let ok = fake(|r| { + let body: Value = serde_json::from_slice(r.body.as_deref().unwrap_or(b"{}")).unwrap(); + assert_eq!(body["give"]["key"], "BOOK-112"); + assert_eq!(body["give"]["label"], "coderhelm"); + assert_eq!(body["give"]["account_id"], "557058:a1b2c3d4"); + (200, json!({"given": {"ok": true, "key": "BOOK-112"}})) + }); + assert_eq!( + ask_give(&ok, &app(), "BOOK-112", "coderhelm", "557058:a1b2c3d4").await, + GiveAnswer::Given + ); + let old = fake(|_| (200, json!({"issues": []}))); + assert_eq!( + ask_give(&old, &app(), "BOOK-112", "coderhelm", "557058:a1b2c3d4").await, + GiveAnswer::Old + ); + let no = fake(|_| { + ( + 200, + json!({"given": {"ok": false, "why": "BOOK-112 isn't assigned to you"}}), + ) + }); + assert_eq!( + ask_give(&no, &app(), "BOOK-112", "coderhelm", "557058:a1b2c3d4").await, + GiveAnswer::Refused("BOOK-112 isn't assigned to you".into()) + ); + } +} diff --git a/services/gateway/src/routes/foryou_link.rs b/services/gateway/src/routes/foryou_link.rs new file mode 100644 index 000000000..6cdc4bc0d --- /dev/null +++ b/services/gateway/src/routes/foryou_link.rs @@ -0,0 +1,449 @@ +//! Linking a person's Jira account to their CoderHelm user, by them only. +//! +//! - `POST /api/foryou/link/jira` ([`make_code`]): the signed-in person gets +//! a one-time code, signed for their team (`common::foryou::issue_code`), +//! good for fifteen minutes. +//! - `POST /webhooks/jira-link` ([`forge_link`]): the Jira app's "Link my +//! CoderHelm account" action sends the code with the account id Forge +//! gives for the person who opened it, proven by the site's Forge secret. +//! The code is used up in the same write that reads it. +//! - `DELETE /api/foryou/link/jira` ([`unlink`]): the person removes the +//! link; both rows go. +//! - `POST /api/foryou/link/jira/not-me` ([`not_me`]): "No" to the "Is this +//! you?" suggestion. +//! +//! The link is kept twice under the team's partition: `FORYOU#JIRA#` +//! holds the account id, and the account's own `JIRAUSER#` row +//! holds `linked_user`. An account is linked to one person at a time. An +//! email never makes a link: it can only make the suggestion. + +use std::sync::Arc; + +use aws_sdk_dynamodb::types::AttributeValue; +use axum::body::Bytes; +use axum::{extract::State, http::StatusCode, Extension, Json}; +use common::foryou; +use serde_json::{json, Value}; +use tracing::{info, warn}; + +use crate::models::Claims; +use crate::AppState; + +fn s(v: &str) -> AttributeValue { + AttributeValue::S(v.to_string()) +} + +fn get_s(item: &std::collections::HashMap, k: &str) -> String { + item.get(k) + .and_then(|v| v.as_s().ok()) + .cloned() + .unwrap_or_default() +} + +/// The user part of the session's id (`USER#abc` is `abc`). +pub fn user_of(claims: &Claims) -> String { + claims + .sub + .strip_prefix("USER#") + .unwrap_or(&claims.sub) + .to_string() +} + +fn now() -> i64 { + chrono::Utc::now().timestamp() +} + +/// The Jira account this user linked themselves, if any. +pub async fn linked_jira(state: &AppState, team: &str, user: &str) -> Option { + let user = user.strip_prefix("USER#").unwrap_or(user); + let item = state + .dynamo + .get_item() + .table_name(&state.config.settings_table_name) + .key("pk", s(team)) + .key("sk", s(&foryou::jira_link_sk(user))) + .consistent_read(true) + .send() + .await + .ok()? + .item?; + Some(get_s(&item, "account_id")).filter(|a| foryou::valid_account_id(a)) +} + +/// POST /api/foryou/link/jira — a one-time code for the Jira app's "Link my +/// CoderHelm account" action. +pub async fn make_code( + State(state): State>, + Extension(claims): Extension, +) -> Result, StatusCode> { + let user = user_of(&claims); + let random: [u8; 5] = rand::random(); + let (code, sk) = + foryou::issue_code(state.secrets.jwt_secret.as_bytes(), &claims.team_id, random); + let expires = now() + foryou::CODE_TTL_SECS; + state + .dynamo + .put_item() + .table_name(&state.config.settings_table_name) + .item("pk", s(&claims.team_id)) + .item("sk", s(&sk)) + .item("user", s(&user)) + .item("expires_at", AttributeValue::N(expires.to_string())) + // The table's TTL removes it a while after; the expiry above is + // what counts. + .item("ttl", AttributeValue::N((expires + 3600).to_string())) + .send() + .await + .map_err(|e| { + warn!(error = %e, "For you: link code not stored"); + StatusCode::INTERNAL_SERVER_ERROR + })?; + Ok(Json(json!({ + "code": code, + "expires_at": common::pr_view::rfc3339(expires), + "steps": [ + "Open any issue in Jira.", + "Open the issue's \u{2022}\u{2022}\u{2022} menu and choose Link my CoderHelm account.", + "Paste this code and choose Link my account.", + ], + }))) +} + +/// DELETE /api/foryou/link/jira — the person removes their Jira link. +pub async fn unlink( + State(state): State>, + Extension(claims): Extension, +) -> Result, StatusCode> { + let user = user_of(&claims); + let account = linked_jira(&state, &claims.team_id, &user).await; + let table = &state.config.settings_table_name; + state + .dynamo + .delete_item() + .table_name(table) + .key("pk", s(&claims.team_id)) + .key("sk", s(&foryou::jira_link_sk(&user))) + .send() + .await + .map_err(|e| { + warn!(error = %e, "For you: unlink failed"); + StatusCode::INTERNAL_SERVER_ERROR + })?; + if let Some(a) = &account { + release_account(&state, &claims.team_id, a, &user).await; + } + info!(team_id = %claims.team_id, "For you: a person unlinked their Jira account"); + Ok(Json(json!({ "unlinked": account.is_some() }))) +} + +/// Takes `linked_user` off an account's row, only when it is this user's. +async fn release_account(state: &AppState, team: &str, account: &str, user: &str) { + let r = state + .dynamo + .update_item() + .table_name(&state.config.settings_table_name) + .key("pk", s(team)) + .key("sk", s(&common::requester::jira_user_sk(account))) + .update_expression("REMOVE #l, linked_at") + .condition_expression("#l = :u") + .expression_attribute_names("#l", foryou::FIELD_LINKED_USER) + .expression_attribute_values(":u", s(user)) + .send() + .await; + if let Err(e) = r { + if !e + .as_service_error() + .is_some_and(|x| x.is_conditional_check_failed_exception()) + { + warn!(error = %e, "For you: account row not released"); + } + } +} + +/// POST /api/foryou/link/jira/not-me — "No" to "Is this you?". +pub async fn not_me( + State(state): State>, + Extension(claims): Extension, + Json(body): Json, +) -> Result, StatusCode> { + let account = body["account_id"].as_str().unwrap_or("").trim().to_string(); + if !foryou::valid_account_id(&account) { + return Err(StatusCode::BAD_REQUEST); + } + super::foryou::update_prefs(&state, &claims, |p| { + p.identity_no.insert(account.clone()); + Ok(()) + }) + .await?; + Ok(Json(json!({ "ok": true }))) +} + +/// What the Jira app sent, checked: the team, its proof, the account and +/// the code. +fn read_link(body: &Value) -> Result<(String, String, String, String), StatusCode> { + let team = body + .pointer("/coderhelm/team_id") + .and_then(|v| v.as_str()) + .unwrap_or("") + .trim(); + let secret = body + .pointer("/coderhelm/forge_secret") + .and_then(|v| v.as_str()) + .unwrap_or(""); + let account = body["account_id"].as_str().unwrap_or("").trim(); + let code = body["code"].as_str().unwrap_or("").trim(); + if team.is_empty() || secret.is_empty() { + return Err(StatusCode::UNAUTHORIZED); + } + if !foryou::valid_account_id(account) || code.is_empty() || code.len() > 40 { + return Err(StatusCode::BAD_REQUEST); + } + let team = if team.starts_with("TEAM#") { + team.to_string() + } else { + format!("TEAM#{team}") + }; + Ok(( + team, + secret.to_string(), + account.to_string(), + code.to_string(), + )) +} + +fn answer(code: StatusCode, message: &str) -> (StatusCode, Json) { + (code, Json(json!({ "message": message }))) +} + +/// POST /webhooks/jira-link — the Jira app's "Link my CoderHelm account". +/// +/// The team is proven by its own Forge secret (as every Forge event is); +/// the person by the account id Forge gives for whoever opened the action; +/// the dashboard user by the one-time code they made, signed for this team +/// and used up here. +pub async fn forge_link( + State(state): State>, + body: Bytes, +) -> (StatusCode, Json) { + let Ok(payload) = serde_json::from_slice::(&body) else { + return answer(StatusCode::BAD_REQUEST, "That request couldn't be read."); + }; + let (team, secret, account, code) = match read_link(&payload) { + Ok(x) => x, + Err(c) => return answer(c, "That request is missing what CoderHelm needs."), + }; + if common::hybrid::sign::is_install_id(team.trim_start_matches("TEAM#")) { + return answer( + StatusCode::CONFLICT, + "This Jira site sends its work to a self-hosted CoderHelm: link your account there.", + ); + } + let config = state + .dynamo + .get_item() + .table_name(&state.config.jira_config_table_name) + .key("pk", s(&team)) + .key("sk", s("JIRA#config")) + .send() + .await + .ok() + .and_then(|r| r.item); + let stored = config + .as_ref() + .map(|c| get_s(c, "forge_secret")) + .unwrap_or_default(); + if !super::jira_webhook::forge_secret_matches(&stored, &secret) { + warn!(team_id = %team, "Jira link: invalid or missing forge_secret"); + return answer(StatusCode::FORBIDDEN, ""); + } + // The signature first: a guessed code, or another team's, costs no read. + if !foryou::verify_code(state.secrets.jwt_secret.as_bytes(), &team, &code) { + return answer( + StatusCode::BAD_REQUEST, + "That isn't a CoderHelm code for this team. Copy it again from the For you page.", + ); + } + // Used up in the read: a second use finds nothing. + let taken = state + .dynamo + .delete_item() + .table_name(&state.config.settings_table_name) + .key("pk", s(&team)) + .key("sk", s(&foryou::code_sk(&team, &code))) + .condition_expression("attribute_exists(sk)") + .return_values(aws_sdk_dynamodb::types::ReturnValue::AllOld) + .send() + .await; + let row = match taken { + Ok(o) => o.attributes.unwrap_or_default(), + Err(e) => { + if e.as_service_error() + .is_some_and(|x| x.is_conditional_check_failed_exception()) + { + return answer( + StatusCode::GONE, + "That code has expired or was already used. Make a new one on the For you page.", + ); + } + warn!(error = %e, "Jira link: code not read"); + return answer(StatusCode::INTERNAL_SERVER_ERROR, ""); + } + }; + let expires: i64 = row + .get("expires_at") + .and_then(|v| v.as_n().ok()) + .and_then(|n| n.parse().ok()) + .unwrap_or(0); + let user = get_s(&row, "user"); + if user.is_empty() || expires <= now() { + return answer( + StatusCode::GONE, + "That code has expired or was already used. Make a new one on the For you page.", + ); + } + match link(&state, &team, &user, &account).await { + Ok(()) => { + info!(team_id = %team, "For you: a person linked their Jira account"); + let name = user_name(&state, &team, &user).await; + answer( + StatusCode::OK, + &match name { + Some(n) => format!("Linked to {n} in CoderHelm. Your sprint now shows on the For you page."), + None => "Linked. Your sprint now shows on CoderHelm's For you page.".into(), + }, + ) + } + Err(LinkError::Taken) => answer( + StatusCode::CONFLICT, + "This Jira account is already linked to another CoderHelm user. They unlink it on their For you page first.", + ), + Err(LinkError::Store) => answer(StatusCode::INTERNAL_SERVER_ERROR, ""), + } +} + +#[derive(Debug)] +enum LinkError { + Taken, + Store, +} + +/// Writes both rows. The account row first, claimed only when it is +/// nobody's or already this user's; then the user's row (a link to another +/// account is replaced and that account released). +async fn link(state: &AppState, team: &str, user: &str, account: &str) -> Result<(), LinkError> { + let at = chrono::Utc::now().to_rfc3339(); + let claimed = state + .dynamo + .update_item() + .table_name(&state.config.settings_table_name) + .key("pk", s(team)) + .key("sk", s(&common::requester::jira_user_sk(account))) + .update_expression("SET #l = :u, linked_at = :t") + .condition_expression("attribute_not_exists(#l) OR #l = :u") + .expression_attribute_names("#l", foryou::FIELD_LINKED_USER) + .expression_attribute_values(":u", s(user)) + .expression_attribute_values(":t", s(&at)) + .send() + .await; + if let Err(e) = claimed { + if e.as_service_error() + .is_some_and(|x| x.is_conditional_check_failed_exception()) + { + return Err(LinkError::Taken); + } + warn!(error = %e, "Jira link: account row not written"); + return Err(LinkError::Store); + } + let before = linked_jira(state, team, user).await; + state + .dynamo + .put_item() + .table_name(&state.config.settings_table_name) + .item("pk", s(team)) + .item("sk", s(&foryou::jira_link_sk(user))) + .item("account_id", s(account)) + .item("linked_at", s(&at)) + .send() + .await + .map_err(|e| { + warn!(error = %e, "Jira link: user row not written"); + LinkError::Store + })?; + if let Some(old) = before.filter(|o| o != account) { + release_account(state, team, &old, user).await; + } + Ok(()) +} + +async fn user_name(state: &AppState, team: &str, user: &str) -> Option { + state + .dynamo + .get_item() + .table_name(&state.config.users_table_name) + .key("pk", s(team)) + .key("sk", s(&format!("USER#{user}"))) + .send() + .await + .ok()? + .item + .map(|i| get_s(&i, "name")) + .filter(|n| !n.trim().is_empty()) +} + +/// The team's Jira users CoderHelm has seen, for the "Is this you?" +/// suggestion only (bounded read). +pub async fn seen_jira_users(state: &AppState, team: &str) -> Vec { + let prefix = common::requester::JIRA_USER_PREFIX; + let mut out = Vec::new(); + let mut start = None; + for _ in 0..5 { + let Ok(r) = state + .dynamo + .query() + .table_name(&state.config.settings_table_name) + .key_condition_expression("pk = :p AND begins_with(sk, :s)") + .expression_attribute_values(":p", s(team)) + .expression_attribute_values(":s", s(prefix)) + .set_exclusive_start_key(start.take()) + .send() + .await + else { + break; + }; + for i in r.items() { + if get_s(i, "pk") != team { + continue; + } + out.push(foryou::SeenJiraUser { + account_id: get_s(i, "sk").trim_start_matches(prefix).to_string(), + name: get_s(i, "name"), + email: get_s(i, "email"), + linked: !get_s(i, foryou::FIELD_LINKED_USER).is_empty(), + }); + } + match r.last_evaluated_key() { + Some(k) if !k.is_empty() => start = Some(k.clone()), + _ => break, + } + } + out +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_link_request_needs_the_team_its_proof_an_account_and_a_code() { + let ok = json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "ABCD-EFGH-JKMN-PQRS"}); + let (team, _, account, _) = read_link(&ok).unwrap(); + assert_eq!(team, "TEAM#acme1"); + assert_eq!(account, "557058:a1b2c3d4"); + let no_secret = json!({"coderhelm": {"team_id": "acme1"}, "account_id": "557058:a1b2c3d4", "code": "x"}); + assert_eq!(read_link(&no_secret).unwrap_err(), StatusCode::UNAUTHORIZED); + let bad_id = json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "x\" OR 1=1", "code": "c"}); + assert_eq!(read_link(&bad_id).unwrap_err(), StatusCode::BAD_REQUEST); + let no_code = json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4"}); + assert_eq!(read_link(&no_code).unwrap_err(), StatusCode::BAD_REQUEST); + } +} diff --git a/services/gateway/src/routes/jira_webhook.rs b/services/gateway/src/routes/jira_webhook.rs index ef9c45e91..cc6cd9565 100644 --- a/services/gateway/src/routes/jira_webhook.rs +++ b/services/gateway/src/routes/jira_webhook.rs @@ -365,6 +365,11 @@ pub(crate) fn ticket_triggers(issue: &Value, trigger_label: &str) -> (bool, bool (has_label, is_assigned) } +/// The team's trigger label, for For you's Give to CoderHelm. +pub(crate) async fn trigger_label_of(state: &AppState, team_id: &str) -> String { + team_trigger_label(state, team_id).await +} + /// The team's trigger label (`coderhelm` unless it set another). async fn team_trigger_label(state: &AppState, team_id: &str) -> String { state @@ -707,9 +712,14 @@ async fn process_jira_payload( }) .unwrap_or("jira") .to_string(); - let requester = payload - .get("user") - .and_then(common::requester::Requester::jira_user); + // A ticket given from For you: the label came from the Jira app, so the + // event names the app; the person who gave it is the owner. + let requester = match super::foryou_give::owner_for_event(state, team_id, ticket_key).await { + Some(owner) => Some(owner), + None => payload + .get("user") + .and_then(common::requester::Requester::jira_user), + }; remember_jira_users(state, team_id, payload).await; info!( @@ -1577,22 +1587,30 @@ fn named_jira_users(payload: &Value) -> Vec { /// Keeps the name and email of every Jira user a payload names, by account /// id, so runs that recorded only the account id can show the person's name. +/// An update, never a put: the row also holds who linked the account +/// (`common::foryou::FIELD_LINKED_USER`), which an event must not erase. The +/// email kept here is only ever a suggestion on For you, never a link. async fn remember_jira_users(state: &AppState, team_id: &str, payload: &Value) { let now = chrono::Utc::now().to_rfc3339(); for r in named_jira_users(payload) { let Some(id) = r.jira_id() else { continue }; - let mut put = state + let mut update = state .dynamo - .put_item() + .update_item() .table_name(&state.config.settings_table_name) - .item("pk", attr_s(team_id)) - .item("sk", attr_s(&common::requester::jira_user_sk(id))) - .item("name", attr_s(&r.name)) - .item("seen_at", attr_s(&now)); - if !r.email.is_empty() { - put = put.item("email", attr_s(&r.email)); - } - if let Err(e) = put.send().await { + .key("pk", attr_s(team_id)) + .key("sk", attr_s(&common::requester::jira_user_sk(id))) + .expression_attribute_names("#n", "name") + .expression_attribute_values(":n", attr_s(&r.name)) + .expression_attribute_values(":t", attr_s(&now)); + update = if r.email.is_empty() { + update.update_expression("SET #n = :n, seen_at = :t") + } else { + update + .update_expression("SET #n = :n, seen_at = :t, email = :e") + .expression_attribute_values(":e", attr_s(&r.email)) + }; + if let Err(e) = update.send().await { warn!(team_id, error = %e, "Could not keep a Jira user's name"); } } diff --git a/services/gateway/src/routes/mod.rs b/services/gateway/src/routes/mod.rs index 541b684ed..367b50e18 100644 --- a/services/gateway/src/routes/mod.rs +++ b/services/gateway/src/routes/mod.rs @@ -39,6 +39,9 @@ pub mod email_metrics; pub mod email_settings; pub mod entra_sso; pub mod followup_dedupe; +pub mod foryou; +pub mod foryou_give; +pub mod foryou_link; pub mod github; pub mod github_hybrid; pub mod github_webhook; diff --git a/services/gateway/src/routes/prs.rs b/services/gateway/src/routes/prs.rs index 1136ddd13..1563891e0 100644 --- a/services/gateway/src/routes/prs.rs +++ b/services/gateway/src/routes/prs.rs @@ -427,7 +427,10 @@ async fn runs_by_id(state: &AppState, team_id: &str, ids: &[String]) -> HashMap< } /// The team's records and joins, from the short cache or the tables. -async fn read_all(state: &AppState, team_id: &str) -> Result<(Snapshot, Vec), StatusCode> { +pub(crate) async fn read_all( + state: &AppState, + team_id: &str, +) -> Result<(Snapshot, Vec), StatusCode> { let installation_id = super::api::get_team_installation_id(state, team_id) .await .unwrap_or(0); diff --git a/services/worker/src/passes/incidents/bm_teams_never_cross.rs b/services/worker/src/passes/incidents/bm_teams_never_cross.rs index f4988d90c..301cae2c4 100644 --- a/services/worker/src/passes/incidents/bm_teams_never_cross.rs +++ b/services/worker/src/passes/incidents/bm_teams_never_cross.rs @@ -112,6 +112,12 @@ const INBOUND: &[(&str, &str, &str, &str)] = &[ "forge_secret_matches(stored_secret, request_secret)", "the team named, proven by that team's own Forge secret; the work runs under the team's stored installation", ), + ( + "routes::foryou_link::forge_link", + "gateway/src/routes/foryou_link.rs", + "forge_secret_matches(&stored, &secret)", + "the team named, proven by that team's own Forge secret; the dashboard user from a one-time code signed for that team and used up in the read", + ), ( "routes::alerts::handle_sns", "gateway/src/routes/alerts.rs", @@ -353,6 +359,7 @@ const CACHES: &[(&str, &str)] = &[ ("gateway/src/permissions.rs::ROUTES", "route table; no data"), ("gateway/src/routes/chat_work_prs.rs::CACHE", "URL, reused only on a 304 to the team's own token; repo checked against the team's repos first"), ("gateway/src/routes/github_webhook.rs::SEEN", "installation id; log throttle"), + ("gateway/src/routes/foryou.rs::READS", "installation id plus the team and the session user (read_key(installation_id, \"foryou##\")): one person's own reads, never another's"), ("gateway/src/routes/prs.rs::LIST", "installation id plus the team id (read_key(installation_id, \"prs#\")); its rows keep only that team's records"), ("gateway/src/routes/roles.rs::CACHE", "(team, role)"), ("gateway/src/routes/run_checks.rs::TOKENS", "installation id"), diff --git a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs new file mode 100644 index 000000000..4a10fcf6f --- /dev/null +++ b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs @@ -0,0 +1,248 @@ +//! ya. The For you page shows one person their own reviews, pull requests, +//! sprint tickets and private numbers. Three ways it could have gone wrong +//! were found in its design: +//! +//! - a route taking a user (`?user=`) would let anyone read anyone's page; +//! - the private numbers (what waits on you, your median review turnaround) +//! read for another person would turn a private rail into a ranking; +//! - Chat's "what needs me" matched a dashboard user to a Jira account by +//! email, and the page was to reuse it: an email can be hidden in +//! Atlassian or differ from the sign-in email, so the wrong person's sprint +//! could show, or another person's account could be taken over by anyone +//! whose email matched. +//! +//! Guarantees: +//! - every For you route reads only the session's team and user; none takes +//! a user, an email or a login from the request, and the short cache is +//! keyed by the installation, the team and the session user; +//! - the stats are computed for the session's own GitHub login only, and +//! nothing outside the For you page computes them; +//! - a Jira account is linked only by a one-time code the person makes on +//! the dashboard (signed for their team, used up once) redeemed from the +//! Jira app as that account; an email match is at most an "Is this you?" +//! suggestion, and Chat reads only the link. + +use std::path::{Path, PathBuf}; + +use common::foryou; +use common::pr_record::{RequestEvent, ReviewEvent}; + +fn services() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .expect("services dir") + .to_path_buf() +} + +fn read(rel: &str) -> String { + std::fs::read_to_string(services().join(rel)).unwrap_or_else(|e| panic!("{rel}: {e}")) +} + +const FILES: &[&str] = &[ + "gateway/src/routes/foryou.rs", + "gateway/src/routes/foryou_give.rs", + "gateway/src/routes/foryou_link.rs", +]; + +/// The source without its test module. +fn code(rel: &str) -> String { + let src = read(rel); + match src.find("#[cfg(test)]") { + Some(i) => src[..i].to_string(), + None => src, + } +} + +#[test] +fn every_for_you_route_is_the_sessions_and_takes_no_user() { + let main = read("gateway/src/main.rs"); + let routes: Vec<&str> = main.lines().filter(|l| l.contains("\"/foryou")).collect(); + assert!(routes.len() >= 6, "{routes:?}"); + for r in &routes { + assert!(!r.contains(':'), "a For you path takes no parameter: {r}"); + } + for f in FILES { + let src = code(f); + // No request shape names a person. + for field in [ + "pub user:", + "pub user_id:", + "pub email:", + "pub login:", + "pub person:", + "pub sub:", + ] { + assert!( + !src.contains(field), + "{f} reads a person from the request ({field})" + ); + } + for q in [ + "q.user", + "body.user", + "q.email", + "body.email", + "q.login", + "body.login", + ] { + assert!( + !src.contains(q), + "{f} reads a person from the request ({q})" + ); + } + } + // Every person's settings and links are keyed by the session's user. + let page = code("gateway/src/routes/foryou.rs"); + assert!(page.contains( + "let key = read_key(installation, &format!(\"foryou#{}#{user}\", claims.team_id));" + )); + assert!(page.contains("pub async fn get_for_you(\n State(state): State>,\n Extension(claims): Extension,\n) -> Result, StatusCode> {"), + "GET /api/foryou has no query and no body: only the session"); + let link = code("gateway/src/routes/foryou_link.rs"); + assert!(link.contains(".strip_prefix(\"USER#\")")); + assert_ne!(foryou::user_sk("dana"), foryou::user_sk("mara")); + assert_ne!(foryou::jira_link_sk("dana"), foryou::jira_link_sk("mara")); +} + +#[test] +fn stats_are_never_computed_for_another_person() { + // The numbers are one login's: another reviewer's reviews never count. + let logs = vec![( + vec![ + RequestEvent { + who: "dana".into(), + at: 1_000, + removed_at: 0, + }, + RequestEvent { + who: "mara".into(), + at: 1_000, + removed_at: 0, + }, + ], + vec![ + ReviewEvent { + who: "mara".into(), + state: "APPROVED".into(), + sha: String::new(), + at: 1_060, + human: true, + has_body: false, + }, + ReviewEvent { + who: "dana".into(), + state: "APPROVED".into(), + sha: String::new(), + at: 4_600, + human: true, + has_body: false, + }, + ], + )]; + assert_eq!( + foryou::review_turnaround(&logs, "dana", 10_000), + Some((3_600, 1)) + ); + // Only the For you page computes them, and only for the session's login. + for dir in ["gateway/src", "worker/src"] { + for e in walk(&services().join(dir)) { + let rel = e + .strip_prefix(services()) + .unwrap() + .to_string_lossy() + .replace('\\', "/"); + let src = std::fs::read_to_string(&e).unwrap_or_default(); + if src.contains("review_turnaround(") + && !rel.ends_with("incidents/ya_for_you_is_only_yours.rs") + { + assert_eq!( + rel, "gateway/src/routes/foryou.rs", + "{rel} computes a person's review turnaround" + ); + } + } + } + let page = code("gateway/src/routes/foryou.rs"); + assert!(page.contains("foryou::review_turnaround(&logs, &login, now)")); + assert!(page.contains("let login = v.github.clone().unwrap_or_default();")); + assert!(page.contains("github: claims.github_login.clone().filter(|g| !g.trim().is_empty()),")); +} + +fn walk(p: &Path) -> Vec { + let mut out = Vec::new(); + if let Ok(rd) = std::fs::read_dir(p) { + for e in rd.flatten() { + let path = e.path(); + if path.is_dir() { + out.extend(walk(&path)); + } else if path.extension().is_some_and(|x| x == "rs") { + out.push(path); + } + } + } + out +} + +#[test] +fn email_alone_never_links_an_identity() { + // The suggestion is all an email can make, and only for one unlinked + // account seen with exactly that email. + let seen = vec![foryou::SeenJiraUser { + account_id: "557058:dana0001".into(), + name: "Dana Ortiz".into(), + email: "dana@example.com".into(), + linked: false, + }]; + assert!(foryou::identity_suggestion(&seen, "dana@example.com", &Default::default()).is_some()); + // A link needs a code signed for the team: no email in it, and another + // team's code or a changed one is refused before any read. + let (made, _) = foryou::issue_code(b"k", "TEAM#a", [9, 9, 9, 9, 9]); + assert!(foryou::verify_code(b"k", "TEAM#a", &made)); + assert!(!foryou::verify_code(b"k", "TEAM#b", &made)); + // Only the link route writes a link, and only after the code is + // checked and used up. + for dir in ["gateway/src", "worker/src", "common/src"] { + for e in walk(&services().join(dir)) { + let rel = e + .strip_prefix(services()) + .unwrap() + .to_string_lossy() + .replace('\\', "/"); + if rel.contains("/incidents/") || rel.ends_with("common/src/foryou.rs") { + continue; + } + let src = std::fs::read_to_string(&e).unwrap_or_default(); + if src.contains("jira_link_sk(") && src.contains(".put_item()") { + assert_eq!( + rel, "gateway/src/routes/foryou_link.rs", + "{rel} writes a Jira link" + ); + } + assert!( + !src.contains("fn jira_accounts("), + "{rel} finds Jira accounts by email" + ); + } + } + let link = code("gateway/src/routes/foryou_link.rs"); + let verify = link.find("foryou::verify_code(").unwrap(); + let used_up = link + .find("condition_expression(\"attribute_exists(sk)\")") + .unwrap(); + let write = link + .find("match link(&state, &team, &user, &account)") + .unwrap(); + assert!(verify < used_up && used_up < write); + // Chat's "what needs me" reads only the link, never an email match. + let needs = code("gateway/src/routes/chat_work_needs.rs"); + assert!(needs.contains("src.store.jira_link(src.team, &me.user)")); + assert!( + !needs.contains("requester_email\").eq_ignore_ascii_case"), + "no Jira id from runs by email" + ); + // A Jira event refreshing a user's name never erases who linked it. + let hook = code("gateway/src/routes/jira_webhook.rs"); + let remember = &hook[hook.find("async fn remember_jira_users").unwrap()..]; + let remember = &remember[..remember.find("\n}\n").unwrap()]; + assert!(remember.contains(".update_item()") && !remember.contains(".put_item()")); +} diff --git a/services/worker/src/passes/mod.rs b/services/worker/src/passes/mod.rs index 468c76ce8..a6db9f54c 100644 --- a/services/worker/src/passes/mod.rs +++ b/services/worker/src/passes/mod.rs @@ -4363,6 +4363,116 @@ async fn run_passes( return Ok(()); } + // Given from For you with "Draft a plan first" (`common::foryou`): the + // plan is shown and the run waits for the person's OK before any code. + // Their own ask, so the judge settles it by rule: no default, no + // deadline. An approval on the run page starts the next run, which + // codes. + if let Some(mut given) = common::foryou::read_given( + &state.dynamo, + &state.config.settings_table_name, + &msg.team_id, + &msg.ticket_id, + ) + .await + .filter(|g| g.plan_first && g.approved_at == 0) + { + if common::foryou::plan_approved(&msg.answers) { + given.approved_at = chrono::Utc::now().timestamp(); + if let Err(e) = common::foryou::put_given( + &state.dynamo, + &state.config.settings_table_name, + &msg.team_id, + &given, + ) + .await + { + warn!(run_id, error = %e, "Plan approval not recorded on the give"); + } + add_progress_note( + state, + &msg.team_id, + run_id, + "The plan was approved: coding starts.", + ) + .await; + } else { + let steps = plan_result + .tasks + .lines() + .filter(|l| l.trim_start().starts_with("- [")) + .count(); + let mut picture = stop_judge::Picture::new( + stop_judge::Kind::Ask, + "plan_first", + &format!("{steps} planned steps for {}", msg.ticket_id), + ); + picture.plan_first_for = if given.owner_name.trim().is_empty() { + "The person who gave the ticket".into() + } else { + given.owner_name.clone() + }; + picture.plan = plan_result.design.clone(); + let judged = stop_judge::decide( + state, + &provider, + usage, + &msg.team_id, + &stop_judge::run_subject(run_id), + "", + picture, + ) + .await; + let questions = stop_judge::questions_for(&judged, &[]); + let list_md = + stop_judge::stop_text(&judged, &common::run_questions::markdown(&questions)); + let list_plain = + stop_judge::stop_text(&judged, &common::run_questions::plain(&questions)); + let github_comment = format!( + "**Plan ready for your OK**\n\n{list_md}\n\nApprove it on the run page in CoderHelm, \ + or reply here, and I'll start coding." + ); + let jira_comment = format!( + "{list_plain}\n\nApprove it on the run page in CoderHelm, or reply here, and I'll start coding." + ); + ask_on_ticket( + state, + msg, + run_id, + &github, + &questions, + &github_comment, + &jira_comment, + "Plan ready for your OK", + &judged, + ) + .await; + let wait = WaitingOn::answer_or( + &questions, + None, + WaitingOn::fixed( + "Approve the plan on the run page", + "You asked to see the plan before any code.", + &ticket_url(msg), + ), + ); + mark_run_needs_input( + state, + msg, + run_id, + usage, + start, + &used_mcp_ids, + &wait, + &judged, + supervisor::HumanOnly::Approval, + ) + .await; + close_memory(state, agent_memory.take()).await; + return Ok(()); + } + } + // The plan passed every check and is the one implemented: its // follow-ups are filed now, once. if let (Some(due), Some(decision)) = (followups_due.take(), plan_result.fix.as_mut()) { From fcdc9d0cab3703dbf6b02b838fa4071699cba701 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 18:46:06 -0500 Subject: [PATCH 08/19] Jira app 7.1.0: what a site lacks without For you's sprint, link and give The features table names the first released version with each: a site still on major 6 is told it lacks them. --- .github/scripts/test_forge_release.py | 3 ++- services/common/src/jira_app_features.json | 5 ++++- services/common/src/jira_app_version.rs | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/scripts/test_forge_release.py b/.github/scripts/test_forge_release.py index f012dc2d6..91ee85512 100644 --- a/.github/scripts/test_forge_release.py +++ b/.github/scripts/test_forge_release.py @@ -201,7 +201,8 @@ def test_behind_lists_each_site_by_number_with_what_it_lacks(self): for f in ["full comment reading", "mentions", "in-place edits", "threaded replies", "issue type", "extended issue fields"]: self.assertIn(f, names) self.assertEqual(fr.missing_on_major(features, 5), names) - self.assertEqual(fr.missing_on_major(features, 6), []) + self.assertEqual(sorted(fr.missing_on_major(features, 6)), sorted(["open sprint for For you", "Link my CoderHelm account", "Give to CoderHelm from For you"])) + self.assertEqual(fr.missing_on_major(features, 7), []) self.assertEqual(fr.missing_on_major(features, None), names) md, warning = fr.behind_report(["5\tjira\n", "\n", "\tjira\n"], "6.11.0", features) self.assertIn("- Site 1 (jira): major version 5 (latest 6.11.0). Missing: ", md) diff --git a/services/common/src/jira_app_features.json b/services/common/src/jira_app_features.json index 3e9e7fad2..a2a16985f 100644 --- a/services/common/src/jira_app_features.json +++ b/services/common/src/jira_app_features.json @@ -4,5 +4,8 @@ { "since": "6.9.0", "feature": "mentions", "commit": "0a1e381f" }, { "since": "6.9.0", "feature": "in-place edits", "commit": "0a1e381f" }, { "since": "6.9.0", "feature": "extended issue fields", "commit": "0a1e381f" }, - { "since": "6.10.0", "feature": "threaded replies", "commit": "e9f25b6d" } + { "since": "6.10.0", "feature": "threaded replies", "commit": "e9f25b6d" }, + { "since": "7.1.0", "feature": "open sprint for For you", "commit": "29dc1560" }, + { "since": "7.1.0", "feature": "Link my CoderHelm account", "commit": "29dc1560" }, + { "since": "7.1.0", "feature": "Give to CoderHelm from For you", "commit": "29dc1560" } ] diff --git a/services/common/src/jira_app_version.rs b/services/common/src/jira_app_version.rs index de79d0e54..797e13d8b 100644 --- a/services/common/src/jira_app_version.rs +++ b/services/common/src/jira_app_version.rs @@ -426,10 +426,20 @@ mod tests { assert!(at_8.contains(&"threaded replies".to_string())); assert_eq!( missing_since(Version::parse("6.10.0")), - Vec::::new() + vec![ + "open sprint for For you", + "Link my CoderHelm account", + "Give to CoderHelm from For you" + ] ); + assert!(missing_since(Version::parse("7.1.0")).is_empty()); assert_eq!(missing_on_major(5).len(), features().len()); - assert!(missing_on_major(6).is_empty()); + assert_eq!( + missing_on_major(6).len(), + 3, + "a site on 6 lacks what 7.1 added" + ); + assert!(missing_on_major(7).is_empty()); } #[test] From 13ca67d07cdc02f88cc0d3b097c0389361f1bda6 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 20:37:46 -0500 Subject: [PATCH 09/19] For you: the privacy case reads request shapes and path literals only; the fit reason and version test follow 7.1.0 --- services/common/src/foryou.rs | 6 +-- services/common/src/jira_app_version.rs | 2 +- .../incidents/ya_for_you_is_only_yours.rs | 43 +++++++++++++++++-- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/services/common/src/foryou.rs b/services/common/src/foryou.rs index 4aede1424..c85b9e81e 100644 --- a/services/common/src/foryou.rs +++ b/services/common/src/foryou.rs @@ -722,9 +722,9 @@ pub fn fit(t: &TicketFacts) -> Fit { kind, why, missing: vec![if ex.starts_with("it spans") { - format!("{}: it needs a person's judgment", capitalize(&ex)) + format!("{}: it is a judgment call", capitalize(&ex)) } else { - format!("It is {ex} work, which CoderHelm is never suggested for: it needs a person's judgment") + format!("It is {ex} work, which CoderHelm is never suggested for: it is a judgment call") }], excluded: Some(ex), }; @@ -1521,7 +1521,7 @@ mod tests { assert_eq!(f.band, Band::Not, "{title}"); assert_eq!(f.excluded.as_deref(), Some(why), "{title}"); assert!( - f.missing[0].contains("needs a person's judgment"), + f.missing[0].contains("is a judgment call"), "{:?}", f.missing ); diff --git a/services/common/src/jira_app_version.rs b/services/common/src/jira_app_version.rs index 797e13d8b..32beca84d 100644 --- a/services/common/src/jira_app_version.rs +++ b/services/common/src/jira_app_version.rs @@ -511,7 +511,7 @@ mod tests { "a self-hosted copy" ); // Behind the latest, but newer than every feature: no Missing sentence. - let b = assess(Some(&seen("6.11.0")), Some(&latest("6.12.0")), SITE).unwrap(); + let b = assess(Some(&seen("7.1.0")), Some(&latest("7.2.0")), SITE).unwrap(); assert!(b.missing.is_empty()); assert!(!b.message.contains("Missing")); } diff --git a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs index 4a10fcf6f..931478899 100644 --- a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs +++ b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs @@ -44,6 +44,33 @@ const FILES: &[&str] = &[ "gateway/src/routes/foryou_link.rs", ]; +/// Every struct that derives `Deserialize`, from its derive to its closing +/// brace: the shapes a request can fill. +fn request_shapes(src: &str) -> String { + let mut out = String::new(); + let mut rest = src; + while let Some(i) = rest.find("#[derive(") { + let tail = &rest[i..]; + let derive_end = tail.find(")]").map(|e| e + 2).unwrap_or(tail.len()); + let deserialized = tail[..derive_end].contains("Deserialize"); + let item_end = tail.find("\n}").map(|e| e + 2).unwrap_or(tail.len()); + if deserialized { + out.push_str(&tail[..item_end]); + out.push('\n'); + } + rest = &tail[derive_end..]; + } + out +} + +#[test] +fn a_request_shape_is_found_and_an_internal_one_is_not() { + let src = "#[derive(Debug, Deserialize)]\npub struct Q {\n pub user: String,\n}\n#[derive(Debug, Clone)]\npub struct Viewer {\n pub login: String,\n}\n"; + let shapes = request_shapes(src); + assert!(shapes.contains("pub user:")); + assert!(!shapes.contains("pub login:")); +} + /// The source without its test module. fn code(rel: &str) -> String { let src = read(rel); @@ -59,11 +86,19 @@ fn every_for_you_route_is_the_sessions_and_takes_no_user() { let routes: Vec<&str> = main.lines().filter(|l| l.contains("\"/foryou")).collect(); assert!(routes.len() >= 6, "{routes:?}"); for r in &routes { - assert!(!r.contains(':'), "a For you path takes no parameter: {r}"); + // The path literal alone: `:name` or `{name}` would take a person. + let path = r.split('"').nth(1).unwrap_or_default(); + assert!( + !path.contains(':') && !path.contains('{'), + "a For you path takes no parameter: {r}" + ); } for f in FILES { let src = code(f); - // No request shape names a person. + // No request shape (a struct read from a query or a body) names a + // person. Internal structs, like the page's own viewer, are filled + // from the session and are not read here. + let shapes = request_shapes(&src); for field in [ "pub user:", "pub user_id:", @@ -73,7 +108,7 @@ fn every_for_you_route_is_the_sessions_and_takes_no_user() { "pub sub:", ] { assert!( - !src.contains(field), + !shapes.contains(field), "{f} reads a person from the request ({field})" ); } @@ -212,7 +247,7 @@ fn email_alone_never_links_an_identity() { continue; } let src = std::fs::read_to_string(&e).unwrap_or_default(); - if src.contains("jira_link_sk(") && src.contains(".put_item()") { + if src.contains("foryou::jira_link_sk(") && src.contains(".put_item()") { assert_eq!( rel, "gateway/src/routes/foryou_link.rs", "{rel} writes a Jira link" From ff4b31f75049eb49142e36dcf2211a44ac2c939d Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 20:49:18 -0500 Subject: [PATCH 10/19] Jira app: Forge bridge 7 and UI Kit 12, prosemirror-view held at the fixed 1.42.3 or newer Clears the linkify-it and prosemirror-view advisories. Atlassian's editor packages pin prosemirror-view below the fix in every release, so an override lifts it. --- coderhelm-jira/package-lock.json | 4895 ++++++++++++++++++++---------- coderhelm-jira/package.json | 7 +- 2 files changed, 3294 insertions(+), 1608 deletions(-) diff --git a/coderhelm-jira/package-lock.json b/coderhelm-jira/package-lock.json index a963b8747..617698893 100644 --- a/coderhelm-jira/package-lock.json +++ b/coderhelm-jira/package-lock.json @@ -6,42 +6,44 @@ "": { "dependencies": { "@forge/api": "^7.1.1", - "@forge/bridge": "^5.17.0", - "@forge/react": "^11.17.0", + "@forge/bridge": "^7.4.0", + "@forge/react": "^12.6.0", "@forge/resolver": "^1.8.0", "@forge/ui": "^1.11.4", "react": "^19.3.1" } }, "node_modules/@atlaskit/adf-schema": { - "version": "48.0.0", - "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema/-/adf-schema-48.0.0.tgz", - "integrity": "sha512-zzPhx1zsiAL2zSR9APrw6CMNxAGMerjjNgc0AeqQWZjSuh4U18THv77o4buS9QPdUn2S8BztBNiEbB7bP9wNRw==", + "version": "56.7.3", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema/-/adf-schema-56.7.3.tgz", + "integrity": "sha512-2G82HHnQT/uSnk1cydfHrT/+S6ds+Oz7pkYKUBjdJjdhUFzNDeBR9MdpxusOQSDI0vrvtmkyR2IcY5xmv8p5dA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/editor-prosemirror": "*", - "@atlaskit/feature-gate-js-client": "^4.26.4", + "@atlaskit/adf-schema-generator": "^4.0.0", + "@atlaskit/editor-prosemirror": "^8.0.0", + "@atlaskit/platform-feature-flags": "^2.1.0", + "@atlaskit/tmp-editor-statsig": "^147.0.0", "@babel/runtime": "^7.0.0", "css-color-names": "0.0.4", - "linkify-it": "^2.0.3", + "linkify-it": "^5.0.2", "memoize-one": "^6.0.0" } }, "node_modules/@atlaskit/adf-schema-generator": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema-generator/-/adf-schema-generator-2.4.0.tgz", - "integrity": "sha512-67OANQ8dqp2tJbrHjP9vcwf3aQ90t8pyzT66YSc0Fw/52qibUEQtXU5QEQZFtq7Y0go0YreeLdO8dkH6R+zMAA==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema-generator/-/adf-schema-generator-4.0.4.tgz", + "integrity": "sha512-uFVUN81FHtcRl6zZUf7FhaFhSsAvPpeHo4nQlCXznJEqtTN/KAYJ+9nH1eMSUDoy///LyQBct1lrw/Iyvu/SnA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/editor-prosemirror": "^7.3.0", + "@atlaskit/editor-prosemirror": "^9.0.0", "@babel/runtime": "^7.0.0", "lodash": "^4.17.21" } }, "node_modules/@atlaskit/adf-schema-generator/node_modules/@atlaskit/editor-prosemirror": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-7.3.0.tgz", - "integrity": "sha512-6KB4CuURZ+fU1DJMlmCox6q8T5ooVaCE+eZVrAlcODIfTyLu/wCvJfPJLOJUPZBvzCHqoWCebFmpu39uwUUleg==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-9.0.2.tgz", + "integrity": "sha512-Hn5atRMHJDQFz1U6PbzK50LRt/rEHbwvvNm49n6zIVV1464GfVuoGFtK0sHXPKi2LE1k8HNyyEjOAjLQUsoifw==", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.0.0", @@ -49,18 +51,18 @@ "prosemirror-dropcursor": "1.8.2", "prosemirror-history": "1.5.0", "prosemirror-keymap": "1.2.3", - "prosemirror-markdown": "1.13.2", + "prosemirror-markdown": "1.13.4", "prosemirror-model": "1.25.4", "prosemirror-state": "1.4.4", - "prosemirror-transform": "1.10.5", + "prosemirror-transform": "1.11.0", "prosemirror-utils": "1.2.2", - "prosemirror-view": "1.41.5" + "prosemirror-view": "1.41.7" } }, "node_modules/@atlaskit/adf-schema-generator/node_modules/prosemirror-markdown": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.2.tgz", - "integrity": "sha512-FPD9rHPdA9fqzNmIIDhhnYQ6WgNoSWX9StUZ8LEKapaXU9i6XgykaHKhp6XMyXlOWetmaFgGDS/nu/w9/vUc5g==", + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.4.tgz", + "integrity": "sha512-D98dm4cQ3Hs6EmjK500TdAOew4Z03EV71ajEFiWra3Upr7diytJsjF4mPV2dW+eK5uNectiRj0xFxYI9NLXDbw==", "license": "MIT", "dependencies": { "@types/markdown-it": "^14.0.0", @@ -69,56 +71,48 @@ } }, "node_modules/@atlaskit/adf-schema-generator/node_modules/prosemirror-transform": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.10.5.tgz", - "integrity": "sha512-RPDQCxIDhIBb1o36xxwsaeAvivO8VLJcgBtzmOwQ64bMtsVFh5SSuJ6dWSxO1UsHTiTXPCgQm3PDJt7p6IOLbw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.11.0.tgz", + "integrity": "sha512-4I7Ce4KpygXb9bkiPS3hTEk4dSHorfRw8uI0pE8IhxlK2GXsqv5tIA7JUSxtSu7u8APVOTtbUBxTmnHIxVkIJw==", "license": "MIT", "dependencies": { "prosemirror-model": "^1.21.0" } }, - "node_modules/@atlaskit/adf-schema-generator/node_modules/prosemirror-view": { - "version": "1.41.5", - "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.5.tgz", - "integrity": "sha512-UDQbIPnDrjE8tqUBbPmCOZgtd75htE6W3r0JCmY9bL6W1iemDM37MZEKC49d+tdQ0v/CKx4gjxLoLsfkD2NiZA==", - "license": "MIT", - "dependencies": { - "prosemirror-model": "^1.20.0", - "prosemirror-state": "^1.0.0", - "prosemirror-transform": "^1.1.0" - } - }, "node_modules/@atlaskit/adf-utils": { - "version": "19.33.9", - "resolved": "https://registry.npmjs.org/@atlaskit/adf-utils/-/adf-utils-19.33.9.tgz", - "integrity": "sha512-we14ekAIWGvcA00C5RevNrNFbErCDObKcp6o/xNhgEUqRosRqGTs/dwK5kf0JgfVrPYsDpwrO+3y7/flKLaIrQ==", + "version": "20.9.85", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-utils/-/adf-utils-20.9.85.tgz", + "integrity": "sha512-sKVbA6+kgbxZJDPoFPFr6rqmMcvXGli07n4/U5t/ov0sq7ZNIrBlHNfeqzVkQuSJqU/ZyGfzOyWRcayhdcLxow==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/adf-schema": "^54.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/tmp-editor-statsig": "^103.0.0", + "@atlaskit/adf-schema": "^57.7.0", + "@atlaskit/editor-prosemirror": "^9.0.0", + "@atlaskit/platform-feature-experiments": "^0.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", "@babel/runtime": "^7.0.0" } }, "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/adf-schema": { - "version": "54.0.4", - "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema/-/adf-schema-54.0.4.tgz", - "integrity": "sha512-Ra+tIQGMhcOj96CnRjpDkom8sjebA+PmzHp8OjXW6BOJO6yGRBlnwNSxlcBKdk0O6hFxfIwr5SRN0FF1Dyo1Rg==", + "version": "57.7.77", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema/-/adf-schema-57.7.77.tgz", + "integrity": "sha512-+S1xj0fXepWg0PtudKidQTZhg6mcHKBnFrmtMS+a5Xs8Wi4p/rEEAiMh88tDm7SHNvym8RF75lMHtLjhCQMejw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/adf-schema-generator": "^2.4.0", - "@atlaskit/editor-prosemirror": "^7.3.0", - "@atlaskit/tmp-editor-statsig": "^103.0.0", + "@atlaskit/adf-schema-generator": "^4.0.0", + "@atlaskit/editor-prosemirror": "^9.0.0", + "@atlaskit/platform-feature-experiments": "^0.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/tmp-editor-statsig": "^295.0.0", "@babel/runtime": "^7.0.0", "css-color-names": "0.0.4", - "linkify-it": "^3.0.3", + "linkify-it": "^5.0.2", "memoize-one": "^6.0.0" } }, "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/browser-apis": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-0.0.2.tgz", - "integrity": "sha512-3mfBAVBx8ReUlILUGdsc+G1JlrA0DvFAbOMorJfsIvsOqJViABxjQyW05psbnLoLZD/CT3+9jCHSHOIY8Gwtyw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.0.0" @@ -128,9 +122,9 @@ } }, "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/editor-prosemirror": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-7.3.0.tgz", - "integrity": "sha512-6KB4CuURZ+fU1DJMlmCox6q8T5ooVaCE+eZVrAlcODIfTyLu/wCvJfPJLOJUPZBvzCHqoWCebFmpu39uwUUleg==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-9.0.2.tgz", + "integrity": "sha512-Hn5atRMHJDQFz1U6PbzK50LRt/rEHbwvvNm49n6zIVV1464GfVuoGFtK0sHXPKi2LE1k8HNyyEjOAjLQUsoifw==", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.0.0", @@ -138,33 +132,34 @@ "prosemirror-dropcursor": "1.8.2", "prosemirror-history": "1.5.0", "prosemirror-keymap": "1.2.3", - "prosemirror-markdown": "1.13.2", + "prosemirror-markdown": "1.13.4", "prosemirror-model": "1.25.4", "prosemirror-state": "1.4.4", - "prosemirror-transform": "1.10.5", + "prosemirror-transform": "1.11.0", "prosemirror-utils": "1.2.2", - "prosemirror-view": "1.41.5" + "prosemirror-view": "1.41.7" } }, - "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/feature-gate-js-client": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-5.8.0.tgz", - "integrity": "sha512-SJ+U0EVPdAXHy8Ge7I1BT7bptUiCG11x2XVwqRqZ5ysbR9WsfuUfX4l5BchAqyogJrcrt0v8TC1IBmcQ0WeEUA==", + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/atlassian-context": "^0.11.0", - "@babel/runtime": "^7.0.0", - "@statsig/client-core": "^3.27.0", - "@statsig/js-client": "^3.27.0", - "eventemitter3": "^4.0.0" + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" } }, - "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/interaction-context": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-3.1.0.tgz", - "integrity": "sha512-LB3T0ATpJ5y7/IVBndNbcjtaNmPcz/8k7+smMibzphmV7xB3HaIyJFEu2JoSmgps66qLXo0ia8Hj7v4dF9zJZw==", + "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/platform-feature-experiments": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-experiments/-/platform-feature-experiments-0.3.2.tgz", + "integrity": "sha512-EdFY3b6muB7y1KyyZ+d2ovIFzW/ubc8Qw2oio/zfh6VhRHQ4tmCIX77CgFYURgbhtwu5THTyADE5N2OvMmtcFA==", "license": "Apache-2.0", "dependencies": { + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/react-ufo": "^8.3.0", "@babel/runtime": "^7.0.0" }, "peerDependencies": { @@ -172,55 +167,46 @@ } }, "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/react-ufo": { - "version": "6.7.5", - "resolved": "https://registry.npmjs.org/@atlaskit/react-ufo/-/react-ufo-6.7.5.tgz", - "integrity": "sha512-xzz8KzMSAGEni6sUckaer2GNokMeSq9Cn+4awpZhspgiXDv1TOLFqFuqz8uUisHmbUPbK+9e/fE0r6gc5/ZQvg==", + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/@atlaskit/react-ufo/-/react-ufo-8.9.1.tgz", + "integrity": "sha512-xqT6rlxEkQLXkhhz7JzUaTmQCRvHdTSdfQ5TEF2/pl9MTH+qGAP+kpHW1Zs3UzbXjDSw/OhQpF+lQsE1UQ8AZw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/atlassian-context": "^0.11.0", - "@atlaskit/browser-apis": "^0.0.2", - "@atlaskit/feature-gate-js-client": "^5.8.0", - "@atlaskit/interaction-context": "^3.1.0", - "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/atlassian-context": "^2.0.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/interaction-context": "^4.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", "@opentelemetry/api": "^1.9.0", "bind-event-listener": "^3.0.0", "bowser-ultralight": "^1.0.6", - "scheduler": "0.23.2", - "uuid": "^3.1.0" + "uuid": "^11.1.1" }, "peerDependencies": { "react": "^18.2.0" } }, "node_modules/@atlaskit/adf-utils/node_modules/@atlaskit/tmp-editor-statsig": { - "version": "103.0.1", - "resolved": "https://registry.npmjs.org/@atlaskit/tmp-editor-statsig/-/tmp-editor-statsig-103.0.1.tgz", - "integrity": "sha512-XbGaofYNGvpFCt7kol/OunGO7hDV32Nm0KHXtotvsqNZNKrFC1lIB/5aw5b8sXyrn2D93VBlaaRLsvJ4tbejHA==", + "version": "295.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tmp-editor-statsig/-/tmp-editor-statsig-295.0.0.tgz", + "integrity": "sha512-RVWR6+vDMah4lbp4SESvTLGbMvfK8Tbpt5sSdm24JUMchAt3sdePoN/ALsC1jo87vyJr9h7P156IPrzD++Jzkg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/feature-gate-js-client": "^5.8.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/react-ufo": "^6.7.0", + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-ufo": "^8.9.0", "@babel/runtime": "^7.0.0" }, "peerDependencies": { - "react": "^18.2.0" - } - }, - "node_modules/@atlaskit/adf-utils/node_modules/linkify-it": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", - "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", - "license": "MIT", - "dependencies": { - "uc.micro": "^1.0.1" + "react": "^18.2.0 || ^19.2.0" } }, "node_modules/@atlaskit/adf-utils/node_modules/prosemirror-markdown": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.2.tgz", - "integrity": "sha512-FPD9rHPdA9fqzNmIIDhhnYQ6WgNoSWX9StUZ8LEKapaXU9i6XgykaHKhp6XMyXlOWetmaFgGDS/nu/w9/vUc5g==", + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.4.tgz", + "integrity": "sha512-D98dm4cQ3Hs6EmjK500TdAOew4Z03EV71ajEFiWra3Upr7diytJsjF4mPV2dW+eK5uNectiRj0xFxYI9NLXDbw==", "license": "MIT", "dependencies": { "@types/markdown-it": "^14.0.0", @@ -229,25 +215,14 @@ } }, "node_modules/@atlaskit/adf-utils/node_modules/prosemirror-transform": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.10.5.tgz", - "integrity": "sha512-RPDQCxIDhIBb1o36xxwsaeAvivO8VLJcgBtzmOwQ64bMtsVFh5SSuJ6dWSxO1UsHTiTXPCgQm3PDJt7p6IOLbw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.11.0.tgz", + "integrity": "sha512-4I7Ce4KpygXb9bkiPS3hTEk4dSHorfRw8uI0pE8IhxlK2GXsqv5tIA7JUSxtSu7u8APVOTtbUBxTmnHIxVkIJw==", "license": "MIT", "dependencies": { "prosemirror-model": "^1.21.0" } }, - "node_modules/@atlaskit/adf-utils/node_modules/prosemirror-view": { - "version": "1.41.5", - "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.5.tgz", - "integrity": "sha512-UDQbIPnDrjE8tqUBbPmCOZgtd75htE6W3r0JCmY9bL6W1iemDM37MZEKC49d+tdQ0v/CKx4gjxLoLsfkD2NiZA==", - "license": "MIT", - "dependencies": { - "prosemirror-model": "^1.20.0", - "prosemirror-state": "^1.0.0", - "prosemirror-transform": "^1.1.0" - } - }, "node_modules/@atlaskit/adf-utils/node_modules/react": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", @@ -261,706 +236,715 @@ "node": ">=0.10.0" } }, - "node_modules/@atlaskit/adf-utils/node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", - "license": "MIT", - "bin": { - "uuid": "bin/uuid" + "node_modules/@atlaskit/app-provider": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/app-provider/-/app-provider-8.3.0.tgz", + "integrity": "sha512-NQ+W5m66lwANfFzVVWaEghBzG8BxdEK9dAyUlWCYU6nO1DEnPMQy6h9uHpuTxb845Cb3ocdmBRZQKjtjDX4byw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.9.0", + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@atlaskit/atlassian-context": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@atlaskit/atlassian-context/-/atlassian-context-0.11.0.tgz", - "integrity": "sha512-Q2iMFa6A3OPruD9GQS+quqHWM5Rh+Ew1bP4MxL2BoJV5QulT66K77fq8c86+g+MRqxeqtZ6jnT5zNw6IVrnpMw==", + "node_modules/@atlaskit/app-provider/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.0.0" }, "peerDependencies": { - "react": "^18.2.0 || ^19.0.0" + "react": "^18.2.0" } }, - "node_modules/@atlaskit/ds-lib": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@atlaskit/ds-lib/-/ds-lib-7.0.0.tgz", - "integrity": "sha512-Uqywr6YMi6uBpD0BtbRmG8f81fteRT7NBf62J8zzWPSs7u3Jq9G3Oruwm3y+57Dxv6IqfRwrS10WJARlCJdBLw==", + "node_modules/@atlaskit/atlassian-context": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/atlassian-context/-/atlassian-context-2.0.0.tgz", + "integrity": "sha512-RfdonD91GCqMo6a4nZlg3ZkKrHV4OcEkxVe/4J0aPkLk4R0rRZfcckvQxv0hou3JziNibIv4ou9naK6bt/Y09g==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.0.0", - "bind-event-listener": "^3.0.0", - "tiny-invariant": "^1.2.0" + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@atlaskit/editor-prosemirror": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-9.0.2.tgz", - "integrity": "sha512-Hn5atRMHJDQFz1U6PbzK50LRt/rEHbwvvNm49n6zIVV1464GfVuoGFtK0sHXPKi2LE1k8HNyyEjOAjLQUsoifw==", + "node_modules/@atlaskit/avatar": { + "version": "31.0.5", + "resolved": "https://registry.npmjs.org/@atlaskit/avatar/-/avatar-31.0.5.tgz", + "integrity": "sha512-G+HKT9AFim+b89wqbvqHQ3qRFi7mjpNDIEYOUS63HhOqqObvZ1UOQDy0Vkci3vCYfXu1x/q1f3I/AF3AvOPikA==", "license": "Apache-2.0", "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/platform-feature-experiments": "^0.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popup": "^11.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "prosemirror-commands": "1.7.1", - "prosemirror-dropcursor": "1.8.2", - "prosemirror-history": "1.5.0", - "prosemirror-keymap": "1.2.3", - "prosemirror-markdown": "1.13.4", - "prosemirror-model": "1.25.4", - "prosemirror-state": "1.4.4", - "prosemirror-transform": "1.11.0", - "prosemirror-utils": "1.2.2", - "prosemirror-view": "1.41.7" + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@atlaskit/feature-gate-js-client": { - "version": "4.26.5", - "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-4.26.5.tgz", - "integrity": "sha512-ZCcw7GP6WapqfP18Hr4q5+AZuI1k6pJECL9tyIw64JwG0GntMa3tTj/T8c5aqBIOagRQTw24lkM+Nt+agrRcnA==", + "node_modules/@atlaskit/avatar/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/atlassian-context": "^0.2.0", + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@statsig/client-core": "^3.10.0", - "@statsig/js-client": "^3.10.0", - "eventemitter2": "^4.1.0" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@atlaskit/feature-gate-js-client/node_modules/@atlaskit/atlassian-context": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@atlaskit/atlassian-context/-/atlassian-context-0.2.0.tgz", - "integrity": "sha512-msLRSp0qck6eflkShplgyIoOogNKxKRc6QIWGQlSvKGxHQNEbLEkRGcDzdh8PuBxSs1gda7OqYrdtQYQiPbpTQ==", + "node_modules/@atlaskit/avatar/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.0.0" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0" } }, - "node_modules/@atlaskit/feature-gate-js-client/node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "node_modules/@atlaskit/avatar/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", "license": "MIT", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@atlaskit/platform-feature-flags": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags/-/platform-feature-flags-1.1.3.tgz", - "integrity": "sha512-dRn6UvVmMF5+WXnv7ZlxKTV2rVQncI2TgM0KTGSqpHdD9LnogITWC/rFjzUuF/W8MBCEvpouGilukqhq6rASnw==", + "node_modules/@atlaskit/avatar/node_modules/@atlaskit/platform-feature-experiments": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-experiments/-/platform-feature-experiments-0.3.2.tgz", + "integrity": "sha512-EdFY3b6muB7y1KyyZ+d2ovIFzW/ubc8Qw2oio/zfh6VhRHQ4tmCIX77CgFYURgbhtwu5THTyADE5N2OvMmtcFA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/feature-gate-js-client": "^5.5.0", + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/react-ufo": "^8.3.0", "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" } }, - "node_modules/@atlaskit/platform-feature-flags/node_modules/@atlaskit/feature-gate-js-client": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-5.8.0.tgz", - "integrity": "sha512-SJ+U0EVPdAXHy8Ge7I1BT7bptUiCG11x2XVwqRqZ5ysbR9WsfuUfX4l5BchAqyogJrcrt0v8TC1IBmcQ0WeEUA==", + "node_modules/@atlaskit/avatar/node_modules/@atlaskit/platform-feature-experiments/node_modules/@atlaskit/react-ufo": { + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/@atlaskit/react-ufo/-/react-ufo-8.9.1.tgz", + "integrity": "sha512-xqT6rlxEkQLXkhhz7JzUaTmQCRvHdTSdfQ5TEF2/pl9MTH+qGAP+kpHW1Zs3UzbXjDSw/OhQpF+lQsE1UQ8AZw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/atlassian-context": "^0.11.0", + "@atlaskit/atlassian-context": "^2.0.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/interaction-context": "^4.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@statsig/client-core": "^3.27.0", - "@statsig/js-client": "^3.27.0", - "eventemitter3": "^4.0.0" + "@opentelemetry/api": "^1.9.0", + "bind-event-listener": "^3.0.0", + "bowser-ultralight": "^1.0.6", + "uuid": "^11.1.1" + }, + "peerDependencies": { + "react": "^18.2.0" } }, - "node_modules/@atlaskit/pragmatic-drag-and-drop": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop/-/pragmatic-drag-and-drop-1.8.1.tgz", - "integrity": "sha512-uXWNPpL8n4OmTVbduH7nq8pk8htqGo/prR5cYEE8sVCPJGAUMWn6lzvWTfI+4VCeQvHiDRODVz4YzH06OVAxhw==", + "node_modules/@atlaskit/avatar/node_modules/@atlaskit/platform-feature-experiments/node_modules/@atlaskit/react-ufo/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.0.0", - "bind-event-listener": "^3.0.0", - "raf-schd": "^4.0.3" + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" } }, - "node_modules/@atlaskit/pragmatic-drag-and-drop-hitbox": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-hitbox/-/pragmatic-drag-and-drop-hitbox-1.2.0.tgz", - "integrity": "sha512-eWJvvuHZOC4Yk+Li7QpS+JM2F/I50/3PhMvEcyvcHbXI0FP0kCDD1MiF8Hv7uSOxpk5JNqKoOmK8e1ncOzTgqA==", + "node_modules/@atlaskit/avatar/node_modules/@atlaskit/platform-feature-experiments/node_modules/@atlaskit/react-ufo/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" } }, - "node_modules/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll/-/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll-2.0.2.tgz", - "integrity": "sha512-lo4x9p7DAq3WeCknHXqkCNmzSMvyKfucl1BFF6K22BjdiRd+DavBwt4aGUQBGnIPGwZgNKrjmwAFj9xuYdLZDQ==", + "node_modules/@atlaskit/badge": { + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/badge/-/badge-22.0.1.tgz", + "integrity": "sha512-oYx8ucgxJEqlLTFUb+GjXLOpCIHJb9i3agNTmMCH4duG1o8pcVgmHrBdK2yfAUOK5nRCNf99e3NaoiCHrihSpg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/pragmatic-drag-and-drop": "^1.7.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "css-box-model": "^1.2.0" + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": { - "version": "3.2.16", - "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/-/pragmatic-drag-and-drop-react-drop-indicator-3.2.16.tgz", - "integrity": "sha512-A2rcb6cqBFlGFR0cVwAwZKcSqUaYviNLskfBLI6wvDUFD2/dYI7GN56SOC895YC7EMoG/tPHkDB5vZiLa/iyQA==", + "node_modules/@atlaskit/banner": { + "version": "15.3.5", + "resolved": "https://registry.npmjs.org/@atlaskit/banner/-/banner-15.3.5.tgz", + "integrity": "sha512-sDQvl6Q1+xndpYem0KbXoBd/ZRiWCjkSiFOlVnQOJXrMKrj+tldI9htWXmbqC8sOTDB3kjPq+gO01Q5/BxJAGg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", - "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@atlaskit/tokens": { - "version": "13.4.0", - "resolved": "https://registry.npmjs.org/@atlaskit/tokens/-/tokens-13.4.0.tgz", - "integrity": "sha512-KtVQEwCa3boPmHSGnN0e0eKX9kkxXYFfKjkeex3NZAHju5h6iuDNBCk5MCX+uSu+2cnMRTIh1Trqj1OycoO8gQ==", + "node_modules/@atlaskit/blanket": { + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@atlaskit/blanket/-/blanket-16.4.6.tgz", + "integrity": "sha512-lhgDKHoxbW4PeohXguMa0tm3+JvCJox6rp92pybxTwfS4khFmz3kzXmRxZdH7NXgw0Hhn18zB9FfzcwYT92sVw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.14.0", "@babel/runtime": "^7.0.0", - "@babel/traverse": "^7.23.2", - "@babel/types": "^7.20.0", - "bind-event-listener": "^3.0.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@atlaskit/top-layer": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@atlaskit/top-layer/-/top-layer-0.18.0.tgz", - "integrity": "sha512-l3Um9ACdf6UjD0apuvkNZhyDDADr+QH0aD9ilT2wMDfuAxFc0rbQLekDKeXTPPewX5LEGQm0DrTt16U8JQtmog==", + "node_modules/@atlaskit/blanket/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/browser-apis": "^0.0.2", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/tokens": "^13.4.0", + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "bind-event-listener": "^3.0.0", - "raf-schd": "^4.0.3" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { - "react": "^18.2.0 || ^19.0.0", - "react-dom": "^18.2.0 || ^19.0.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@atlaskit/top-layer/node_modules/@atlaskit/browser-apis": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-0.0.2.tgz", - "integrity": "sha512-3mfBAVBx8ReUlILUGdsc+G1JlrA0DvFAbOMorJfsIvsOqJViABxjQyW05psbnLoLZD/CT3+9jCHSHOIY8Gwtyw==", + "node_modules/@atlaskit/blanket/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.0.0" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/blanket/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@atlaskit/top-layer/node_modules/@atlaskit/css": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@atlaskit/css/-/css-0.19.4.tgz", - "integrity": "sha512-OBacSDD/XBkuu4R2FFMgOoVifSbs7E4LRwqUJFolPurxnsc88/cDrwf9C3obMwDh+64O3a5OyzuUPLVQTfMXYQ==", + "node_modules/@atlaskit/breadcrumbs": { + "version": "17.8.9", + "resolved": "https://registry.npmjs.org/@atlaskit/breadcrumbs/-/breadcrumbs-17.8.9.tgz", + "integrity": "sha512-9I7eUoxuCpp4f+KjMiiXXEbC0Xz5j5ByUiFNbAS5uMn/qHrqnw4Vwc0sal3pzzZNkMOV2FCdMWgra4MbsUp++A==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/dropdown-menu": "^22.2.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/skeleton": "^4.4.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/tooltip": "^24.4.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" } }, - "node_modules/@atlaskit/top-layer/node_modules/@atlaskit/layering": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@atlaskit/layering/-/layering-3.8.0.tgz", - "integrity": "sha512-PmwwvOuj2VhHU+LLsAwFl2VptWNn1aSuSoTXwsC0ZedV4M2WDr0yn0Z3ex0JGq7Za+6VOZsVhiBVW2jXW9a+0A==", + "node_modules/@atlaskit/breadcrumbs/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "bind-event-listener": "^3.0.0", - "tiny-invariant": "^1.2.0" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@babel/code-frame": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.17.tgz", - "integrity": "sha512-IdlVpcDeoDATtN2cfmnVk0A4XJKhu7SlpGuSaiOFdko09YC1MD07WokWUSEdw5R2o4o8VObX2LzViQW6VXnzkA==", - "license": "MIT", + "node_modules/@atlaskit/breadcrumbs/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", "dependencies": { - "@babel/helper-validator-identifier": "^7.29.17", - "js-tokens": "^4.0.0", - "picocolors": "^1.1.1" + "tslib": "^2.0.0" }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "react": "^16.8.0" } }, - "node_modules/@babel/generator": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.17.tgz", - "integrity": "sha512-xjNUVINWex7s4U0vESYwa8ChCBnmvhCQ6nkAdnhM8WYPlhXvU9D9fPurOSYQLV4FwcNXacDkN/MWIPNHsTI2OA==", + "node_modules/@atlaskit/breadcrumbs/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", "license": "MIT", - "dependencies": { - "@babel/parser": "^7.29.17", - "@babel/types": "^7.29.17", - "@jridgewell/gen-mapping": "^0.3.12", - "@jridgewell/trace-mapping": "^0.3.28", - "jsesc": "^3.0.2" - }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@babel/helper-globals": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.17.tgz", - "integrity": "sha512-SeQUwFlH8hH1vjUmBFeqwxt6Nsjp01MKEZOtZPJ86lpA4GBdb/o0dShjC+Awf7v74/+84KIL1RiJ4TOJj6gU+A==", - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.17.tgz", - "integrity": "sha512-bLxkfvUEHeWShbadKTm7EfDCkosXZh6PjWEa9bYiCuob24c0nm388ara2Hz6KisGaXe+XCsi6VyfJNSJjeUUwg==", - "license": "MIT", + "node_modules/@atlaskit/breadcrumbs/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", + "license": "Apache-2.0", "dependencies": { - "@babel/traverse": "^7.29.17", - "@babel/types": "^7.29.17" + "@babel/runtime": "^7.0.0" }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "react": "^18.2.0" } }, - "node_modules/@babel/helper-string-parser": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.17.tgz", - "integrity": "sha512-iY5lvqFhfgMXp4o4zWads4NvQZXizBxzCoADPOgFMcMwk1XefAdBJbc9i1y94aflY57lokjOjRTa3AOOW9R7BQ==", - "license": "MIT", - "engines": { - "node": ">=6.9.0" + "node_modules/@atlaskit/button": { + "version": "25.8.6", + "resolved": "https://registry.npmjs.org/@atlaskit/button/-/button-25.8.6.tgz", + "integrity": "sha512-NR1za1PincLDkKSMnfysS3DnY5EK2gXWfqZQBXprHKgZ0n39NYT/1PzYtVmn24k7pnz0lctZRbhdju4WrzFT+g==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/focus-ring": "^6.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/interaction-context": "^4.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/tooltip": "^24.4.0", + "@atlaskit/visually-hidden": "^4.4.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0", + "@emotion/react": "^11.7.1" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.17.tgz", - "integrity": "sha512-AG+olLB+teKhkQ2WYJeaZqJwNLjtWTz1waQIP/tEYITzVzpdHLP7IXx2c/bH2JTsNCgvWlkqdCv91xcb8lul8Q==", - "license": "MIT", - "engines": { - "node": ">=6.9.0" + "node_modules/@atlaskit/button/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@babel/parser": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.17.tgz", - "integrity": "sha512-I+0olVqWMm9bimQJc/5B3jn1nivNDXtnMtDVs07XdHzZLcWa2N/mlCTPmAsQg95QcKoXSuFD2Yz4fwdtoyk7DQ==", - "license": "MIT", + "node_modules/@atlaskit/button/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", "dependencies": { - "@babel/types": "^7.29.17" - }, - "bin": { - "parser": "bin/babel-parser.js" + "tslib": "^2.0.0" }, - "engines": { - "node": ">=6.0.0" + "peerDependencies": { + "react": "^16.8.0" } }, - "node_modules/@babel/runtime": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.17.tgz", - "integrity": "sha512-CvlZdpED5dsu21yK0DfpXksJWt1zeW09lY49hp7P9cA5Qedx/QkwEs1PfluSJjijH9i94oT9LmtgGWlPY8ISzw==", + "node_modules/@atlaskit/button/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", "license": "MIT", - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@babel/template": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.17.tgz", - "integrity": "sha512-D4nOLKOzIBwn7/Z78h3UPEwzFObmPVTukBJ9+63BijgMVeLj6mQ77FJb6YCZ4QBo6VjAk/yj4QnpKusTcBy6vA==", - "license": "MIT", + "node_modules/@atlaskit/button/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", + "license": "Apache-2.0", "dependencies": { - "@babel/code-frame": "^7.29.17", - "@babel/parser": "^7.29.17", - "@babel/types": "^7.29.17" + "@babel/runtime": "^7.0.0" }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "react": "^18.2.0" } }, - "node_modules/@babel/traverse": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.17.tgz", - "integrity": "sha512-q+CnfQcmNfDdOUARkt9FWtdR0HPOCcyQBj1Z7l2SOpFIfUB/XI3dXS0B5UOlZWwQCun80xVhgcv4ip6w128u9g==", - "license": "MIT", + "node_modules/@atlaskit/calendar": { + "version": "19.6.2", + "resolved": "https://registry.npmjs.org/@atlaskit/calendar/-/calendar-19.6.2.tgz", + "integrity": "sha512-fC1UoySAWYtTZMQY4CT068vkYoA1C2067YkCVrEH3F9U9GemChtc1fjm3FyXLCT8U33oJBCLE0S9Vbvj1U65dg==", + "license": "Apache-2.0", "dependencies": { - "@babel/code-frame": "^7.29.17", - "@babel/generator": "^7.29.17", - "@babel/helper-globals": "^7.29.17", - "@babel/parser": "^7.29.17", - "@babel/template": "^7.29.17", - "@babel/types": "^7.29.17", - "debug": "^4.3.1" + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/heading": "^8.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/locale": "^5.5.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0", + "date-fns": "^2.17.0" }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@babel/types": { - "version": "7.29.17", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.17.tgz", - "integrity": "sha512-kzo3lZUbI0gARA4QvhmOTH/aws2SrZ880ECQRIjPPSrdfBM0bZCkj1U7UN2fB0GNeXayqCiLVXa2+1jAhn377Q==", - "license": "MIT", + "node_modules/@atlaskit/calendar/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", "dependencies": { - "@babel/helper-string-parser": "^7.29.17", - "@babel/helper-validator-identifier": "^7.29.17" + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@compiled/react": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@compiled/react/-/react-0.20.0.tgz", - "integrity": "sha512-mEJuYGFxIDST1H7CpksyE6a3HRVRQmeDal26O+bCHTEZlPp7iKvs5KD1FOmd2palng+S60dPFFG+UuoZDRILwA==", + "node_modules/@atlaskit/calendar/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "csstype": "^3.2.3" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": ">=18.0.0" + "react": "^16.8.0" } }, - "node_modules/@emotion/babel-plugin": { - "version": "11.13.5", - "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.13.5.tgz", - "integrity": "sha512-pxHCpT2ex+0q+HH91/zsdHkw/lXd468DIN2zvfvLtPKLLMo6gQj7oLObq8PhkrxOZb/gGCq03S3Z7PDhS8pduQ==", + "node_modules/@atlaskit/calendar/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", "license": "MIT", - "dependencies": { - "@babel/helper-module-imports": "^7.16.7", - "@babel/runtime": "^7.18.3", - "@emotion/hash": "^0.9.2", - "@emotion/memoize": "^0.9.0", - "@emotion/serialize": "^1.3.3", - "babel-plugin-macros": "^3.1.0", - "convert-source-map": "^1.5.0", - "escape-string-regexp": "^4.0.0", - "find-root": "^1.1.0", - "source-map": "^0.5.7", - "stylis": "4.2.0" + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@emotion/babel-plugin/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "license": "MIT", - "engines": { - "node": ">=10" + "node_modules/@atlaskit/comment": { + "version": "14.2.7", + "resolved": "https://registry.npmjs.org/@atlaskit/comment/-/comment-14.2.7.tgz", + "integrity": "sha512-XvLF54mbaR8/SXQBQtf/D3aWp/e8GuJYx2n4/W+mS4xfmx931iUwhYv8SNNAS3v926nsGKvjvbRE3Kfkt4mHBQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/lozenge": "^17.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@emotion/cache": { - "version": "11.14.0", - "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.14.0.tgz", - "integrity": "sha512-L/B1lc/TViYk4DcpGxtAVbx0ZyiKM5ktoIyafGkH6zg/tj+mA+NE//aPYKG0k8kCHSHVJrpLpcAlOBEXQ3SavA==", - "license": "MIT", + "node_modules/@atlaskit/comment/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", "dependencies": { - "@emotion/memoize": "^0.9.0", - "@emotion/sheet": "^1.4.0", - "@emotion/utils": "^1.4.2", - "@emotion/weak-memoize": "^0.4.0", - "stylis": "4.2.0" + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@emotion/hash": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.2.tgz", - "integrity": "sha512-MyqliTZGuOm3+5ZRSaaBGP3USLw6+EGykkwZns2EPC5g8jJ4z9OrdZY9apkl3+UP9+sdz76YYkwCKP5gh8iY3g==", - "license": "MIT" - }, - "node_modules/@emotion/memoize": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.9.0.tgz", - "integrity": "sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ==", - "license": "MIT" - }, - "node_modules/@emotion/react": { - "version": "11.14.0", - "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.14.0.tgz", - "integrity": "sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==", - "license": "MIT", + "node_modules/@atlaskit/comment/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.13.5", - "@emotion/cache": "^11.14.0", - "@emotion/serialize": "^1.3.3", - "@emotion/use-insertion-effect-with-fallbacks": "^1.2.0", - "@emotion/utils": "^1.4.2", - "@emotion/weak-memoize": "^0.4.0", - "hoist-non-react-statics": "^3.3.1" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } + "react": "^16.8.0" } }, - "node_modules/@emotion/serialize": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.3.3.tgz", - "integrity": "sha512-EISGqt7sSNWHGI76hC7x1CksiXPahbxEOrC5RjmFRJTqLyEK9/9hZvBbiYn70dw4wuwMKiEMCUlR6ZXTSWQqxA==", + "node_modules/@atlaskit/comment/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/css": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/@atlaskit/css/-/css-1.1.10.tgz", + "integrity": "sha512-IXn/G0aoelqH4CV8wGvQb5ar0XsszWKAIQ5cq04K9TPux2VtRV/75so19z89bPBGYS6IniJ0xlNLYXp4SyMOnQ==", + "license": "Apache-2.0", "dependencies": { - "@emotion/hash": "^0.9.2", - "@emotion/memoize": "^0.9.0", - "@emotion/unitless": "^0.10.0", - "@emotion/utils": "^1.4.2", - "csstype": "^3.0.2" + "@atlaskit/tokens": "^20.14.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@emotion/sheet": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.4.0.tgz", - "integrity": "sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg==", - "license": "MIT" - }, - "node_modules/@emotion/unitless": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.10.0.tgz", - "integrity": "sha512-dFoMUuQA20zvtVTuxZww6OHoJYgrzfKM1t52mVySDJnMSEa08ruEvdYQbhvyu6soU+NeLVd3yKfTfT0NeV6qGg==", - "license": "MIT" - }, - "node_modules/@emotion/use-insertion-effect-with-fallbacks": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.2.0.tgz", - "integrity": "sha512-yJMtVdH59sxi/aVJBpk9FQq+OR8ll5GT8oWd57UpeaKEVGab41JWaCFA7FRLoMLloOZF/c/wsPoe+bfGmRKgDg==", - "license": "MIT", - "peerDependencies": { - "react": ">=16.8.0" - } - }, - "node_modules/@emotion/utils": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.4.2.tgz", - "integrity": "sha512-3vLclRofFziIa3J2wDh9jjbkUz9qk5Vi3IZ/FSTKViB0k+ef0fPV7dYrUIugbgupYDx7v9ud/SjrtEP8Y4xLoA==", - "license": "MIT" - }, - "node_modules/@emotion/weak-memoize": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.4.0.tgz", - "integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==", - "license": "MIT" - }, - "node_modules/@floating-ui/core": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz", - "integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==", - "license": "MIT", - "dependencies": { - "@floating-ui/utils": "^0.2.12" - } - }, - "node_modules/@floating-ui/dom": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz", - "integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==", - "license": "MIT", - "dependencies": { - "@floating-ui/core": "^1.8.0", - "@floating-ui/utils": "^0.2.12" - } - }, - "node_modules/@floating-ui/utils": { - "version": "0.2.12", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz", - "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", - "license": "MIT" - }, - "node_modules/@forge/api": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/@forge/api/-/api-7.2.2.tgz", - "integrity": "sha512-q0TwkgzZqEbB1NNetQ9xRvNH6ICaX71QH884tduRzps+qnjuJYh0lJHKKxtwWMfZFdiILNRayhyAlvvuMskH3Q==", - "license": "SEE LICENSE IN LICENSE.txt", - "dependencies": { - "@forge/auth": "0.0.9", - "@forge/egress": "2.3.2", - "@forge/i18n": "0.0.7", - "@forge/manifest": "^12.9.0", - "@forge/storage": "2.0.3", - "headers-utils": "^3.0.2" - } - }, - "node_modules/@forge/auth": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/@forge/auth/-/auth-0.0.9.tgz", - "integrity": "sha512-3qZZNknFprzDkrXzBVKHqVD12r/b2K9cu/RJh9TP3QLiF18v7bdoD1fgZZbVavKJUmCNdQERk6NTVQLmmEszhg==", - "license": "SEE LICENSE IN LICENSE.txt", - "dependencies": { - "tslib": "^2.6.2" - } - }, - "node_modules/@forge/bridge": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/@forge/bridge/-/bridge-5.17.0.tgz", - "integrity": "sha512-f8uLJiHR2QY/kXrTvRDOrvJCh3RLlmDmyn/IXC5Xk7hIquH/F783ZyYwrsOyyxy/QkdQh3I8Hkgrmdul+AQZeA==", - "license": "SEE LICENSE IN LICENSE.txt", + "node_modules/@atlaskit/css/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", "dependencies": { - "@atlaskit/adf-schema": "^48.0.0", - "@atlaskit/tokens": "^1.58.0", - "@forge/egress": "^2.3.2", - "@forge/i18n": "0.0.7", - "@forge/manifest": "12.9.0", - "@forge/resolver": "1.8.0", - "@types/history": "^4.7.11", - "@types/iframe-resizer": "^3.5.8", - "iframe-resizer": "^4.4.5" + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" } }, - "node_modules/@forge/bridge/node_modules/@atlaskit/ds-lib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@atlaskit/ds-lib/-/ds-lib-2.7.0.tgz", - "integrity": "sha512-+U4aPE2dBRFUBYWCM9vkrwJGrLAYVcK30ZpEiQDNpM2D7K41223TfEijC8azaN4VM3tsCgwSKBWwniloNxqYbA==", + "node_modules/@atlaskit/datetime-picker": { + "version": "19.5.7", + "resolved": "https://registry.npmjs.org/@atlaskit/datetime-picker/-/datetime-picker-19.5.7.tgz", + "integrity": "sha512-mzPnrE1R03BO2tppoH/qLqiWPHAW5Z4JMXHwvA370moMVyXWbkNV3yuta15x/Pqq/EsLqLlPcgbiiqUs/UCXcA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/platform-feature-flags": "^0.3.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/calendar": "^19.6.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/locale": "^5.5.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popper": "^9.4.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/react-select": "^4.13.0", + "@atlaskit/select": "^23.3.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.3.0", "@babel/runtime": "^7.0.0", - "bind-event-listener": "^3.0.0", - "react-uid": "^2.2.0" + "@compiled/react": "^2.0.0", + "date-fns": "^2.17.0" }, "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/bridge/node_modules/@atlaskit/platform-feature-flags": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags/-/platform-feature-flags-0.3.0.tgz", - "integrity": "sha512-/0u5fFJ0Rw2j4M5wzsXgaHO6Ey12oekPCDTRvmmAIp4GO9T2Swbl80bavLAPSOmSHMhHTSuvRxiJveZXfQ21IQ==", + "node_modules/@atlaskit/datetime-picker/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.0.0" + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@forge/bridge/node_modules/@atlaskit/tokens": { - "version": "1.61.0", - "resolved": "https://registry.npmjs.org/@atlaskit/tokens/-/tokens-1.61.0.tgz", - "integrity": "sha512-gRkBDZOaQffJHg9g+hYFgPjQ0Hz4XIDaK5WEttIGyhi2USsGsvDvUeED8liqcQNwssH/5UFxIFp3FmEwo0DoFA==", + "node_modules/@atlaskit/datetime-picker/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/ds-lib": "^2.6.0", - "@atlaskit/platform-feature-flags": "^0.3.0", - "@babel/runtime": "^7.0.0", - "@babel/traverse": "^7.23.2", - "@babel/types": "^7.20.0", - "bind-event-listener": "^3.0.0" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + "react": "^16.8.0" } }, - "node_modules/@forge/bridge/node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "node_modules/@atlaskit/datetime-picker/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", "license": "MIT", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/egress": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@forge/egress/-/egress-2.3.2.tgz", - "integrity": "sha512-p8ioX4qnAlRFln+hyH9kO0MmVCSOUg0bsIG9RAYK8KM2YaJb6EnKqbCvPMBTwegiua3vixBsnZmWDgPegSZh9Q==", - "license": "SEE LICENSE IN LICENSE.txt" - }, - "node_modules/@forge/i18n": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/@forge/i18n/-/i18n-0.0.7.tgz", - "integrity": "sha512-EKrQApcuI4k4AkUSeERkZv1dQaGjWsmB8i7ciDPtpDARPRH1sOrU+FSEOoA7b9FQ15++7Q144m94w/aMLCg5Gg==", - "license": "SEE LICENSE IN LICENSE.txt", + "node_modules/@atlaskit/dropdown-menu": { + "version": "22.2.11", + "resolved": "https://registry.npmjs.org/@atlaskit/dropdown-menu/-/dropdown-menu-22.2.11.tgz", + "integrity": "sha512-34lZ5FpZvlN7jCsO4NbImDDXnPy0UZoImnMgRAO8EQ1Pv7Fws/6TgxjV+ejrd42y/fajvM7P9fgnia44ZFmDPg==", + "license": "Apache-2.0", "dependencies": { - "lodash": "^4.17.21" + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/menu": "^11.2.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popup": "^11.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.3.0", + "@atlaskit/visually-hidden": "^4.4.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/manifest": { - "version": "12.9.0", - "resolved": "https://registry.npmjs.org/@forge/manifest/-/manifest-12.9.0.tgz", - "integrity": "sha512-7JZiXpAHa5SNSM4DsmaO1PfgZtHngKKwh1++RoYCS1QDuck1sJ2KXh3dq7FV+ajOKVtI54uyukUb7oYMGp7rPw==", - "license": "SEE LICENSE IN LICENSE.txt", + "node_modules/@atlaskit/ds-lib": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/ds-lib/-/ds-lib-9.0.0.tgz", + "integrity": "sha512-28xHAlZsqZu2Oto7CXQVcBMyp76Jfe7Vjn3GCEzH8BlviQLzVEgy8ylZ+Lxatx3JglqtWrNIskqQ7wWT6B85GA==", + "license": "Apache-2.0", "dependencies": { - "@forge/i18n": "0.0.7", - "@sentry/node": "7.106.0", - "ajv": "^8.18.0", - "ajv-formats": "2.1.1", - "cheerio": "^1.1.0", - "glob": "^13.0.0", - "lodash": "^4.17.21", - "mime-types": "^2.1.35", - "yaml": "^2.3.4" + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react": { - "version": "11.17.0", - "resolved": "https://registry.npmjs.org/@forge/react/-/react-11.17.0.tgz", - "integrity": "sha512-78kXJrSf2s2NwXM4qqeJzP1ZOACwZNtssVuv8apjnvrYvNjjs41H8UZKBJMyw1jZk0o9R8Fbuzcjo4rlv+NN7Q==", - "license": "SEE LICENSE IN LICENSE.txt", + "node_modules/@atlaskit/dynamic-table": { + "version": "19.3.10", + "resolved": "https://registry.npmjs.org/@atlaskit/dynamic-table/-/dynamic-table-19.3.10.tgz", + "integrity": "sha512-c2L9WJke1Advcf6hCyAHgd8UGO4IW128vw+CSeEvO9Q/GhkAvPoLg+kaF687OYPU7nYw3vnivsUxaUpFfHGtZA==", + "license": "Apache-2.0", "dependencies": { - "@atlaskit/adf-schema": "^48.0.0", - "@atlaskit/adf-utils": "^19.19.0", - "@atlaskit/forge-react-types": "^1.7.0", - "@forge/bridge": "^5.17.0", - "@forge/egress": "^2.3.2", - "@forge/i18n": "0.0.7", - "@types/react": "^18.2.64", - "@types/react-reconciler": "^0.28.8", - "lodash": "^4.17.21", - "react": "^18.2.0", - "react-hook-form": "7.65.0", - "react-reconciler": "^0.29.0", - "react-test-renderer": "^18.2.0", - "uuid": "^9.0.1" + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/pagination": "^17.3.0", + "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": "^3.5.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/tooltip": "^24.4.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/analytics-next": { - "version": "11.3.0", - "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-11.3.0.tgz", - "integrity": "sha512-UDTl1YSRz7QCFXxTXctgsbVjXMVIIaoyqpH7SAZw2CRjKeTuihljtxBuv0C2EX5hocPS6b2KZKCwA4yEXHWozQ==", + "node_modules/@atlaskit/dynamic-table/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { "@atlaskit/analytics-next-stable-react-context": "1.0.1", - "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", "prop-types": "^15.5.10", "use-memo-one": "^1.1.1" @@ -970,7 +954,7 @@ "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/analytics-next-stable-react-context": { + "node_modules/@atlaskit/dynamic-table/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", @@ -982,1290 +966,2840 @@ "react": "^16.8.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/app-provider": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@atlaskit/app-provider/-/app-provider-4.3.3.tgz", - "integrity": "sha512-hVOEl1VqwgUGVZOMfQsKIyg3DH7rYh/8qY5BXJuRKqw8Vn3ybexnkyeduQbfCP4rzLUnUUQCVhMxvTZhe+mDOw==", + "node_modules/@atlaskit/dynamic-table/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/editor-prosemirror": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-8.0.3.tgz", + "integrity": "sha512-VU2N4/VhwhXj50wm6CtgVrHyOx6TPtNIHRSL9FpiEu/Rt4TVOgJjr1ul6SmTYclccmNWviFUsa2LR7evKaLZgw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/browser-apis": "^0.0.2", - "@atlaskit/css": "^0.19.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/tokens": "^13.0.0", "@babel/runtime": "^7.0.0", - "bind-event-listener": "^3.0.0" - }, - "peerDependencies": { - "react": "^18.2.0" + "prosemirror-commands": "1.7.1", + "prosemirror-dropcursor": "1.8.2", + "prosemirror-history": "1.5.0", + "prosemirror-keymap": "1.2.3", + "prosemirror-markdown": "1.13.2", + "prosemirror-model": "1.25.4", + "prosemirror-state": "1.4.4", + "prosemirror-transform": "1.10.5", + "prosemirror-utils": "1.2.2", + "prosemirror-view": "1.41.5" } }, - "node_modules/@forge/react/node_modules/@atlaskit/avatar": { - "version": "25.15.1", - "resolved": "https://registry.npmjs.org/@atlaskit/avatar/-/avatar-25.15.1.tgz", - "integrity": "sha512-tWTdjed8UHD/nBC5jBPcoevrNbsHqriM4kmD2Z8OPdPUsy2ouFhbywXqA6Xol0ED7Du8Kd/TbeuUmwMpfn7V7g==", + "node_modules/@atlaskit/feature-gate-js-client": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-8.0.2.tgz", + "integrity": "sha512-gJGPlau67fpXRjXh7rJd3zqE5vq3ZyTKVjRZ7bGFrYKQh2iWtPKT4qzLe3XoLVi/PqiUoKNkMQIl/ooGTr+2Hg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/atlassian-context": "^2.0.0", + "@atlaskit/flag-client": "^1.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" - }, - "peerDependencies": { - "react": "^18.2.0" + "@statsig/client-core": "3.30.2", + "@statsig/js-client": "3.30.2", + "eventemitter3": "^4.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/badge": { - "version": "18.7.1", - "resolved": "https://registry.npmjs.org/@atlaskit/badge/-/badge-18.7.1.tgz", - "integrity": "sha512-H6Ic5ZOXgGEFfNwqnFcxIWzChoJIPUgzXfox2UHcHurBODSQaGFrNXApHMn0Qa+az+yqTmSdRWQOVaIBdZ+99Q==", + "node_modules/@atlaskit/flag-client": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@atlaskit/flag-client/-/flag-client-1.2.2.tgz", + "integrity": "sha512-PcxudIcmJV9qoPzaVo+ew8H673ZNoATs7hbGU6vGur3ZHMiuY0Dy6pDrwZZiJ59MZCKras2A7OuiwVs5XUHUeg==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "hash-wasm": "^4.11.0" + } + }, + "node_modules/@atlaskit/focus-ring": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/focus-ring/-/focus-ring-6.0.0.tgz", + "integrity": "sha512-a+wvgoeB7bD4Oju+wAJmEZfE31ZLZOAhR8acWWO4Kg/y7iJGloEPrdu9tAWq5a8bh/kLsN2IVLh5fEWmz+jTTw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.3.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.0.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@emotion/react": "^11.7.1" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/banner": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/banner/-/banner-14.1.0.tgz", - "integrity": "sha512-tgLEgyl/y/s6Nu+Fcvm/rbpeQDPwAJ6lWaCDO8u2tnTzsLrHTKo2VRMqjLMUAdecaW1LqHTaNxQNWT+U2Nh1+g==", + "node_modules/@atlaskit/form": { + "version": "18.3.5", + "resolved": "https://registry.npmjs.org/@atlaskit/form/-/form-18.3.5.tgz", + "integrity": "sha512-n/CHaSkV4QrUiQIfOoWfjMGnJnNt+1ZYpdpjoY4yyW9KbD0F7cHGgKHPm1Y/C93NBe2qtZ79qGXMlnYCvV6QmQ==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/css": "^0.19.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/heading": "^8.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/visually-hidden": "^4.4.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0", + "final-form": "^4.20.3", + "final-form-focus": "^1.1.2", + "lodash": "^4.17.21" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/blanket": { - "version": "15.0.34", - "resolved": "https://registry.npmjs.org/@atlaskit/blanket/-/blanket-15.0.34.tgz", - "integrity": "sha512-BIO7KYWSL6p6t5AbrTbAtO86XSuuNF+qhm5c0hPv8nkRiAfVQW3WlDXly036oB1Kj/HtP0G6TIre/XXgKlr4yw==", + "node_modules/@atlaskit/heading": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/heading/-/heading-8.0.1.tgz", + "integrity": "sha512-73wHM7N8L5HXJOBy0zaOoDLqXx7LDMcI3/RxxgTjMyXA46fg4Raz8HGi+mGxw/KE6KQFkbRr5Myje2TchSZOPw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/breadcrumbs": { - "version": "16.1.1", - "resolved": "https://registry.npmjs.org/@atlaskit/breadcrumbs/-/breadcrumbs-16.1.1.tgz", - "integrity": "sha512-BkCgqW7CeEDk+rCue1dP2kWPx9PzsRXfp84NJCDaWpDCR28bo+PNpnTHFQoQm5RHIcs3wXWWhHwAlC9X9hjpEQ==", + "node_modules/@atlaskit/icon": { + "version": "38.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/icon/-/icon-38.3.0.tgz", + "integrity": "sha512-fQMM99J4fJQN+zHQ6DEtgrFxYHbP0zXSOOYC15EKIAku84x5Dyb7sCUNm4Pv5J+1dnKpUoSNDC558pymDGlhmA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", - "@atlaskit/tooltip": "^22.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tile": "^5.0.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/browser-apis": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-0.0.2.tgz", - "integrity": "sha512-3mfBAVBx8ReUlILUGdsc+G1JlrA0DvFAbOMorJfsIvsOqJViABxjQyW05psbnLoLZD/CT3+9jCHSHOIY8Gwtyw==", + "node_modules/@atlaskit/icon-lab": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@atlaskit/icon-lab/-/icon-lab-7.14.0.tgz", + "integrity": "sha512-1BCLkZRIBqwCAdWK0bih6SPUbq84Qplqp0L+c13GWQLfQ9fGiv+58k6bqlthVbCNVVbSnLUUm1UWUL8weQCdrw==", "license": "Apache-2.0", "dependencies": { + "@atlaskit/icon": "^38.3.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/button": { - "version": "23.11.8", - "resolved": "https://registry.npmjs.org/@atlaskit/button/-/button-23.11.8.tgz", - "integrity": "sha512-ptEGHRfBLmEigbD2t0PkrZkQxMPtyuS6rtfW6htGQo3c+nilap85qNxZtkdOVfO3oPYTssVnOD663rnbd/CHnA==", - "license": "Apache-2.0", - "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/focus-ring": "^3.1.0", - "@atlaskit/icon": "^35.1.0", - "@atlaskit/interaction-context": "^3.1.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/spinner": "^19.1.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.0.0", - "@atlaskit/tooltip": "^22.3.0", - "@atlaskit/visually-hidden": "^3.1.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "@emotion/react": "^11.7.1" - }, - "peerDependencies": { - "react": "^18.2.0" - } - }, - "node_modules/@forge/react/node_modules/@atlaskit/calendar": { - "version": "17.2.20", - "resolved": "https://registry.npmjs.org/@atlaskit/calendar/-/calendar-17.2.20.tgz", - "integrity": "sha512-xBT7/Kca3b8aA4SLokGq91UlAdbhIEd2biXeWKNCJ6/tO7+UUPm3iIuzG1c5tXyzDY09JoatZt05c7iYWwA0MA==", + "node_modules/@atlaskit/inline-dialog": { + "version": "20.3.12", + "resolved": "https://registry.npmjs.org/@atlaskit/inline-dialog/-/inline-dialog-20.3.12.tgz", + "integrity": "sha512-mSonmO0o5XF+xYfuksnrAl4JSvg/9XOxRjZTG3FaPJDvQuCWkcHuPZsWDXrSiSXBUufgW1mPQpDWIWtWlLl37Q==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/heading": "^5.4.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/locale": "^4.1.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popper": "^9.4.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.14.0", + "@atlaskit/top-layer": "^8.1.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "date-fns": "^2.17.0" + "@compiled/react": "^2.0.0", + "bind-event-listener": "^3.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/comment": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/@atlaskit/comment/-/comment-13.3.1.tgz", - "integrity": "sha512-osYooHPajtJ9+MTTYPRDpVU/EB6yRFbnD9736zTcAOMsff7/9pIFwmH+bnoD8UNc/il2UKJi+se2+ItgKMXt/Q==", + "node_modules/@atlaskit/inline-dialog/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/lozenge": "^13.8.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/css": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@atlaskit/css/-/css-0.19.4.tgz", - "integrity": "sha512-OBacSDD/XBkuu4R2FFMgOoVifSbs7E4LRwqUJFolPurxnsc88/cDrwf9C3obMwDh+64O3a5OyzuUPLVQTfMXYQ==", + "node_modules/@atlaskit/inline-dialog/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/tokens": "^13.0.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/datetime-picker": { - "version": "17.9.6", - "resolved": "https://registry.npmjs.org/@atlaskit/datetime-picker/-/datetime-picker-17.9.6.tgz", - "integrity": "sha512-Jml9iVsZxfxSaQoyjlWMRVb87RQe6VnTt64l7dHLyyMzFTR6RsXj6xxDBtZxpAvfAXduDRs2AhxeeKvcMyfIeA==", - "license": "Apache-2.0", - "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/calendar": "^17.2.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.4.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/locale": "^4.1.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/popper": "^7.2.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/select": "^21.12.0", - "@atlaskit/tokens": "^13.4.0", - "@atlaskit/top-layer": "^0.18.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "date-fns": "^2.17.0" - }, + "node_modules/@atlaskit/inline-dialog/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/dynamic-table": { - "version": "18.4.2", - "resolved": "https://registry.npmjs.org/@atlaskit/dynamic-table/-/dynamic-table-18.4.2.tgz", - "integrity": "sha512-RkiMCuJ6tjhKhU8GYc/n+EyMR7mwF7zTY96bMXcQTwy+sVQufcDzwwwT1NZHOubCPxrNlURcqDpDVhNMEuEDnw==", + "node_modules/@atlaskit/inline-edit": { + "version": "16.7.0", + "resolved": "https://registry.npmjs.org/@atlaskit/inline-edit/-/inline-edit-16.7.0.tgz", + "integrity": "sha512-CHlq/Z/Mly/rcz7lCTEV9q59f0y+ywEuIHmQY1agyzwEYjtcRooRlV6lZyZ3+HOgi1X7QwM95usL0aK9qRgIYA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/pagination": "^16.3.0", - "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": "^2.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/spinner": "^19.1.0", - "@atlaskit/tokens": "^13.0.0", - "@atlaskit/tooltip": "^22.2.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/form": "^18.3.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/inline-dialog": "^20.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popup": "^11.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/textfield": "^11.0.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.3.0", + "@atlaskit/visually-hidden": "^4.4.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/focus-ring": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/focus-ring/-/focus-ring-3.1.0.tgz", - "integrity": "sha512-mrXeeqrV0wVnru59ZfRBG9VitjQA13roEiwU4efOHM/mHGrkWsFiCTdmwJAJklyBddiemUTM08I/+Av+QHHBag==", + "node_modules/@atlaskit/inline-edit/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@emotion/react": "^11.7.1" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/forge-react-types": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@atlaskit/forge-react-types/-/forge-react-types-1.7.1.tgz", - "integrity": "sha512-5u6RhFf7muciYP8/PeAhl2sLoU+QmCdGMkzC0kh9DnmVTs4votj+wUoJunc8gTE/qH2nIgMZIQapwi9QnX3vuQ==", - "dependencies": { - "@atlaskit/banner": "^14.1.0", - "@atlaskit/blanket": "^15.0.0", - "@atlaskit/breadcrumbs": "^16.1.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/comment": "^13.3.0", - "@atlaskit/datetime-picker": "^17.9.0", - "@atlaskit/dynamic-table": "^18.4.0", - "@atlaskit/form": "^15.5.0", - "@atlaskit/inline-edit": "^15.6.0", - "@atlaskit/modal-dialog": "^15.2.0", - "@atlaskit/navigation-system": "^9.4.0", - "@atlaskit/object": "^1.0.0", - "@atlaskit/pagination": "^16.3.0", - "@atlaskit/popup": "^4.23.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/progress-bar": "^4.2.0", - "@atlaskit/progress-tracker": "^10.5.0", - "@atlaskit/radio": "^8.6.0", - "@atlaskit/section-message": "^8.13.0", - "@atlaskit/select": "^21.12.0", - "@atlaskit/skeleton": "^2.1.0", - "@atlaskit/spinner": "^19.1.0", - "@atlaskit/tabs": "^19.1.0", - "@atlaskit/tag": "^14.15.0", - "@atlaskit/tag-group": "^12.1.0", - "@atlaskit/textarea": "^8.3.0", - "@atlaskit/textfield": "^8.3.0", - "@atlaskit/tile": "^1.1.0", - "@atlaskit/toggle": "^16.1.0", - "@atlaskit/tokens": "^13.3.0", - "@atlaskit/tooltip": "^22.6.0", - "@babel/runtime": "^7.0.0", - "@emotion/react": "^11.7.1", - "@emotion/serialize": "^1.1.0" + "node_modules/@atlaskit/inline-edit/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/form": { - "version": "15.5.6", - "resolved": "https://registry.npmjs.org/@atlaskit/form/-/form-15.5.6.tgz", - "integrity": "sha512-ocjHXkvNGUzjlGcwIabxX3SL27zsHD1R3idpATokQXbdELsyYQJuRu70NISEPQUQIIknPKQRm3eqMxlTGWhAtQ==", - "license": "Apache-2.0", - "dependencies": { - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/heading": "^5.4.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", - "@atlaskit/visually-hidden": "^3.1.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "final-form": "^4.20.3", - "final-form-focus": "^1.1.2", - "lodash": "^4.17.21" - }, + "node_modules/@atlaskit/inline-edit/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/heading": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/@atlaskit/heading/-/heading-5.4.2.tgz", - "integrity": "sha512-B4SMRq9sq3WWJYLo8Nx5731LvAjiev6dT3SbK1/dqSM+HXnrAy6GwEhW3oDJefeWYO7eZ9xPfuC3jpjdNBgxoA==", + "node_modules/@atlaskit/layering": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/layering/-/layering-6.1.0.tgz", + "integrity": "sha512-OpVcPXsS4OBYGuJDSuubi1qtOp3aSKi3FK/++/Z49KVFtcRdn0UrTrkz3e+dpI+0FtaI8IV4f6O2ceqCa1T81w==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/icon": { - "version": "35.4.0", - "resolved": "https://registry.npmjs.org/@atlaskit/icon/-/icon-35.4.0.tgz", - "integrity": "sha512-zE8DtQVaPTL3H6OSOwtgDihal0d5As/J3f4W2gzVLn9gOv24sFMlFC/GEEuotyYOFFwS7+NeT2pVqOi2IRv17g==", + "node_modules/@atlaskit/link": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/@atlaskit/link/-/link-5.1.8.tgz", + "integrity": "sha512-7U+jeGAtfnd+D1PhGZl7Pdyk7ZcwVAXRDes6xv8i7R3D4uQxRvQjfCabzHLpBZU0yLFs4pZp/gNsAXV6mbvU1A==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/tile": "^1.1.0", - "@atlaskit/tokens": "^13.1.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/icon-lab": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/@atlaskit/icon-lab/-/icon-lab-6.14.0.tgz", - "integrity": "sha512-Yi9DZMM6siOH3AGDyL+iCsFie07mbMlOtl1bYFG70ta2LensVtfohZIWcm3LWweWL3Xcc4dosRKO8v22xmWg1A==", + "node_modules/@atlaskit/locale": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/@atlaskit/locale/-/locale-5.5.0.tgz", + "integrity": "sha512-CIC/TdVa1gf38KVE//pTe7WKXIw3eeC3eEYrJD2oKJFbTjw7P9pCf8AJHtY59815qaZfVSjcWtu9wMJQjZ6LpA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/icon": "^35.4.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-select": "^4.12.0", + "@atlaskit/select": "^23.1.0", "@babel/runtime": "^7.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/inline-dialog": { - "version": "18.1.14", - "resolved": "https://registry.npmjs.org/@atlaskit/inline-dialog/-/inline-dialog-18.1.14.tgz", - "integrity": "sha512-+qjmwAl3MNH5nzkOfHodz8q32P94EvFf4mMsDftaNimrZpWGDvcuxwXgdaa977jm2xGcixWchiYSK83OAZNGsA==", + "node_modules/@atlaskit/logo": { + "version": "23.3.3", + "resolved": "https://registry.npmjs.org/@atlaskit/logo/-/logo-23.3.3.tgz", + "integrity": "sha512-ITQfprX6Bd0XlqBDYauz3Y/VO4JIw1+PoI5jLQcgKxdXYVGW7UEa+pPyeXUGISaSmkhdxffYYk7UsUrgLt/zGA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/popper": "^7.2.0", - "@atlaskit/tokens": "^13.4.0", - "@atlaskit/top-layer": "^0.18.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.14.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "bind-event-listener": "^3.0.0" + "@compiled/react": "^1.0.2" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/inline-edit": { - "version": "15.6.16", - "resolved": "https://registry.npmjs.org/@atlaskit/inline-edit/-/inline-edit-15.6.16.tgz", - "integrity": "sha512-gnbGq5sx+cy6RY3hsJn1wfiNCmSNRNDA2RvtkU8cuE4weGW1jurjGjnu+JCwtZ7Ry+xhTHkxV1lFF2xwPAZylQ==", + "node_modules/@atlaskit/logo/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/form": "^15.5.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/inline-dialog": "^18.1.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/textfield": "^8.3.0", - "@atlaskit/tokens": "^13.0.0", - "@atlaskit/visually-hidden": "^3.1.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "csstype": "^3.2.3" }, "peerDependencies": { - "react": "^18.2.0" + "react": ">=18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/interaction-context": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-3.1.0.tgz", - "integrity": "sha512-LB3T0ATpJ5y7/IVBndNbcjtaNmPcz/8k7+smMibzphmV7xB3HaIyJFEu2JoSmgps66qLXo0ia8Hj7v4dF9zJZw==", + "node_modules/@atlaskit/lozenge": { + "version": "17.0.12", + "resolved": "https://registry.npmjs.org/@atlaskit/lozenge/-/lozenge-17.0.12.tgz", + "integrity": "sha512-hANIjmZgEFjXd2chJRc1wLIWdH/r44y/4pCVUf7/nGTzWqF+lkkQIHEAJf479fx+T4OlWQFlIfY1TkWsz/pkTA==", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.0.0" + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/badge": "^22.0.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popup": "^11.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/layering": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@atlaskit/layering/-/layering-3.8.0.tgz", - "integrity": "sha512-PmwwvOuj2VhHU+LLsAwFl2VptWNn1aSuSoTXwsC0ZedV4M2WDr0yn0Z3ex0JGq7Za+6VOZsVhiBVW2jXW9a+0A==", + "node_modules/@atlaskit/lozenge/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "bind-event-listener": "^3.0.0", - "tiny-invariant": "^1.2.0" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/link": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/@atlaskit/link/-/link-3.4.2.tgz", - "integrity": "sha512-Y2aItT5nfxQhJu7RzgwKQImMp50aq58M3ccbTuqElnNNK7QHde37Hrvtxpia7WLwvJOpKYmxJnaM9yxbkDsYKQ==", + "node_modules/@atlaskit/lozenge/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/css": "^0.19.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/locale": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/locale/-/locale-4.1.0.tgz", - "integrity": "sha512-8WCpGFK5N5ySol5IooUx8FIwnWe8ykgE/aGp9D22swLrCE3+5IS49seeWfAXGvLV8GtXRoB6L2RtcCpgQEGT5Q==", - "license": "Apache-2.0", - "dependencies": { - "@atlaskit/select": "^21.10.0", - "@babel/runtime": "^7.0.0" - }, + "node_modules/@atlaskit/lozenge/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/logo": { - "version": "20.2.0", - "resolved": "https://registry.npmjs.org/@atlaskit/logo/-/logo-20.2.0.tgz", - "integrity": "sha512-SKxR17k17O95BQCH5B8CW4XNPptJgu60rYg8C6WIAUpYoskC5IRpv6g/OlnuzgmYzg+pEK4w6eH8ntV4EyQ0Ng==", + "node_modules/@atlaskit/menu": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/menu/-/menu-11.2.0.tgz", + "integrity": "sha512-uX3nsZ07F06sMH4pkob/sTCpE3C4AYJBT4X6XuFaxRpOBvTl3IoE+flzw+4PH1OdQiUGXqHTEkjxFAZGDVcVqg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.1.0", + "@atlaskit/app-provider": "^8.3.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/interaction-context": "^4.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/lozenge": { - "version": "13.9.0", - "resolved": "https://registry.npmjs.org/@atlaskit/lozenge/-/lozenge-13.9.0.tgz", - "integrity": "sha512-xj3PncJ8h3qwjCwBqUyPJ6pWEr/J4oM1HOZhYblLHNGQ4DP4Vibaiiu5rJ1RWwcIFfg23oziJb4A4SbxFeZIfQ==", + "node_modules/@atlaskit/menu/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/badge": "^18.7.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.4.0", - "@atlaskit/motion": "^6.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/spinner": "^19.1.0", - "@atlaskit/tokens": "^13.3.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog": { - "version": "15.3.1", - "resolved": "https://registry.npmjs.org/@atlaskit/modal-dialog/-/modal-dialog-15.3.1.tgz", - "integrity": "sha512-H1klgfteq3uTG2Ev4WlbNE2YjABlUJ6pekqOMgk8Zl8x+MNeDRGA9jRuaDr1vFAYZ6xexmGoWkUyXwKgGuil+g==", - "license": "Apache-2.0", - "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/blanket": "^15.0.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.4.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/motion": "^6.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/portal": "^5.5.0", - "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.4.0", - "@atlaskit/top-layer": "^0.18.0", + "node_modules/@atlaskit/modal-dialog": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/@atlaskit/modal-dialog/-/modal-dialog-17.4.2.tgz", + "integrity": "sha512-VzzdbbOFTuYEYwqTfpm7hhMWgPMNoJP3gXFTqeXb57R7RxJfN75deacCqb71kpOPDTy7fhDUgjYPG7ZZ+pbLGw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/blanket": "^16.4.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/portal": "^7.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.3.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", + "@compiled/react": "^2.0.0", "bind-event-listener": "^3.0.0", "raf-schd": "^4.0.3", "react-focus-lock": "^2.9.5", + "react-intl": "^7.0.0", "react-scrolllock": "^5.0.1" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog/node_modules/react-focus-lock": { - "version": "2.13.7", - "resolved": "https://registry.npmjs.org/react-focus-lock/-/react-focus-lock-2.13.7.tgz", - "integrity": "sha512-20lpZHEQrXPb+pp1tzd4ULL6DyO5D2KnR0G69tTDdydrmNhU7pdFmbQUYVyHUgp+xN29IuFR0PVuhOmvaZL9Og==", - "license": "MIT", + "node_modules/@atlaskit/modal-dialog/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "focus-lock": "^1.3.6", - "prop-types": "^15.6.2", - "react-clientside-effect": "^1.2.7", - "use-callback-ref": "^1.3.3", - "use-sidecar": "^1.1.3" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { - "@types/react": "*", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog/node_modules/use-callback-ref": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", - "integrity": "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==", - "license": "MIT", + "node_modules/@atlaskit/modal-dialog/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", "dependencies": { "tslib": "^2.0.0" }, - "engines": { - "node": ">=10" - }, "peerDependencies": { - "@types/react": "*", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } + "react": "^16.8.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/modal-dialog/node_modules/use-sidecar": { + "node_modules/@atlaskit/modal-dialog/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", - "integrity": "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", "license": "MIT", - "dependencies": { - "detect-node-es": "^1.1.0", - "tslib": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, "peerDependencies": { - "@types/react": "*", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/motion": { - "version": "6.2.5", - "resolved": "https://registry.npmjs.org/@atlaskit/motion/-/motion-6.2.5.tgz", - "integrity": "sha512-cYKzj5cS6nxF0lmfxXBRvYmmTys3SAYkLIl29z6/hFNELs4LpU+13CGtJz/0+lDl7X4Lnt5QWjrCJdoeoACKGA==", + "node_modules/@atlaskit/modal-dialog/node_modules/@atlaskit/portal": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/portal/-/portal-7.1.0.tgz", + "integrity": "sha512-LSwuHoqPJTwOzJJO/XyE95mlSvaQZ33QH5kLY36LaQoNqkSpoOMYQepJ8CeK6ZH7k516WOSISgc3E/3At7YDBA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/browser-apis": "^0.0.2", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/tokens": "^13.1.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "bind-event-listener": "^3.0.0" - }, - "peerDependencies": { - "react": "^18.2.0" - } - }, - "node_modules/@forge/react/node_modules/@atlaskit/navigation-system": { - "version": "9.4.3", - "resolved": "https://registry.npmjs.org/@atlaskit/navigation-system/-/navigation-system-9.4.3.tgz", - "integrity": "sha512-Y8FOgCuRjryYsZhG58gZsEdYPre4F6oKo3OEG3nNlO7oXjjq43Skb3F+irvhlTs49jNNt/uW2VSzIBU/Sw+kBQ==", - "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/app-provider": "^4.3.0", - "@atlaskit/avatar": "^25.15.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.4.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/logo": "^20.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/platform-feature-flags-react": "^0.5.0", - "@atlaskit/popup": "^4.24.0", - "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/side-nav-items": "^1.14.0", - "@atlaskit/tokens": "^13.3.0", - "@atlaskit/tooltip": "^22.6.0", - "@atlaskit/visually-hidden": "^3.1.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "bind-event-listener": "^3.0.0", - "raf-schd": "^4.0.3", - "tiny-invariant": "^1.2.0" + "@atlaskit/app-provider": "^8.2.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/object": { - "version": "1.0.17", - "resolved": "https://registry.npmjs.org/@atlaskit/object/-/object-1.0.17.tgz", - "integrity": "sha512-xM7r+JvcykGUkJ2t+VuN7LLuEnHJt/Go1OcipLkBkJRWq80G+WEFFQXxYyoVK0ejMbcnftLnEuDlZWFUmh9DXg==", + "node_modules/@atlaskit/motion": { + "version": "10.0.4", + "resolved": "https://registry.npmjs.org/@atlaskit/motion/-/motion-10.0.4.tgz", + "integrity": "sha512-jkrgpBYbEfxNNWjc600S7kBJIQhnXWebo4HeOsfZCkBGzDUF94zCLXLtAy3vHZOt4Nm8F45zvV3RAOMdBrHxLQ==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/css": "^0.19.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/icon-lab": "^6.9.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tile": "^1.1.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "tiny-invariant": "^1.2.0" + "@compiled/react": "^2.0.0", + "bind-event-listener": "^3.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/pagination": { - "version": "16.3.1", - "resolved": "https://registry.npmjs.org/@atlaskit/pagination/-/pagination-16.3.1.tgz", - "integrity": "sha512-lAJUAhD0TEKII+5bv6WOb3ysSrXzhmNcQ6JblnqhrkfQ3lKwfvtE3LBu4soj4AqflYoSSZFZ3CGXntnpMgbugQ==", + "node_modules/@atlaskit/motion/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", - "@atlaskit/visually-hidden": "^3.1.0", - "@babel/runtime": "^7.0.0", - "memoize-one": "^6.0.0" + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/platform-feature-flags-react": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags-react/-/platform-feature-flags-react-0.5.1.tgz", - "integrity": "sha512-QAjrPOWFRn+ijGu/uz1MxT/pISNgy9XKH/mnUlcOGk2YsjsLtCiHyY68vKLC0PDxA5IbVtuHOqZYG8Cwfx2k3w==", + "node_modules/@atlaskit/object": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/@atlaskit/object/-/object-2.3.6.tgz", + "integrity": "sha512-828U64XI+KZrCyLHmUZqauaNL+5V0vFS8CN0EOZvElj9pvRe7NM9H2TmGZMUYZABu5sJzvpfDpIBi+X7zwPC8w==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/platform-feature-flags": "^1.1.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/icon-lab": "^7.14.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tile": "^5.0.0", + "@atlaskit/tokens": "^20.15.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "react-magnetic-di": "^3.1.4" + "@compiled/react": "^2.0.0", + "tiny-invariant": "^1.2.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/popper": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@atlaskit/popper/-/popper-7.2.0.tgz", - "integrity": "sha512-Uw2dzPblwwfYxs5VYIKhOCkwG1tSbmw+sALylsdCTXlVqKWHVxaNzZ24RCglol2BO5QUAT+YAZh1jbjgXyH8mQ==", + "node_modules/@atlaskit/pagination": { + "version": "17.3.6", + "resolved": "https://registry.npmjs.org/@atlaskit/pagination/-/pagination-17.3.6.tgz", + "integrity": "sha512-MEckqvj/mNqpfPzJBaweKsTH9A350E9CWged/Q++NC4KeAEzs+nxTmRwv20FfBzf1hEul08vvi/Qyo9E3omGNQ==", "license": "Apache-2.0", "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/visually-hidden": "^4.4.0", "@babel/runtime": "^7.0.0", - "@popperjs/core": "^2.11.8", - "react-popper": "^2.3.0" + "memoize-one": "^6.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0 || ^19.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/popup": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/@atlaskit/popup/-/popup-4.26.0.tgz", - "integrity": "sha512-awJboKQwWe2RpY1uzaHtV4WPPoeKC5xB8U4WLozUsyerq+PNKL2e/AtyUI4Sv1r9Vw55KCQ61Smc45CfhNP7Qg==", + "node_modules/@atlaskit/pagination/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/motion": "^6.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/popper": "^7.2.0", - "@atlaskit/portal": "^5.5.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.4.0", - "@atlaskit/top-layer": "^0.18.0", + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "bind-event-listener": "^3.0.0", - "focus-trap": "^2.4.5", - "memoize-one": "^6.0.0", - "tiny-invariant": "^1.2.0" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/portal": { - "version": "5.5.6", - "resolved": "https://registry.npmjs.org/@atlaskit/portal/-/portal-5.5.6.tgz", - "integrity": "sha512-sB+31TrDA/r6daytYawF1zGJoVG/hbfhosGIu2gKmg/8KM/waNGVYd2HlUPGmhbuFKxT5P+NbIAbOF/zHffnaQ==", + "node_modules/@atlaskit/pagination/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/app-provider": "^4.3.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/theme": "^25.0.0", - "@babel/runtime": "^7.0.0" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^16.8.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration/-/pragmatic-drag-and-drop-react-beautiful-dnd-migration-2.1.1.tgz", - "integrity": "sha512-l/NIcq2VPbYyy78MMCsfuG3EoHynHytoXm6gB6/O42Y1npcDn1SkxAtblAF0vf3aw1G1rx6TioDBI26KvRg0RQ==", + "node_modules/@atlaskit/pagination/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/platform-feature-flags": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags/-/platform-feature-flags-2.2.2.tgz", + "integrity": "sha512-2vVqXpUH2qW2bAAetiT7eOT5gu3cvyg0RNRknTSASlN7hGD3zJc5lcc28GC7f9ayy2DdteRoG7teiSKrinU1jw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", - "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0", - "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^2.0.0", - "@atlaskit/tokens": "^13.0.0", - "@babel/runtime": "^7.0.0", - "@emotion/react": "^11.7.1", - "bind-event-listener": "^3.0.0", - "tiny-invariant": "^1.2.0" - }, - "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@babel/runtime": "^7.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/primitives": { - "version": "19.0.2", - "resolved": "https://registry.npmjs.org/@atlaskit/primitives/-/primitives-19.0.2.tgz", - "integrity": "sha512-vMp2L8NhNeEkDj26GtVeynx8yC//uhfzVgxgI06dpHQ2gTV/jZidaNGOWjXslCrOpfgZckAAG3x2JamT/95XGw==", + "node_modules/@atlaskit/popper": { + "version": "9.4.13", + "resolved": "https://registry.npmjs.org/@atlaskit/popper/-/popper-9.4.13.tgz", + "integrity": "sha512-F7LFx+0P5nQMEP+JYOm6M5DaAehhpJepDXSbet7x0NcoEEJ6dh5gfi8g0jvhMzO3OkYcOQicJqh5sSoZiJqrow==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/app-provider": "^4.3.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/interaction-context": "^3.1.0", - "@atlaskit/tokens": "^13.2.0", - "@atlaskit/visually-hidden": "^3.1.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "@emotion/react": "^11.7.1", - "@emotion/serialize": "^1.1.0", + "@compiled/react": "^2.0.0", + "@popperjs/core": "^2.11.8", "bind-event-listener": "^3.0.0", - "tiny-invariant": "^1.2.0" + "react-popper": "^2.3.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/popper/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/progress-bar": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@atlaskit/progress-bar/-/progress-bar-4.2.0.tgz", - "integrity": "sha512-H9VlEFff8brF/3fLOf7kbEPzI2JJUN3FL983ReCY3McATh/5bZZf8WrPpl6id/TKL1QS/pyr6AGx708xwLdcwA==", + "node_modules/@atlaskit/popper/node_modules/react-popper": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.3.0.tgz", + "integrity": "sha512-e1hj8lL3uM+sgSR4Lxzn5h1GxBlpa4CQz0XLF8kx4MDrDRWY0Ena4c97PUeSX9i5W3UAfDP0z0FXCTQkoXUl3Q==", + "license": "MIT", + "dependencies": { + "react-fast-compare": "^3.0.1", + "warning": "^4.0.2" + }, + "peerDependencies": { + "@popperjs/core": "^2.0.0", + "react": "^16.8.0 || ^17 || ^18", + "react-dom": "^16.8.0 || ^17 || ^18" + } + }, + "node_modules/@atlaskit/popup": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/@atlaskit/popup/-/popup-11.1.1.tgz", + "integrity": "sha512-aWAUuBm+Yg0A5c1A3MpI4LIp9nboYi6yOwhIHfbSXoisr7qqYhmyI9vuSbrE3dnQZBNol5GsRuGFyvV+stLNjQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popper": "^9.4.0", + "@atlaskit/portal": "^7.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.2.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0", + "bind-event-listener": "^3.0.0", + "focus-trap": "^2.4.5", + "memoize-one": "^6.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/popup/node_modules/@atlaskit/portal": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/portal/-/portal-7.1.0.tgz", + "integrity": "sha512-LSwuHoqPJTwOzJJO/XyE95mlSvaQZ33QH5kLY36LaQoNqkSpoOMYQepJ8CeK6ZH7k516WOSISgc3E/3At7YDBA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/app-provider": "^8.2.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop/-/pragmatic-drag-and-drop-4.0.0.tgz", + "integrity": "sha512-pyDo2B5NiaExoKGmgeXKGNUL4aR4UzzSZm8QWWjYTEyBLVqSqKyKUwtVxMw2YEkakagOGFONUdHM32LAH2nPug==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0", + "bind-event-listener": "^3.0.0", + "raf-schd": "^4.0.3" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-hitbox": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-hitbox/-/pragmatic-drag-and-drop-hitbox-3.0.0.tgz", + "integrity": "sha512-AGLp1ewjm07eRN2NL62awllSM19FrWVZMQYfZA/jugQlpaeoTr5ah2DE7zfiEt7yrg34htoKQVM+y6SGIQYs2A==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^4.0.0", + "@babel/runtime": "^7.0.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll/-/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll-3.2.1.tgz", + "integrity": "sha512-18dNiWVT2dhWVypbZ93cHpWfvThtxYZyFQqZLj+iwXa3JMjsu5mBikizqA5HBDrL5zpL+N8yvzcub4GCUcB6Zw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^4.0.0", + "@babel/runtime": "^7.0.0", + "css-box-model": "^1.2.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration/-/pragmatic-drag-and-drop-react-beautiful-dnd-migration-3.5.0.tgz", + "integrity": "sha512-yhamlE2vfcxXi3v4wsDtLPENa/B9d0WWPmuYU/fIY1TdkhRPgbn4r9fSpE9cCAUay2Woe3/ghaM9HG/MdWiveQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^4.0.0", + "@atlaskit/pragmatic-drag-and-drop-hitbox": "^3.0.0", + "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^3.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.12.0", + "@babel/runtime": "^7.0.0", + "@emotion/react": "^11.7.1", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/-/pragmatic-drag-and-drop-react-drop-indicator-4.3.0.tgz", + "integrity": "sha512-0jOj3UdQUEA9mtU3omOBmKg+JYArZGz+mhZi386tWcDKNVPtckRJtg8GVhPH1FjTcYhai+ik4HXpN0U0l/S+2w==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/pragmatic-drag-and-drop": "^4.0.0", + "@atlaskit/pragmatic-drag-and-drop-hitbox": "^3.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.12.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/tokens": "^13.0.0", + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/primitives": { + "version": "23.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/primitives/-/primitives-23.0.0.tgz", + "integrity": "sha512-7LxieV2AzoM9XSGqa7Cqa2rZEFF2LV5NSpdJCRiXUbbZq3ARn7Udadm9O8pgpMkprzgcY5bWO286++bXf0U4xA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/app-provider": "^8.3.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/interaction-context": "^4.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/visually-hidden": "^4.4.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0", + "@emotion/react": "^11.7.1", + "@emotion/serialize": "^1.1.0", + "bind-event-listener": "^3.0.0", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/primitives/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/primitives/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/primitives/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/primitives/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/progress-tracker": { - "version": "10.5.7", - "resolved": "https://registry.npmjs.org/@atlaskit/progress-tracker/-/progress-tracker-10.5.7.tgz", - "integrity": "sha512-jm5lvURQsFK0uAW5Kbx4NzD61fQmzL63oELxl5T4dl2MQcOhfS+xDzxswcFxG9RHeTaT64qypzQfB+TSBU9ryA==", + "node_modules/@atlaskit/progress-bar": { + "version": "5.3.7", + "resolved": "https://registry.npmjs.org/@atlaskit/progress-bar/-/progress-bar-5.3.7.tgz", + "integrity": "sha512-0aiz/V4gl/MR64x5qzq9V+Eq0bojvYNjW9uAQOkcyu1gIPpJcFt3SUEUhIScnu1Yhl6R77nUyPVdIxaUWVZzEg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/progress-bar/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/progress-tracker": { + "version": "11.4.5", + "resolved": "https://registry.npmjs.org/@atlaskit/progress-tracker/-/progress-tracker-11.4.5.tgz", + "integrity": "sha512-Mbw2mI+I0Hrmm8kdbnyl9hPj9ptwrL1H11vHnABRxBwqDpplcjrX4MJrlh4e8y3ugd4B3KrjmDZr5RLZyS2sDA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/css": "^1.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/radio": { + "version": "10.2.7", + "resolved": "https://registry.npmjs.org/@atlaskit/radio/-/radio-10.2.7.tgz", + "integrity": "sha512-i/lQrZHZ4e0PM59LucK5uDcZ4uBPMCaliY7BlrjbVE/cStMAn/RjJ8JhmCdMO5HxgKw9cWpzLAnLg0U8BF2m7Q==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.14.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/radio/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/radio/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/radio/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/radio/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/react-compiler-gating": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@atlaskit/react-compiler-gating/-/react-compiler-gating-0.2.7.tgz", + "integrity": "sha512-aOcVwX7le2FX92NmSfvvyMEierigp9O/rYNy/M+1ablnRRq1osP/drquGBPuDRHjnq0dddNWYVR4VxhF54Dtqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@babel/runtime": "^7.0.0" + } + }, + "node_modules/@atlaskit/react-select": { + "version": "4.13.4", + "resolved": "https://registry.npmjs.org/@atlaskit/react-select/-/react-select-4.13.4.tgz", + "integrity": "sha512-CE9hSf9zOx038MDqTeBrbk+saoakoq6YTvLlfXLpakORWFEl3WKP/44JFJTLAznMtRC6xBi2y7AtF3HP/j0vSw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/css": "^0.19.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/tag": "^17.1.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0", + "@floating-ui/dom": "^1.8.0", + "bind-event-listener": "^3.0.0", + "memoize-one": "^6.0.0", + "use-isomorphic-layout-effect": "^1.1.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/react-select/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/radio": { - "version": "8.6.2", - "resolved": "https://registry.npmjs.org/@atlaskit/radio/-/radio-8.6.2.tgz", - "integrity": "sha512-52HKnWiIOfc35nCsd/gs7T+tLqHQDtA1C6kr/H9UjAzCPf0t37+e+7g7tqSM+s4Adz/+snXpkhdu26P/g7Be8A==", + "node_modules/@atlaskit/section-message": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/@atlaskit/section-message/-/section-message-10.3.1.tgz", + "integrity": "sha512-yVWoXxioZR4hF7NT7+T0iarXwSgI8R5JFQs5Ps7J9p0mDRzjjUyla5pI9q/NfhfFtJWRMqcYKMwDIQv1tSVmMw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/heading": "^8.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/link": "^5.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/select": { + "version": "23.3.5", + "resolved": "https://registry.npmjs.org/@atlaskit/select/-/select-23.3.5.tgz", + "integrity": "sha512-HIqkFkqXzQTlBSMjEQI0Hhp+15LsPyMreDZSUs4FgPNAeluLL70yArD/VRXpOtrgXiiO3PY5YvCZnXhrLRwmBA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popper": "^9.4.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/react-select": "^4.13.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/top-layer": "^8.2.0", + "@atlaskit/visually-hidden": "^4.4.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0", + "@popperjs/core": "^2.11.8", + "bind-event-listener": "^3.0.0", + "react-focus-lock": "^2.9.5", + "shallow-equal": "^3.1.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/select/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/select/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/select/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/skeleton": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/@atlaskit/skeleton/-/skeleton-4.4.4.tgz", + "integrity": "sha512-UGDE48LN0j14rIWuv/OJq5Q3gdPljrDm4NtUEfr8Lld6/x1MKB5OsXkmwT76L/w7tmdcVTJ/wXqTuPWdtwgYlw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/interaction-context": "^4.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/skeleton/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/skeleton/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/spinner": { + "version": "20.4.4", + "resolved": "https://registry.npmjs.org/@atlaskit/spinner/-/spinner-20.4.4.tgz", + "integrity": "sha512-8gotKIqhS1k6ULNniSNt6IKAIA3ofHJuiMUdURlTYQ6PP+dyMqUg5dIoeRyLk2VPiuBipSXCFIAiRbSnK3eABQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/interaction-context": "^4.1.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/spinner/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/spinner/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/tabs": { + "version": "21.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/tabs/-/tabs-21.3.2.tgz", + "integrity": "sha512-etM9PzQ2OwE8Y8tQTT1yHvPLzPLrovmWgrt0zdCDwvyQrkgZouI2TTYhbPcbvHFerEA/0imEsmXCXJlnq9vG6w==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tabs/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/tabs/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/tabs/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/tag": { + "version": "17.1.5", + "resolved": "https://registry.npmjs.org/@atlaskit/tag/-/tag-17.1.5.tgz", + "integrity": "sha512-S+HU2xRXxg1/rWajOEBeoR2ro1nsgcvcvyKKMiDdRSs2CCF6vWM2y4wbNE5pQ1sDYPbqkjLpB3TPi667nLjkGA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/avatar": "^31.0.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/link": "^5.1.0", + "@atlaskit/lozenge": "^17.0.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-experiments": "^0.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/teams-avatar": "^4.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tag-group": { + "version": "13.4.3", + "resolved": "https://registry.npmjs.org/@atlaskit/tag-group/-/tag-group-13.4.3.tgz", + "integrity": "sha512-AkX9oYhzVkdmCL/yv1vGZvv+6aC1wk3atQL41J8KiZ7RCkqUvgDhPdXWOyWnZ18AUMyi5Ido9ROW7+I2qYqFEw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tag-group/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/tag/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/tag/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/tag/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/tag/node_modules/@atlaskit/platform-feature-experiments": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-experiments/-/platform-feature-experiments-0.3.2.tgz", + "integrity": "sha512-EdFY3b6muB7y1KyyZ+d2ovIFzW/ubc8Qw2oio/zfh6VhRHQ4tmCIX77CgFYURgbhtwu5THTyADE5N2OvMmtcFA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/react-ufo": "^8.3.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/tag/node_modules/@atlaskit/platform-feature-experiments/node_modules/@atlaskit/react-ufo": { + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/@atlaskit/react-ufo/-/react-ufo-8.9.1.tgz", + "integrity": "sha512-xqT6rlxEkQLXkhhz7JzUaTmQCRvHdTSdfQ5TEF2/pl9MTH+qGAP+kpHW1Zs3UzbXjDSw/OhQpF+lQsE1UQ8AZw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/atlassian-context": "^2.0.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/interaction-context": "^4.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "@opentelemetry/api": "^1.9.0", + "bind-event-listener": "^3.0.0", + "bowser-ultralight": "^1.0.6", + "uuid": "^11.1.1" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/tag/node_modules/@atlaskit/platform-feature-experiments/node_modules/@atlaskit/react-ufo/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/tag/node_modules/@atlaskit/platform-feature-experiments/node_modules/@atlaskit/react-ufo/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/teams-avatar": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/teams-avatar/-/teams-avatar-4.3.0.tgz", + "integrity": "sha512-cWF8pun8inihlXXJjy1YFCuBRQdbn89Q45ISe6P781m01qjwol78p2B32Sv5PIIGnfcbbuxkwr5JpNOg3lek3Q==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/avatar": "^31.0.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.2.0" + } + }, + "node_modules/@atlaskit/textarea": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/textarea/-/textarea-11.0.1.tgz", + "integrity": "sha512-HtqcY9wAAY9kYqgdLQ0NajQFTfJuiwHI26bmewHnx4/mhA3yAZGNKnuNvuiiP8VkcX2sCKbvUbQqsIWpeWkCTA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/textarea/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/textarea/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/textarea/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/textfield": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/textfield/-/textfield-11.0.1.tgz", + "integrity": "sha512-r3n6zmOWo21HL/XgVusJFEE8d4wz+bi2CO4oWEqijDcwNwgq21/b0SacEaRQdUQ+slm9AvRvcqbb3bxT73xboQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/textfield/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/textfield/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/textfield/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/theme": { + "version": "28.2.6", + "resolved": "https://registry.npmjs.org/@atlaskit/theme/-/theme-28.2.6.tgz", + "integrity": "sha512-ZdksHEUIYhrq5RJDe2n4Tl9qZPl1TAKFmib1utySTAvoy3fny7dn+SiyEU/p+Iufr728wwi5hNvq1XazBEAx5g==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.14.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tile": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tile/-/tile-5.0.0.tgz", + "integrity": "sha512-LZHzXCufzP1GlYhFtM2c1zuchdtvsMMwVKG3paC9Nf9MPlNsMbJH7RfFb2iuRc5jteD3Q5mBBNuHLsCgYmvf5A==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/skeleton": "^4.4.0", + "@atlaskit/tokens": "^20.0.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tile/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/tmp-editor-statsig": { + "version": "147.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tmp-editor-statsig/-/tmp-editor-statsig-147.1.0.tgz", + "integrity": "sha512-h0fMa/N3yQIEwXUWQN9ghsf516gKqqfvDJDSOLY/gI2cbgGq1KTWKp8A8bhrtZY45+kyhrJftsnExCz6oTL6BA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/feature-gate-js-client": "^6.0.0", + "@atlaskit/platform-feature-flags": "^2.1.0", + "@atlaskit/react-ufo": "^7.5.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.2.0" + } + }, + "node_modules/@atlaskit/tmp-editor-statsig/node_modules/@atlaskit/atlassian-context": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/atlassian-context/-/atlassian-context-1.2.0.tgz", + "integrity": "sha512-xM3V7efLG7LTeG/acX8k7N7QJ4929TMXg3Pv5eBAhIrE2o5YrE7wBfnkCDgNTWRu1KY7IJOGbz4xmF+AZ0z7fw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tmp-editor-statsig/node_modules/@atlaskit/feature-gate-js-client": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/feature-gate-js-client/-/feature-gate-js-client-6.0.2.tgz", + "integrity": "sha512-x4TKOAhM9Ejb6e2CA3OrIMv+T6+FdPSgEPH+yzB+k/A5OOHBaoKLzcG9Fs1mBGp/fISiD966xmdPdYb1RcMPDw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/atlassian-context": "^1.1.0", + "@babel/runtime": "^7.0.0", + "@statsig/client-core": "3.30.2", + "@statsig/js-client": "3.30.2", + "eventemitter3": "^4.0.0" + } + }, + "node_modules/@atlaskit/tmp-editor-statsig/node_modules/@atlaskit/react-ufo": { + "version": "7.13.0", + "resolved": "https://registry.npmjs.org/@atlaskit/react-ufo/-/react-ufo-7.13.0.tgz", + "integrity": "sha512-8uVMq1RWtzxiwP8ocq7ARkdkjwDAiGXzARcckZ6p5rB/yKKy3lKq96VkFwrgbCapJ0u+Zt6Mr3GTyiE+9QFZAA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/atlassian-context": "^1.2.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/feature-gate-js-client": "^6.0.0", + "@atlaskit/interaction-context": "^4.1.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "@opentelemetry/api": "^1.9.0", + "bind-event-listener": "^3.0.0", + "bowser-ultralight": "^1.0.6", + "scheduler": "0.23.2", + "uuid": "^11.1.1" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/tmp-editor-statsig/node_modules/@atlaskit/react-ufo/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/tmp-editor-statsig/node_modules/@atlaskit/react-ufo/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/toggle": { + "version": "17.3.7", + "resolved": "https://registry.npmjs.org/@atlaskit/toggle/-/toggle-17.3.7.tgz", + "integrity": "sha512-5TjrGm0JGnTmdPrIFbJOL8GWP9+mCgwOxUEP8YwUBGJMg4okx1VDa5uqbvttaSS8+HvkNpMlFnhoxB0gkVaaWw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/visually-hidden": "^4.4.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/toggle/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/toggle/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/toggle/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/tokens": { + "version": "20.15.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tokens/-/tokens-20.15.0.tgz", + "integrity": "sha512-G+jxuBsAUXdJIELgU0Juf2lplZlUCU0DnSnmpD4vLbRAMwKF1XCAWKlIj1AO+wl7dlxqUiBOSs1RIt8c+DGdfQ==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "@babel/traverse": "^7.23.2", + "@babel/types": "^7.20.0", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tooltip": { + "version": "24.4.8", + "resolved": "https://registry.npmjs.org/@atlaskit/tooltip/-/tooltip-24.4.8.tgz", + "integrity": "sha512-mHZrIFGc28ECBdOhw70pSD+0MyfrzGAEABei8tztXb9VuIEa3BNUPofvP1ZRZFGgOLDA1hFQoIxXdwpPyV9akg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popper": "^9.4.0", + "@atlaskit/portal": "^7.1.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@atlaskit/tokens": "^20.14.0", + "@atlaskit/top-layer": "^8.1.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2", + "bind-event-listener": "^3.0.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/tooltip/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/tooltip/node_modules/@atlaskit/analytics-next/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0" + } + }, + "node_modules/@atlaskit/tooltip/node_modules/@atlaskit/analytics-next/node_modules/use-memo-one": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@atlaskit/tooltip/node_modules/@atlaskit/portal": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@atlaskit/portal/-/portal-7.1.0.tgz", + "integrity": "sha512-LSwuHoqPJTwOzJJO/XyE95mlSvaQZ33QH5kLY36LaQoNqkSpoOMYQepJ8CeK6ZH7k516WOSISgc3E/3At7YDBA==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/app-provider": "^8.2.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/theme": "^28.2.0", + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } + }, + "node_modules/@atlaskit/tooltip/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@atlaskit/top-layer": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/top-layer/-/top-layer-8.3.2.tgz", + "integrity": "sha512-5CHhPPjxfUi5m5ssxR2ROylbgGmG1zsDbf5EpSaV2U8QJYVTIvJ5Y6OGgUnV5TSYUHDvRV5hsGHDAeyRW7JdEg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/pragmatic-drag-and-drop": "^4.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/tokens": "^20.15.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^2.0.0", + "bind-event-listener": "^3.0.0", + "raf-schd": "^4.0.3", + "tiny-invariant": "^1.2.0" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0", + "react-dom": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/top-layer/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/@atlaskit/visually-hidden": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@atlaskit/visually-hidden/-/visually-hidden-4.4.0.tgz", + "integrity": "sha512-pWru1P8dYWZxmTntklTf8Bi2CHUFLLHpG2RxO7bMzVAV47ebAre4jnQCeUyxwJHe4n0EynaFOD4fTIpXf5+rqw==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/react-compiler-gating": "^0.2.0", + "@babel/runtime": "^7.0.0", + "@compiled/react": "^1.0.2" + }, + "peerDependencies": { + "react": "^18.2.0 || ^19.0.0" + } + }, + "node_modules/@atlaskit/visually-hidden/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.17.tgz", + "integrity": "sha512-IdlVpcDeoDATtN2cfmnVk0A4XJKhu7SlpGuSaiOFdko09YC1MD07WokWUSEdw5R2o4o8VObX2LzViQW6VXnzkA==", + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.17", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.17.tgz", + "integrity": "sha512-xjNUVINWex7s4U0vESYwa8ChCBnmvhCQ6nkAdnhM8WYPlhXvU9D9fPurOSYQLV4FwcNXacDkN/MWIPNHsTI2OA==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.17", + "@babel/types": "^7.29.17", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.17.tgz", + "integrity": "sha512-SeQUwFlH8hH1vjUmBFeqwxt6Nsjp01MKEZOtZPJ86lpA4GBdb/o0dShjC+Awf7v74/+84KIL1RiJ4TOJj6gU+A==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.17.tgz", + "integrity": "sha512-bLxkfvUEHeWShbadKTm7EfDCkosXZh6PjWEa9bYiCuob24c0nm388ara2Hz6KisGaXe+XCsi6VyfJNSJjeUUwg==", + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.17", + "@babel/types": "^7.29.17" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.17.tgz", + "integrity": "sha512-iY5lvqFhfgMXp4o4zWads4NvQZXizBxzCoADPOgFMcMwk1XefAdBJbc9i1y94aflY57lokjOjRTa3AOOW9R7BQ==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.17.tgz", + "integrity": "sha512-AG+olLB+teKhkQ2WYJeaZqJwNLjtWTz1waQIP/tEYITzVzpdHLP7IXx2c/bH2JTsNCgvWlkqdCv91xcb8lul8Q==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.17.tgz", + "integrity": "sha512-I+0olVqWMm9bimQJc/5B3jn1nivNDXtnMtDVs07XdHzZLcWa2N/mlCTPmAsQg95QcKoXSuFD2Yz4fwdtoyk7DQ==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.17" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.17.tgz", + "integrity": "sha512-CvlZdpED5dsu21yK0DfpXksJWt1zeW09lY49hp7P9cA5Qedx/QkwEs1PfluSJjijH9i94oT9LmtgGWlPY8ISzw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.17.tgz", + "integrity": "sha512-D4nOLKOzIBwn7/Z78h3UPEwzFObmPVTukBJ9+63BijgMVeLj6mQ77FJb6YCZ4QBo6VjAk/yj4QnpKusTcBy6vA==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.17", + "@babel/parser": "^7.29.17", + "@babel/types": "^7.29.17" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.17.tgz", + "integrity": "sha512-q+CnfQcmNfDdOUARkt9FWtdR0HPOCcyQBj1Z7l2SOpFIfUB/XI3dXS0B5UOlZWwQCun80xVhgcv4ip6w128u9g==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.17", + "@babel/generator": "^7.29.17", + "@babel/helper-globals": "^7.29.17", + "@babel/parser": "^7.29.17", + "@babel/template": "^7.29.17", + "@babel/types": "^7.29.17", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.17", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.17.tgz", + "integrity": "sha512-kzo3lZUbI0gARA4QvhmOTH/aws2SrZ880ECQRIjPPSrdfBM0bZCkj1U7UN2fB0GNeXayqCiLVXa2+1jAhn377Q==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.17", + "@babel/helper-validator-identifier": "^7.29.17" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@compiled/react": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-2.0.0.tgz", + "integrity": "sha512-dYLzz9K1tlDklC9/00c0b0HdyL3JPYyW42CwiPPrufS083ZKd6kgq6wfyh6M2VvsoVVQWl+e1Zag4qS+lO2yYA==", + "license": "Apache-2.0", + "dependencies": { + "csstype": "^3.2.3" + }, + "peerDependencies": { + "react": ">=18.0.0" + } + }, + "node_modules/@emotion/babel-plugin": { + "version": "11.13.5", + "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.13.5.tgz", + "integrity": "sha512-pxHCpT2ex+0q+HH91/zsdHkw/lXd468DIN2zvfvLtPKLLMo6gQj7oLObq8PhkrxOZb/gGCq03S3Z7PDhS8pduQ==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.16.7", + "@babel/runtime": "^7.18.3", + "@emotion/hash": "^0.9.2", + "@emotion/memoize": "^0.9.0", + "@emotion/serialize": "^1.3.3", + "babel-plugin-macros": "^3.1.0", + "convert-source-map": "^1.5.0", + "escape-string-regexp": "^4.0.0", + "find-root": "^1.1.0", + "source-map": "^0.5.7", + "stylis": "4.2.0" + } + }, + "node_modules/@emotion/babel-plugin/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@emotion/cache": { + "version": "11.14.0", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.14.0.tgz", + "integrity": "sha512-L/B1lc/TViYk4DcpGxtAVbx0ZyiKM5ktoIyafGkH6zg/tj+mA+NE//aPYKG0k8kCHSHVJrpLpcAlOBEXQ3SavA==", + "license": "MIT", + "dependencies": { + "@emotion/memoize": "^0.9.0", + "@emotion/sheet": "^1.4.0", + "@emotion/utils": "^1.4.2", + "@emotion/weak-memoize": "^0.4.0", + "stylis": "4.2.0" + } + }, + "node_modules/@emotion/hash": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.2.tgz", + "integrity": "sha512-MyqliTZGuOm3+5ZRSaaBGP3USLw6+EGykkwZns2EPC5g8jJ4z9OrdZY9apkl3+UP9+sdz76YYkwCKP5gh8iY3g==", + "license": "MIT" + }, + "node_modules/@emotion/memoize": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.9.0.tgz", + "integrity": "sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ==", + "license": "MIT" + }, + "node_modules/@emotion/react": { + "version": "11.14.0", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.14.0.tgz", + "integrity": "sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.18.3", + "@emotion/babel-plugin": "^11.13.5", + "@emotion/cache": "^11.14.0", + "@emotion/serialize": "^1.3.3", + "@emotion/use-insertion-effect-with-fallbacks": "^1.2.0", + "@emotion/utils": "^1.4.2", + "@emotion/weak-memoize": "^0.4.0", + "hoist-non-react-statics": "^3.3.1" + }, + "peerDependencies": { + "react": ">=16.8.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@emotion/serialize": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.3.3.tgz", + "integrity": "sha512-EISGqt7sSNWHGI76hC7x1CksiXPahbxEOrC5RjmFRJTqLyEK9/9hZvBbiYn70dw4wuwMKiEMCUlR6ZXTSWQqxA==", + "license": "MIT", + "dependencies": { + "@emotion/hash": "^0.9.2", + "@emotion/memoize": "^0.9.0", + "@emotion/unitless": "^0.10.0", + "@emotion/utils": "^1.4.2", + "csstype": "^3.0.2" + } + }, + "node_modules/@emotion/sheet": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.4.0.tgz", + "integrity": "sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg==", + "license": "MIT" + }, + "node_modules/@emotion/unitless": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.10.0.tgz", + "integrity": "sha512-dFoMUuQA20zvtVTuxZww6OHoJYgrzfKM1t52mVySDJnMSEa08ruEvdYQbhvyu6soU+NeLVd3yKfTfT0NeV6qGg==", + "license": "MIT" + }, + "node_modules/@emotion/use-insertion-effect-with-fallbacks": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.2.0.tgz", + "integrity": "sha512-yJMtVdH59sxi/aVJBpk9FQq+OR8ll5GT8oWd57UpeaKEVGab41JWaCFA7FRLoMLloOZF/c/wsPoe+bfGmRKgDg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.8.0" + } + }, + "node_modules/@emotion/utils": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.4.2.tgz", + "integrity": "sha512-3vLclRofFziIa3J2wDh9jjbkUz9qk5Vi3IZ/FSTKViB0k+ef0fPV7dYrUIugbgupYDx7v9ud/SjrtEP8Y4xLoA==", + "license": "MIT" + }, + "node_modules/@emotion/weak-memoize": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.4.0.tgz", + "integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==", + "license": "MIT" + }, + "node_modules/@floating-ui/core": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz", + "integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz", + "integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==", + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.8.0", + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz", + "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", + "license": "MIT" + }, + "node_modules/@forge/api": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/@forge/api/-/api-7.2.2.tgz", + "integrity": "sha512-q0TwkgzZqEbB1NNetQ9xRvNH6ICaX71QH884tduRzps+qnjuJYh0lJHKKxtwWMfZFdiILNRayhyAlvvuMskH3Q==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@forge/auth": "0.0.9", + "@forge/egress": "2.3.2", + "@forge/i18n": "0.0.7", + "@forge/manifest": "^12.9.0", + "@forge/storage": "2.0.3", + "headers-utils": "^3.0.2" + } + }, + "node_modules/@forge/auth": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@forge/auth/-/auth-0.0.9.tgz", + "integrity": "sha512-3qZZNknFprzDkrXzBVKHqVD12r/b2K9cu/RJh9TP3QLiF18v7bdoD1fgZZbVavKJUmCNdQERk6NTVQLmmEszhg==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "tslib": "^2.6.2" + } + }, + "node_modules/@forge/bridge": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@forge/bridge/-/bridge-7.4.0.tgz", + "integrity": "sha512-sCPLCJ1mC9al3np1OUZuopxZep2vbjsHpIbeiUfJfr4inc0oKu/Cp8+31byLI30PqhqNVOgs0BV5NvduoxtHrQ==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@atlaskit/adf-schema": "^56.7.0", + "@atlaskit/tokens": "^1.58.0", + "@forge/egress": "^3.0.1", + "@forge/i18n": "1.0.2", + "@forge/manifest": "13.9.1", + "@forge/resolver": "2.0.2", + "@types/history": "^4.7.11", + "@types/iframe-resizer": "^3.5.8", + "iframe-resizer": "^4.4.5" }, "peerDependencies": { - "react": "^18.2.0" + "typescript": ">=5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, - "node_modules/@forge/react/node_modules/@atlaskit/react-select": { - "version": "3.16.2", - "resolved": "https://registry.npmjs.org/@atlaskit/react-select/-/react-select-3.16.2.tgz", - "integrity": "sha512-q9gLluaJZFG/S0YB848N/SIrc16RoAhrpXO0OfEVZqcv8Qd7d97+wZxd0rL/ynjZZZqdCGec+D7aJlDCFnY96A==", + "node_modules/@forge/bridge/node_modules/@atlaskit/ds-lib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@atlaskit/ds-lib/-/ds-lib-2.7.0.tgz", + "integrity": "sha512-+U4aPE2dBRFUBYWCM9vkrwJGrLAYVcK30ZpEiQDNpM2D7K41223TfEijC8azaN4VM3tsCgwSKBWwniloNxqYbA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.3.0", - "@atlaskit/layering": "^3.7.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/spinner": "^19.1.0", - "@atlaskit/tag": "^14.14.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/platform-feature-flags": "^0.3.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "@floating-ui/dom": "^1.0.1", - "memoize-one": "^6.0.0", - "use-isomorphic-layout-effect": "^1.1.2" + "bind-event-listener": "^3.0.0", + "react-uid": "^2.2.0" }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/section-message": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@atlaskit/section-message/-/section-message-8.13.0.tgz", - "integrity": "sha512-tibMfW9dY1IcFnupBIP1UIkVwaud3A5mwfHHrSxyFBV1fVhhvccS0WlLvMXceu3cui20Y6tB1CQzCR4mB8f+og==", + "node_modules/@forge/bridge/node_modules/@atlaskit/platform-feature-flags": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags/-/platform-feature-flags-0.3.0.tgz", + "integrity": "sha512-/0u5fFJ0Rw2j4M5wzsXgaHO6Ey12oekPCDTRvmmAIp4GO9T2Swbl80bavLAPSOmSHMhHTSuvRxiJveZXfQ21IQ==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/heading": "^5.4.0", - "@atlaskit/icon": "^35.0.0", - "@atlaskit/link": "^3.4.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", "@babel/runtime": "^7.0.0" - }, - "peerDependencies": { - "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/select": { - "version": "21.12.15", - "resolved": "https://registry.npmjs.org/@atlaskit/select/-/select-21.12.15.tgz", - "integrity": "sha512-Ad3llod6ZUA15u73dG7pflHYUY4l0T1UkOwnTWpc/4kvTdZ05gE0lU7nM7BlAP7Vet9ENq2Fq75WbfqY5aN7PA==", + "node_modules/@forge/bridge/node_modules/@atlaskit/tokens": { + "version": "1.61.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tokens/-/tokens-1.61.0.tgz", + "integrity": "sha512-gRkBDZOaQffJHg9g+hYFgPjQ0Hz4XIDaK5WEttIGyhi2USsGsvDvUeED8liqcQNwssH/5UFxIFp3FmEwo0DoFA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.4.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/react-select": "^3.16.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.4.0", - "@atlaskit/top-layer": "^0.18.0", - "@atlaskit/visually-hidden": "^3.1.0", + "@atlaskit/ds-lib": "^2.6.0", + "@atlaskit/platform-feature-flags": "^0.3.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "@popperjs/core": "^2.11.8", - "bind-event-listener": "^3.0.0", - "react-focus-lock": "^2.9.5", - "react-popper": "^2.3.0", - "shallow-equal": "^3.1.0" + "@babel/traverse": "^7.23.2", + "@babel/types": "^7.20.0", + "bind-event-listener": "^3.0.0" }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/select/node_modules/react-focus-lock": { - "version": "2.13.7", - "resolved": "https://registry.npmjs.org/react-focus-lock/-/react-focus-lock-2.13.7.tgz", - "integrity": "sha512-20lpZHEQrXPb+pp1tzd4ULL6DyO5D2KnR0G69tTDdydrmNhU7pdFmbQUYVyHUgp+xN29IuFR0PVuhOmvaZL9Og==", - "license": "MIT", + "node_modules/@forge/bridge/node_modules/@forge/egress": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@forge/egress/-/egress-3.0.1.tgz", + "integrity": "sha512-G32D+jtr9P6x5Lgikcf6P7oBIguFID89nUDoCHpTwk7dkySEBTQZ5mHUm1Til4/K6M0NY1gxAL0ULm0X6gqJiA==", + "license": "SEE LICENSE IN LICENSE.txt", + "peerDependencies": { + "typescript": ">=5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@forge/bridge/node_modules/@forge/i18n": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@forge/i18n/-/i18n-1.0.2.tgz", + "integrity": "sha512-Bp7bnyH26yg4uJ84KhLwHXpi0Gc1BKx7AaJO67GvVahlHl8YCDH/ePb0KH77IOb9K/yOmsjaJJ2vK3wY/c/p3A==", + "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { - "@babel/runtime": "^7.0.0", - "focus-lock": "^1.3.6", - "prop-types": "^15.6.2", - "react-clientside-effect": "^1.2.7", - "use-callback-ref": "^1.3.3", - "use-sidecar": "^1.1.3" + "lodash": "^4.18.1" }, "peerDependencies": { - "@types/react": "*", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + "typescript": ">=5.0.0" }, "peerDependenciesMeta": { - "@types/react": { + "typescript": { "optional": true } } }, - "node_modules/@forge/react/node_modules/@atlaskit/select/node_modules/use-callback-ref": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", - "integrity": "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==", - "license": "MIT", + "node_modules/@forge/bridge/node_modules/@forge/manifest": { + "version": "13.9.1", + "resolved": "https://registry.npmjs.org/@forge/manifest/-/manifest-13.9.1.tgz", + "integrity": "sha512-W2Jh1EtqAO6djKMntTFrhAcCpXbL4o7UwyD6I6Ffro4M3nSxFW0qFJpOmcw5FGF+x7fKEbcH9OW7efP1Plra+Q==", + "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { - "tslib": "^2.0.0" + "@forge/i18n": "1.0.2", + "@sentry/node": "7.106.0", + "ajv": "^8.18.0", + "ajv-formats": "2.1.1", + "cheerio": "^1.2.0", + "glob": "^13.0.0", + "lodash": "^4.18.1", + "mime-types": "^2.1.35", + "yaml": "^2.3.4" }, - "engines": { - "node": ">=10" + "peerDependencies": { + "typescript": ">=5.0.0" }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@forge/bridge/node_modules/@forge/resolver": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@forge/resolver/-/resolver-2.0.2.tgz", + "integrity": "sha512-LIAW/lS/1prKWhO3KPj9uaOSIvXL8Sv0vFHuW6yEHKRcAVF8vt7qDDVmkQwAsnx74QtRywDzN7UZuzeNKqhq0g==", + "license": "SEE LICENSE IN LICENSE.txt", "peerDependencies": { - "@types/react": "*", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + "typescript": ">=5.0.0" }, "peerDependenciesMeta": { - "@types/react": { + "typescript": { "optional": true } } }, - "node_modules/@forge/react/node_modules/@atlaskit/select/node_modules/use-sidecar": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", - "integrity": "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==", + "node_modules/@forge/bridge/node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", + "peer": true, "dependencies": { - "detect-node-es": "^1.1.0", - "tslib": "^2.0.0" + "loose-envify": "^1.1.0" }, "engines": { - "node": ">=10" + "node": ">=0.10.0" + } + }, + "node_modules/@forge/egress": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@forge/egress/-/egress-2.3.2.tgz", + "integrity": "sha512-p8ioX4qnAlRFln+hyH9kO0MmVCSOUg0bsIG9RAYK8KM2YaJb6EnKqbCvPMBTwegiua3vixBsnZmWDgPegSZh9Q==", + "license": "SEE LICENSE IN LICENSE.txt" + }, + "node_modules/@forge/i18n": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@forge/i18n/-/i18n-0.0.7.tgz", + "integrity": "sha512-EKrQApcuI4k4AkUSeERkZv1dQaGjWsmB8i7ciDPtpDARPRH1sOrU+FSEOoA7b9FQ15++7Q144m94w/aMLCg5Gg==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "lodash": "^4.17.21" + } + }, + "node_modules/@forge/manifest": { + "version": "12.9.0", + "resolved": "https://registry.npmjs.org/@forge/manifest/-/manifest-12.9.0.tgz", + "integrity": "sha512-7JZiXpAHa5SNSM4DsmaO1PfgZtHngKKwh1++RoYCS1QDuck1sJ2KXh3dq7FV+ajOKVtI54uyukUb7oYMGp7rPw==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@forge/i18n": "0.0.7", + "@sentry/node": "7.106.0", + "ajv": "^8.18.0", + "ajv-formats": "2.1.1", + "cheerio": "^1.1.0", + "glob": "^13.0.0", + "lodash": "^4.17.21", + "mime-types": "^2.1.35", + "yaml": "^2.3.4" + } + }, + "node_modules/@forge/react": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@forge/react/-/react-12.6.0.tgz", + "integrity": "sha512-MP+SOTcs/t83Vlb+bEiqKQx/knlLfJvVqoh/0edO+wFDZQzROwhAOoByCZ471Fl7nsa+YFqu1crR2wE117v42g==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "@atlaskit/adf-schema": "^56.7.0", + "@atlaskit/adf-utils": "^20.5.12", + "@atlaskit/forge-react-types": "^2.13.0", + "@forge/bridge": "^7.4.0", + "@forge/egress": "^3.0.1", + "@forge/i18n": "1.0.2", + "@types/react": "^18.2.64", + "@types/react-reconciler": "^0.28.8", + "lodash": "^4.18.1", + "react": "^18.2.0", + "react-hook-form": "7.65.0", + "react-reconciler": "^0.29.0", + "react-test-renderer": "^18.2.0", + "uuid": "^11.1.1" }, "peerDependencies": { - "@types/react": "*", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + "typescript": ">=5.0.0" }, "peerDependenciesMeta": { - "@types/react": { + "typescript": { "optional": true } } }, - "node_modules/@forge/react/node_modules/@atlaskit/side-nav-items": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/@atlaskit/side-nav-items/-/side-nav-items-1.14.0.tgz", - "integrity": "sha512-z1l0beJB7ohMOuiky1vCXYoVqxtRuyXtckIiHkCo31C+47b4/PNq1dACeao2XftHld95uWHYbGjD3NfzQuUQlA==", - "license": "Apache-2.0", - "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/avatar": "^25.15.0", - "@atlaskit/button": "^23.11.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/heading": "^5.4.0", - "@atlaskit/icon": "^35.4.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/platform-feature-flags-react": "^0.5.0", - "@atlaskit/popup": "^4.24.0", - "@atlaskit/pragmatic-drag-and-drop": "^1.8.0", - "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.2.0", - "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.3.0", - "@atlaskit/tooltip": "^22.6.0", + "node_modules/@forge/react/node_modules/@atlaskit/analytics-next": { + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next/-/analytics-next-12.6.0.tgz", + "integrity": "sha512-QFECDwLBbNx9IRsBQMiQlw6r/sx+DcVs9hkJxRgPe3yakTdPBZMzSqD0b4R2tsFNlNxSKSkeJCF92S20v7suqg==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/analytics-next-stable-react-context": "1.0.1", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "tiny-invariant": "^1.2.0" + "prop-types": "^15.5.10", + "use-memo-one": "^1.1.1" }, "peerDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/skeleton": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@atlaskit/skeleton/-/skeleton-2.2.0.tgz", - "integrity": "sha512-0Pu7Wmem6Nakr0hQ2PqLitDvSAhaHh4G+jPdIQWciaW5PMYdeXPtJ1LpkRiEjtzLU6mStPbr/X5HIH1QJiQsrQ==", + "node_modules/@forge/react/node_modules/@atlaskit/analytics-next-stable-react-context": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@atlaskit/analytics-next-stable-react-context/-/analytics-next-stable-react-context-1.0.1.tgz", + "integrity": "sha512-iO6+hIp09dF4iAZQarVz3vKY1kM5Ij5CExYcK9jgc2q+OH8nv8n+BPFeJTdzGOGopmbUZn5Opj9pYQvge1Gr4Q==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/tokens": "^13.3.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "tslib": "^2.0.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^16.8.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/spinner": { - "version": "19.1.2", - "resolved": "https://registry.npmjs.org/@atlaskit/spinner/-/spinner-19.1.2.tgz", - "integrity": "sha512-Z2zOdi+zNd2qn8BrKOcxmHdlhcA1mNi3gGPklqW2MY+Ch/zL8WBTLia8KL5dIFwLjLG9C2J1u8OTYvtrZrhDhA==", + "node_modules/@forge/react/node_modules/@atlaskit/browser-apis": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/browser-apis/-/browser-apis-1.2.0.tgz", + "integrity": "sha512-SNwf6LGu1BjECz62iC/kIOwmtiJlz4cuf04OnVLlN8amEly+6NHIzZG+IU2Bbpa2vG7oVSj3nSy0gMm/7kqiuQ==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/interaction-context": "^3.1.0", - "@atlaskit/tokens": "^13.0.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/tabs": { - "version": "19.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/tabs/-/tabs-19.1.0.tgz", - "integrity": "sha512-Pzxg6lZWnXFq8kt++qA5zIznEAfgf9zyQU0mSuDN4O5hDcsfhs9rwGAxgjCszxuVOJNnh+DfBd+mjB1847SF3A==", + "node_modules/@forge/react/node_modules/@atlaskit/editor-prosemirror": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@atlaskit/editor-prosemirror/-/editor-prosemirror-9.0.2.tgz", + "integrity": "sha512-Hn5atRMHJDQFz1U6PbzK50LRt/rEHbwvvNm49n6zIVV1464GfVuoGFtK0sHXPKi2LE1k8HNyyEjOAjLQUsoifw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" - }, - "peerDependencies": { - "react": "^18.2.0" + "prosemirror-commands": "1.7.1", + "prosemirror-dropcursor": "1.8.2", + "prosemirror-history": "1.5.0", + "prosemirror-keymap": "1.2.3", + "prosemirror-markdown": "1.13.4", + "prosemirror-model": "1.25.4", + "prosemirror-state": "1.4.4", + "prosemirror-transform": "1.11.0", + "prosemirror-utils": "1.2.2", + "prosemirror-view": "1.41.7" } }, - "node_modules/@forge/react/node_modules/@atlaskit/tag": { - "version": "14.16.0", - "resolved": "https://registry.npmjs.org/@atlaskit/tag/-/tag-14.16.0.tgz", - "integrity": "sha512-6xeoT2tZdD8Va2imwiXivcAwBtXSN+bizaddqD6GaJMGy98JW3o8t36/mhiiNRlULwJDPy/SF0jfxnrtPV+zgA==", - "license": "Apache-2.0", - "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/avatar": "^25.15.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.4.0", - "@atlaskit/link": "^3.4.0", - "@atlaskit/lozenge": "^13.8.0", - "@atlaskit/motion": "^6.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/spinner": "^19.1.0", - "@atlaskit/teams-avatar": "^2.7.0", - "@atlaskit/tokens": "^13.3.0", + "node_modules/@forge/react/node_modules/@atlaskit/forge-react-types": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/@atlaskit/forge-react-types/-/forge-react-types-2.20.0.tgz", + "integrity": "sha512-x9z3YDeAF90CKVY0Ow0ZcG2ii55Hvr/3f8SiGv3mJtoayVsO+Uc8PqvHH8bxlpMY/j7cqnrQBmFBaEWC2E97ww==", + "license": "Apache-2.0", + "dependencies": { + "@atlaskit/adf-schema": "^57.7.0", + "@atlaskit/banner": "^15.3.0", + "@atlaskit/blanket": "^16.4.0", + "@atlaskit/breadcrumbs": "^17.8.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/comment": "^14.2.0", + "@atlaskit/datetime-picker": "^19.5.0", + "@atlaskit/dynamic-table": "^19.3.0", + "@atlaskit/form": "^18.3.0", + "@atlaskit/inline-edit": "^16.6.0", + "@atlaskit/modal-dialog": "^17.4.0", + "@atlaskit/navigation-system": "^12.2.0", + "@atlaskit/object": "^2.3.0", + "@atlaskit/pagination": "^17.3.0", + "@atlaskit/popup": "^11.1.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/progress-bar": "^5.3.0", + "@atlaskit/progress-tracker": "^11.4.0", + "@atlaskit/radio": "^10.2.0", + "@atlaskit/section-message": "^10.3.0", + "@atlaskit/select": "^23.3.0", + "@atlaskit/skeleton": "^4.4.0", + "@atlaskit/spinner": "^20.4.0", + "@atlaskit/tabs": "^21.3.0", + "@atlaskit/tag": "^17.1.0", + "@atlaskit/tag-group": "^13.4.0", + "@atlaskit/textarea": "^11.0.0", + "@atlaskit/textfield": "^11.0.0", + "@atlaskit/tile": "^5.0.0", + "@atlaskit/toggle": "^17.3.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/tooltip": "^24.4.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@emotion/react": "^11.7.1", + "@emotion/serialize": "^1.1.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/tag-group": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/tag-group/-/tag-group-12.1.0.tgz", - "integrity": "sha512-Lafdgis655Cs25Ooj2kF0SB0z0J3Cm6Slj/+1VpmdGIPZebxoQzA5UqU6N8jFMRGY54VLdsUNVVd4oEFr3L8zg==", + "node_modules/@forge/react/node_modules/@atlaskit/forge-react-types/node_modules/@atlaskit/adf-schema": { + "version": "57.7.77", + "resolved": "https://registry.npmjs.org/@atlaskit/adf-schema/-/adf-schema-57.7.77.tgz", + "integrity": "sha512-+S1xj0fXepWg0PtudKidQTZhg6mcHKBnFrmtMS+a5Xs8Wi4p/rEEAiMh88tDm7SHNvym8RF75lMHtLjhCQMejw==", "license": "Apache-2.0", "dependencies": { + "@atlaskit/adf-schema-generator": "^4.0.0", + "@atlaskit/editor-prosemirror": "^9.0.0", + "@atlaskit/platform-feature-experiments": "^0.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/tmp-editor-statsig": "^295.0.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "css-color-names": "0.0.4", + "linkify-it": "^5.0.2", + "memoize-one": "^6.0.0" + } + }, + "node_modules/@forge/react/node_modules/@atlaskit/interaction-context": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@atlaskit/interaction-context/-/interaction-context-4.3.0.tgz", + "integrity": "sha512-F31jO2V5z68MEAsyFPCFo5/FoklA7qhBf/1sKBuYzNcSJfWHegjb4K7+g9H2HsAQMe8WnfcTysqYOIod8Iiuqw==", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/teams-avatar": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@atlaskit/teams-avatar/-/teams-avatar-2.7.0.tgz", - "integrity": "sha512-pSgF0uL9ghbHzJ0IYB/cS28rCT1GnMNVMKfdj+bKyOrrhuhTE1Gc3MpbTY3OS9PNr+KqQfmFhFeKLAa9sbUqhg==", + "node_modules/@forge/react/node_modules/@atlaskit/navigation-system": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@atlaskit/navigation-system/-/navigation-system-12.2.2.tgz", + "integrity": "sha512-ZSGxSNd/cSarzWdE2JndwIyv7szZ6F8c5shHXwC+TwD09vEZVgF36Ys1G3VvaQ6PuNbYgjbnhBQf9tH9OkjLHw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/avatar": "^25.14.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/avatar": "^31.0.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/layering": "^6.1.0", + "@atlaskit/logo": "^23.3.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/popup": "^11.1.0", + "@atlaskit/pragmatic-drag-and-drop": "^4.0.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/side-nav-items": "^2.8.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/tooltip": "^24.4.0", + "@atlaskit/top-layer": "^8.3.0", + "@atlaskit/visually-hidden": "^4.4.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^2.0.0", + "bind-event-listener": "^3.0.0", + "raf-schd": "^4.0.3", + "tiny-invariant": "^1.2.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/textarea": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/@atlaskit/textarea/-/textarea-8.3.2.tgz", - "integrity": "sha512-HeVjb0ur18Go29fKMBZJpUFYwjUUVrxvBxsuvA/wwYvgzvr9DDwDS5Wx6vBDIiBOwND8YHYHC8cr+fmaSPBZ7w==", + "node_modules/@forge/react/node_modules/@atlaskit/platform-feature-experiments": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-experiments/-/platform-feature-experiments-0.3.2.tgz", + "integrity": "sha512-EdFY3b6muB7y1KyyZ+d2ovIFzW/ubc8Qw2oio/zfh6VhRHQ4tmCIX77CgFYURgbhtwu5THTyADE5N2OvMmtcFA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.0.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/react-ufo": "^8.3.0", + "@babel/runtime": "^7.0.0" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/textfield": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/@atlaskit/textfield/-/textfield-8.3.2.tgz", - "integrity": "sha512-rj+XIWl1mh8CEj8DeVlEiMBaAnUTeCgtLiNfqsQxzvsaeLI+/YgIQqTsVpslLKhhiAyCI/bDW076PreNywpCiQ==", + "node_modules/@forge/react/node_modules/@atlaskit/platform-feature-flags-react": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@atlaskit/platform-feature-flags-react/-/platform-feature-flags-react-1.2.0.tgz", + "integrity": "sha512-Vav/2EbQdUd9tmwRjdVls3zvB+LuxDO9M8xQicVBxEHbxb3zUpfdBx2B4SMfyv1wIvKzDQiEgmcgIPu4VAJdqA==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/platform-feature-flags": "^2.1.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@compiled/react": "^1.0.2", + "react-magnetic-di": "^3.1.4" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/theme": { - "version": "25.0.0", - "resolved": "https://registry.npmjs.org/@atlaskit/theme/-/theme-25.0.0.tgz", - "integrity": "sha512-zZFJla2cDQg9hM87L1AiSy6SvgYWyZQ2uw/bWLV6Cb/anat2/NVtQ9fxlOpVrCiq8yVZEnJNaY97gFQ8mL9lzA==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "node_modules/@forge/react/node_modules/@atlaskit/platform-feature-flags-react/node_modules/@compiled/react": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@compiled/react/-/react-1.0.2.tgz", + "integrity": "sha512-xGOChqGDvoJON+1QOgV4cYmy1W3oonJw43TQ7KR8TuPTlIAHuFBgfckmyMPG4WppF0FYem518LZknySU0uQhlg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/tokens": "^13.0.0", - "@babel/runtime": "^7.0.0" + "csstype": "^3.2.3" }, "peerDependencies": { - "react": "^18.2.0" + "react": ">=18.0.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/tile": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/tile/-/tile-1.1.0.tgz", - "integrity": "sha512-ZvFITAzYx4IUV+V7OsLrdM1Hic9WQfK4nIebG4dHasssBjsJfdVQmLDsR/lHbop24cFENI4x/D75LcMtr+kQew==", + "node_modules/@forge/react/node_modules/@atlaskit/react-ufo": { + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/@atlaskit/react-ufo/-/react-ufo-8.9.1.tgz", + "integrity": "sha512-xqT6rlxEkQLXkhhz7JzUaTmQCRvHdTSdfQ5TEF2/pl9MTH+qGAP+kpHW1Zs3UzbXjDSw/OhQpF+lQsE1UQ8AZw==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/skeleton": "^2.1.0", - "@atlaskit/tokens": "^13.0.0", + "@atlaskit/atlassian-context": "^2.0.0", + "@atlaskit/browser-apis": "^1.2.0", + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/interaction-context": "^4.3.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-compiler-gating": "^0.2.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" + "@opentelemetry/api": "^1.9.0", + "bind-event-listener": "^3.0.0", + "bowser-ultralight": "^1.0.6", + "uuid": "^11.1.1" }, "peerDependencies": { "react": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/toggle": { - "version": "16.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/toggle/-/toggle-16.1.0.tgz", - "integrity": "sha512-L0jykH+WkvBjHZf2jXOumBkDwqj+Ew4c/BPPxcrxOemmxwdRt6a+3bIcDKVY9/bkf5SIBdcF3Pd+Gez3MB68bw==", + "node_modules/@forge/react/node_modules/@atlaskit/side-nav-items": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/@atlaskit/side-nav-items/-/side-nav-items-2.8.6.tgz", + "integrity": "sha512-ci4r4qB6iWW1iy/30PjRmiFCoF3ZJ1hyBvoaaJ5rYM8dvL/Gc1y4fgiFb/YwBJqlbU6RB1ToOqpzVqIUkw6OUg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.2.0", - "@atlaskit/css": "^0.19.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/icon": "^35.3.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/primitives": "^19.0.0", - "@atlaskit/spinner": "^19.1.0", - "@atlaskit/tokens": "^13.1.0", - "@atlaskit/visually-hidden": "^3.1.0", + "@atlaskit/analytics-next": "^12.6.0", + "@atlaskit/avatar": "^31.0.0", + "@atlaskit/button": "^25.8.0", + "@atlaskit/css": "^1.1.0", + "@atlaskit/ds-lib": "^9.0.0", + "@atlaskit/heading": "^8.0.0", + "@atlaskit/icon": "^38.3.0", + "@atlaskit/motion": "^10.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/platform-feature-flags-react": "^1.2.0", + "@atlaskit/popup": "^11.1.0", + "@atlaskit/pragmatic-drag-and-drop": "^4.0.0", + "@atlaskit/pragmatic-drag-and-drop-hitbox": "^3.0.0", + "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^4.3.0", + "@atlaskit/primitives": "^23.0.0", + "@atlaskit/react-compiler-gating": "^0.2.0", + "@atlaskit/skeleton": "^4.4.0", + "@atlaskit/tokens": "^20.15.0", + "@atlaskit/tooltip": "^24.4.0", "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "bind-event-listener": "^3.0.0" + "@compiled/react": "^2.0.0", + "tiny-invariant": "^1.2.0" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/tooltip": { - "version": "22.6.5", - "resolved": "https://registry.npmjs.org/@atlaskit/tooltip/-/tooltip-22.6.5.tgz", - "integrity": "sha512-MXIsyhlqVW9JJRCQOBok2E52+HPvLEcIu31fG6eHWpVCQ7tH+fQK7YjfxBDCALJw8a8VzkotzPEUeVofeB/nhA==", + "node_modules/@forge/react/node_modules/@atlaskit/tmp-editor-statsig": { + "version": "295.0.0", + "resolved": "https://registry.npmjs.org/@atlaskit/tmp-editor-statsig/-/tmp-editor-statsig-295.0.0.tgz", + "integrity": "sha512-RVWR6+vDMah4lbp4SESvTLGbMvfK8Tbpt5sSdm24JUMchAt3sdePoN/ALsC1jo87vyJr9h7P156IPrzD++Jzkg==", "license": "Apache-2.0", "dependencies": { - "@atlaskit/analytics-next": "^11.3.0", - "@atlaskit/ds-lib": "^7.0.0", - "@atlaskit/layering": "^3.8.0", - "@atlaskit/motion": "^6.2.0", - "@atlaskit/platform-feature-flags": "^1.1.0", - "@atlaskit/popper": "^7.2.0", - "@atlaskit/portal": "^5.5.0", - "@atlaskit/theme": "^25.0.0", - "@atlaskit/tokens": "^13.4.0", - "@atlaskit/top-layer": "^0.18.0", - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0", - "bind-event-listener": "^3.0.0" + "@atlaskit/feature-gate-js-client": "^8.0.0", + "@atlaskit/platform-feature-flags": "^2.2.0", + "@atlaskit/react-ufo": "^8.9.0", + "@babel/runtime": "^7.0.0" }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^18.2.0 || ^19.2.0" + } + }, + "node_modules/@forge/react/node_modules/@forge/egress": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@forge/egress/-/egress-3.0.1.tgz", + "integrity": "sha512-G32D+jtr9P6x5Lgikcf6P7oBIguFID89nUDoCHpTwk7dkySEBTQZ5mHUm1Til4/K6M0NY1gxAL0ULm0X6gqJiA==", + "license": "SEE LICENSE IN LICENSE.txt", + "peerDependencies": { + "typescript": ">=5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/@forge/i18n": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@forge/i18n/-/i18n-1.0.2.tgz", + "integrity": "sha512-Bp7bnyH26yg4uJ84KhLwHXpi0Gc1BKx7AaJO67GvVahlHl8YCDH/ePb0KH77IOb9K/yOmsjaJJ2vK3wY/c/p3A==", + "license": "SEE LICENSE IN LICENSE.txt", + "dependencies": { + "lodash": "^4.18.1" + }, + "peerDependencies": { + "typescript": ">=5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@forge/react/node_modules/prosemirror-markdown": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.4.tgz", + "integrity": "sha512-D98dm4cQ3Hs6EmjK500TdAOew4Z03EV71ajEFiWra3Upr7diytJsjF4mPV2dW+eK5uNectiRj0xFxYI9NLXDbw==", + "license": "MIT", + "dependencies": { + "@types/markdown-it": "^14.0.0", + "markdown-it": "^14.0.0", + "prosemirror-model": "^1.25.0" } }, - "node_modules/@forge/react/node_modules/@atlaskit/visually-hidden": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@atlaskit/visually-hidden/-/visually-hidden-3.1.0.tgz", - "integrity": "sha512-OpwLmUZhbbo3NHKDjLl9JzKdHroeLPzRS1HTyHubJkC5DUWoOAH4cXStMpoesZ/Fqmbyz8O0Wb4K8RzpNZ7Jmw==", - "license": "Apache-2.0", + "node_modules/@forge/react/node_modules/prosemirror-transform": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.11.0.tgz", + "integrity": "sha512-4I7Ce4KpygXb9bkiPS3hTEk4dSHorfRw8uI0pE8IhxlK2GXsqv5tIA7JUSxtSu7u8APVOTtbUBxTmnHIxVkIJw==", + "license": "MIT", "dependencies": { - "@babel/runtime": "^7.0.0", - "@compiled/react": "^0.20.0" - }, - "peerDependencies": { - "react": "^18.2.0" + "prosemirror-model": "^1.21.0" } }, "node_modules/@forge/react/node_modules/react": { @@ -2280,35 +3814,6 @@ "node": ">=0.10.0" } }, - "node_modules/@forge/react/node_modules/react-dom": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", - "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", - "license": "MIT", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.2" - }, - "peerDependencies": { - "react": "^18.3.1" - } - }, - "node_modules/@forge/react/node_modules/react-popper": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.3.0.tgz", - "integrity": "sha512-e1hj8lL3uM+sgSR4Lxzn5h1GxBlpa4CQz0XLF8kx4MDrDRWY0Ena4c97PUeSX9i5W3UAfDP0z0FXCTQkoXUl3Q==", - "license": "MIT", - "dependencies": { - "react-fast-compare": "^3.0.1", - "warning": "^4.0.2" - }, - "peerDependencies": { - "@popperjs/core": "^2.0.0", - "react": "^16.8.0 || ^17 || ^18", - "react-dom": "^16.8.0 || ^17 || ^18" - } - }, "node_modules/@forge/react/node_modules/react-reconciler": { "version": "0.29.2", "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.29.2.tgz", @@ -2325,18 +3830,6 @@ "react": "^18.3.1" } }, - "node_modules/@forge/react/node_modules/react-scrolllock": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/react-scrolllock/-/react-scrolllock-5.0.1.tgz", - "integrity": "sha512-poeEsjnZAlpA6fJlaNo4rZtcip2j6l5mUGU/SJe1FFlicEudS943++u7ZSdA7lk10hoyYK3grOD02/qqt5Lxhw==", - "license": "MIT", - "dependencies": { - "exenv": "^1.2.2" - }, - "peerDependencies": { - "react": "^16.3.0" - } - }, "node_modules/@forge/react/node_modules/react-shallow-renderer": { "version": "16.15.0", "resolved": "https://registry.npmjs.org/react-shallow-renderer/-/react-shallow-renderer-16.15.0.tgz", @@ -2399,6 +3892,78 @@ "tslib": "^2.6.2" } }, + "node_modules/@formatjs/ecma402-abstract": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-2.3.6.tgz", + "integrity": "sha512-HJnTFeRM2kVFVr5gr5kH1XP6K0JcJtE7Lzvtr3FS/so5f1kpsqqqxy5JF+FRaO6H2qmcMfAUIox7AJteieRtVw==", + "license": "MIT", + "dependencies": { + "@formatjs/fast-memoize": "2.2.7", + "@formatjs/intl-localematcher": "0.6.2", + "decimal.js": "^10.4.3", + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/fast-memoize": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-2.2.7.tgz", + "integrity": "sha512-Yabmi9nSvyOMrlSeGGWDiH7rf3a7sIwplbvo/dlz9WCIjzIQAfy1RMf4S0X3yG724n5Ghu2GmEl5NJIV6O9sZQ==", + "license": "MIT", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/icu-messageformat-parser": { + "version": "2.11.4", + "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.11.4.tgz", + "integrity": "sha512-7kR78cRrPNB4fjGFZg3Rmj5aah8rQj9KPzuLsmcSn4ipLXQvC04keycTI1F7kJYDwIXtT2+7IDEto842CfZBtw==", + "license": "MIT", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.6", + "@formatjs/icu-skeleton-parser": "1.8.16", + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/icu-skeleton-parser": { + "version": "1.8.16", + "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.8.16.tgz", + "integrity": "sha512-H13E9Xl+PxBd8D5/6TVUluSpxGNvFSlN/b3coUp0e0JpuWXXnQDiavIpY3NnvSp4xhEMoXyyBvVfdFX8jglOHQ==", + "license": "MIT", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.6", + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/intl": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/@formatjs/intl/-/intl-3.1.8.tgz", + "integrity": "sha512-LWXgwI5zTMatvR8w8kCNh/priDTOF/ZssokMBHJ7ZWXFoYLVOYo0EJERD9Eajv+xsfQO1QkuAt77KWQ1OI4mOQ==", + "license": "MIT", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.6", + "@formatjs/fast-memoize": "2.2.7", + "@formatjs/icu-messageformat-parser": "2.11.4", + "intl-messageformat": "10.7.18", + "tslib": "^2.8.0" + }, + "peerDependencies": { + "typescript": "^5.6.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@formatjs/intl-localematcher": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.6.2.tgz", + "integrity": "sha512-XOMO2Hupl0wdd172Y06h6kLpBz6Dv+J4okPLl4LPtzbr8f66WbIoy4ev98EBuZ6ZK4h5ydTN6XneT4QVpD7cdA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.8.0" + } + }, "node_modules/@isaacs/nonrecursive-glob-match": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", @@ -2570,18 +4135,18 @@ "license": "MIT" }, "node_modules/@statsig/client-core": { - "version": "3.33.8", - "resolved": "https://registry.npmjs.org/@statsig/client-core/-/client-core-3.33.8.tgz", - "integrity": "sha512-5N1XnYMgjXGPwQFO2bsyq2i7NL2yh+Oi8NALIgKCxVL3333Le66iRemPyK61XjkuIXvlNRn7iwoEEdJ1DKxuMg==", + "version": "3.30.2", + "resolved": "https://registry.npmjs.org/@statsig/client-core/-/client-core-3.30.2.tgz", + "integrity": "sha512-F3u1+LDml6IFz/tMbSYI0pEOMR13OHM71lLJ3RuoWpK2KpCwfsHpt7kBmUKJxUXZ05CP/jWgmhG/ROj7eqDCPQ==", "license": "ISC" }, "node_modules/@statsig/js-client": { - "version": "3.33.8", - "resolved": "https://registry.npmjs.org/@statsig/js-client/-/js-client-3.33.8.tgz", - "integrity": "sha512-xyfeoSLqn+lJRWo+8k915vSJtf+iuglMakiYxhu0Y7Fjb01Gf1cLmjtuMJYdjC1XCkyGgmiHFDtlLVms7LOcUg==", + "version": "3.30.2", + "resolved": "https://registry.npmjs.org/@statsig/js-client/-/js-client-3.30.2.tgz", + "integrity": "sha512-Cjs4uzyAxt1sw44oa6qSNWuZdO11jmgrpOVBC2NajtpA55GBmAfjZ3vQdXizUffUZMRmFiEpGwxi9zmjFEG7Sw==", "license": "ISC", "dependencies": { - "@statsig/client-core": "3.33.8" + "@statsig/client-core": "3.30.2" } }, "node_modules/@types/history": { @@ -2590,6 +4155,18 @@ "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", "license": "MIT" }, + "node_modules/@types/hoist-non-react-statics": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.7.tgz", + "integrity": "sha512-PQTyIulDkIDro8P+IHbKCsw7U2xxBYflVzW/FgWdCAePD9xGSidgA76/GeJ6lBKoblyhf9pBY763gbrN+1dI8g==", + "license": "MIT", + "dependencies": { + "hoist-non-react-statics": "^3.3.0" + }, + "peerDependencies": { + "@types/react": "*" + } + }, "node_modules/@types/iframe-resizer": { "version": "3.5.13", "resolved": "https://registry.npmjs.org/@types/iframe-resizer/-/iframe-resizer-3.5.13.tgz", @@ -3108,6 +4685,12 @@ } } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "license": "MIT" + }, "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", @@ -3282,12 +4865,6 @@ "node": ">=8" } }, - "node_modules/eventemitter2": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-4.1.2.tgz", - "integrity": "sha512-erx0niBaTi8B7ywjGAcg8ilGNRl/xs/o4MO2ZMpRlpZ62mYzjGTBlOpxxRIrPQqBs9mbXkEux6aR+Sc5vQ/wUw==", - "license": "MIT" - }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", @@ -3552,6 +5129,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/hash-wasm": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/hash-wasm/-/hash-wasm-4.13.0.tgz", + "integrity": "sha512-GrWl7wsV46fKIXQZB5ebskLZLAmKL6d9RS0fspCxDeQyjoNu1AfTJTMLPOJyfzaQm0ldFiwFN21/w+sE/kgEFQ==", + "license": "MIT" + }, "node_modules/hasown": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", @@ -3664,6 +5247,18 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "license": "ISC" }, + "node_modules/intl-messageformat": { + "version": "10.7.18", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-10.7.18.tgz", + "integrity": "sha512-m3Ofv/X/tV8Y3tHXLohcuVuhWKo7BBq62cqY15etqmLxg2DZ34AGGgQDeR+SCta2+zICb1NX83af0GJmbQ1++g==", + "license": "BSD-3-Clause", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.6", + "@formatjs/fast-memoize": "2.2.7", + "@formatjs/icu-messageformat-parser": "2.11.4", + "tslib": "^2.8.0" + } + }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -3840,12 +5435,22 @@ "license": "MIT" }, "node_modules/linkify-it": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", - "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", + "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], "license": "MIT", "dependencies": { - "uc.micro": "^1.0.1" + "uc.micro": "^2.0.0" } }, "node_modules/lodash": { @@ -3902,31 +5507,6 @@ "markdown-it": "bin/markdown-it.mjs" } }, - "node_modules/markdown-it/node_modules/linkify-it": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", - "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/puzrin" - }, - { - "type": "github", - "url": "https://github.com/sponsors/markdown-it" - } - ], - "license": "MIT", - "dependencies": { - "uc.micro": "^2.0.0" - } - }, - "node_modules/markdown-it/node_modules/uc.micro": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", - "license": "MIT" - }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -4265,9 +5845,9 @@ } }, "node_modules/prosemirror-markdown": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.4.tgz", - "integrity": "sha512-D98dm4cQ3Hs6EmjK500TdAOew4Z03EV71ajEFiWra3Upr7diytJsjF4mPV2dW+eK5uNectiRj0xFxYI9NLXDbw==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.2.tgz", + "integrity": "sha512-FPD9rHPdA9fqzNmIIDhhnYQ6WgNoSWX9StUZ8LEKapaXU9i6XgykaHKhp6XMyXlOWetmaFgGDS/nu/w9/vUc5g==", "license": "MIT", "dependencies": { "@types/markdown-it": "^14.0.0", @@ -4296,9 +5876,9 @@ } }, "node_modules/prosemirror-transform": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.11.0.tgz", - "integrity": "sha512-4I7Ce4KpygXb9bkiPS3hTEk4dSHorfRw8uI0pE8IhxlK2GXsqv5tIA7JUSxtSu7u8APVOTtbUBxTmnHIxVkIJw==", + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.10.5.tgz", + "integrity": "sha512-RPDQCxIDhIBb1o36xxwsaeAvivO8VLJcgBtzmOwQ64bMtsVFh5SSuJ6dWSxO1UsHTiTXPCgQm3PDJt7p6IOLbw==", "license": "MIT", "dependencies": { "prosemirror-model": "^1.21.0" @@ -4315,16 +5895,25 @@ } }, "node_modules/prosemirror-view": { - "version": "1.41.7", - "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.7.tgz", - "integrity": "sha512-jUwKNCEIGiqdvhlS91/2QAg21e4dfU5bH2iwmSDQeosXJgKF7smG0YSplOWK0cjSNgIqXe7VXqo7EIfUFJdt3w==", + "version": "1.44.1", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.44.1.tgz", + "integrity": "sha512-Nbt8y1j4RI1PR/iuarAWTQ9ja/jgy9QaxEUdRdAcitfMxV8I/f15/0IO4b2jwbSN/p10tiaNfvmSjHVn641s3A==", "license": "MIT", "dependencies": { - "prosemirror-model": "^1.20.0", + "prosemirror-model": "^1.25.12", "prosemirror-state": "^1.0.0", "prosemirror-transform": "^1.1.0" } }, + "node_modules/prosemirror-view/node_modules/prosemirror-model": { + "version": "1.25.13", + "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.13.tgz", + "integrity": "sha512-MlDMWGjYXaYOeCiO17jcybntCOzPnN+97U0809ke2QsgPtxW3n5/sD6ZKyJONUgMw1iP93ohZTjeKjnRJ7L6kQ==", + "license": "MIT", + "dependencies": { + "orderedmap": "^2.0.0" + } + }, "node_modules/punycode.js": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", @@ -4362,31 +5951,48 @@ } }, "node_modules/react-dom": { - "version": "19.3.1", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", - "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "license": "MIT", "peer": true, "dependencies": { - "scheduler": "^0.28.0" + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" }, "peerDependencies": { - "react": "^19.3.1" + "react": "^18.3.1" } }, - "node_modules/react-dom/node_modules/scheduler": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", - "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", - "license": "MIT", - "peer": true - }, "node_modules/react-fast-compare": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.4.tgz", "integrity": "sha512-YbkgZfjvuokdt6zR8Oki8Bt4QXAZim/9HKSUr5J23GVyX2o8sYD/JlKSFrJvEFIPjotWvkGY7DgUS+udyr8cEw==", "license": "MIT" }, + "node_modules/react-focus-lock": { + "version": "2.13.7", + "resolved": "https://registry.npmjs.org/react-focus-lock/-/react-focus-lock-2.13.7.tgz", + "integrity": "sha512-20lpZHEQrXPb+pp1tzd4ULL6DyO5D2KnR0G69tTDdydrmNhU7pdFmbQUYVyHUgp+xN29IuFR0PVuhOmvaZL9Og==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.0.0", + "focus-lock": "^1.3.6", + "prop-types": "^15.6.2", + "react-clientside-effect": "^1.2.7", + "use-callback-ref": "^1.3.3", + "use-sidecar": "^1.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/react-hook-form": { "version": "7.65.0", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.65.0.tgz", @@ -4403,6 +6009,31 @@ "react": "^16.8.0 || ^17 || ^18 || ^19" } }, + "node_modules/react-intl": { + "version": "7.1.14", + "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-7.1.14.tgz", + "integrity": "sha512-VE/0Wi/lHJlBC7APQpCzLUdIt3GB5B0GZrRW8Q+ACbkHI4j+Wwgg9J1TniN6zmLHmPH5gxXcMy+fkSPfw5p1WQ==", + "license": "BSD-3-Clause", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.6", + "@formatjs/icu-messageformat-parser": "2.11.4", + "@formatjs/intl": "3.1.8", + "@types/hoist-non-react-statics": "^3.3.1", + "@types/react": "16 || 17 || 18 || 19", + "hoist-non-react-statics": "^3.3.2", + "intl-messageformat": "10.7.18", + "tslib": "^2.8.0" + }, + "peerDependencies": { + "react": "16 || 17 || 18 || 19", + "typescript": "^5.6.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -4427,6 +6058,18 @@ } } }, + "node_modules/react-scrolllock": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-scrolllock/-/react-scrolllock-5.0.1.tgz", + "integrity": "sha512-poeEsjnZAlpA6fJlaNo4rZtcip2j6l5mUGU/SJe1FFlicEudS943++u7ZSdA7lk10hoyYK3grOD02/qqt5Lxhw==", + "license": "MIT", + "dependencies": { + "exenv": "^1.2.2" + }, + "peerDependencies": { + "react": "^16.3.0" + } + }, "node_modules/react-uid": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/react-uid/-/react-uid-2.4.0.tgz", @@ -4690,9 +6333,9 @@ } }, "node_modules/uc.micro": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", "license": "MIT" }, "node_modules/undici": { @@ -4704,6 +6347,27 @@ "node": ">=20.18.1" } }, + "node_modules/use-callback-ref": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", + "integrity": "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/use-isomorphic-layout-effect": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.2.1.tgz", @@ -4718,18 +6382,39 @@ } } }, + "node_modules/use-sidecar": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", + "integrity": "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==", + "license": "MIT", + "dependencies": { + "detect-node-es": "^1.1.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.1.tgz", + "integrity": "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" ], "license": "MIT", "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/w3c-keyname": { diff --git a/coderhelm-jira/package.json b/coderhelm-jira/package.json index 58f1af792..ebe061378 100644 --- a/coderhelm-jira/package.json +++ b/coderhelm-jira/package.json @@ -4,13 +4,14 @@ }, "dependencies": { "@forge/api": "^7.1.1", - "@forge/bridge": "^5.17.0", - "@forge/react": "^11.17.0", + "@forge/bridge": "^7.4.0", + "@forge/react": "^12.6.0", "@forge/resolver": "^1.8.0", "@forge/ui": "^1.11.4", "react": "^19.3.1" }, "overrides": { - "glob": "^14.0.2" + "glob": "^14.0.2", + "prosemirror-view": "^1.42.3" } } From 961cc69f76a2ec98724055fc7244b747b74efcbf Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 20:50:13 -0500 Subject: [PATCH 11/19] Jira app: React 18, the one UI Kit runs on, so the link screen has a single React --- coderhelm-jira/package-lock.json | 73 +++++++++----------------------- coderhelm-jira/package.json | 2 +- 2 files changed, 20 insertions(+), 55 deletions(-) diff --git a/coderhelm-jira/package-lock.json b/coderhelm-jira/package-lock.json index 617698893..0a089a3e6 100644 --- a/coderhelm-jira/package-lock.json +++ b/coderhelm-jira/package-lock.json @@ -10,7 +10,7 @@ "@forge/react": "^12.6.0", "@forge/resolver": "^1.8.0", "@forge/ui": "^1.11.4", - "react": "^19.3.1" + "react": "^18.3.1" } }, "node_modules/@atlaskit/adf-schema": { @@ -223,19 +223,6 @@ "prosemirror-model": "^1.21.0" } }, - "node_modules/@atlaskit/adf-utils/node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/@atlaskit/app-provider": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/@atlaskit/app-provider/-/app-provider-8.3.0.tgz", @@ -1497,6 +1484,18 @@ "react-dom": "^18.2.0" } }, + "node_modules/@atlaskit/modal-dialog/node_modules/react-scrolllock": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-scrolllock/-/react-scrolllock-5.0.1.tgz", + "integrity": "sha512-poeEsjnZAlpA6fJlaNo4rZtcip2j6l5mUGU/SJe1FFlicEudS943++u7ZSdA7lk10hoyYK3grOD02/qqt5Lxhw==", + "license": "MIT", + "dependencies": { + "exenv": "^1.2.2" + }, + "peerDependencies": { + "react": "^16.3.0" + } + }, "node_modules/@atlaskit/motion": { "version": "10.0.4", "resolved": "https://registry.npmjs.org/@atlaskit/motion/-/motion-10.0.4.tgz", @@ -3391,19 +3390,6 @@ } } }, - "node_modules/@forge/bridge/node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/@forge/egress": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/@forge/egress/-/egress-2.3.2.tgz", @@ -3802,18 +3788,6 @@ "prosemirror-model": "^1.21.0" } }, - "node_modules/@forge/react/node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", - "license": "MIT", - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/@forge/react/node_modules/react-reconciler": { "version": "0.29.2", "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.29.2.tgz", @@ -5930,10 +5904,13 @@ "license": "MIT" }, "node_modules/react": { - "version": "19.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", - "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, "engines": { "node": ">=0.10.0" } @@ -6058,18 +6035,6 @@ } } }, - "node_modules/react-scrolllock": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/react-scrolllock/-/react-scrolllock-5.0.1.tgz", - "integrity": "sha512-poeEsjnZAlpA6fJlaNo4rZtcip2j6l5mUGU/SJe1FFlicEudS943++u7ZSdA7lk10hoyYK3grOD02/qqt5Lxhw==", - "license": "MIT", - "dependencies": { - "exenv": "^1.2.2" - }, - "peerDependencies": { - "react": "^16.3.0" - } - }, "node_modules/react-uid": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/react-uid/-/react-uid-2.4.0.tgz", diff --git a/coderhelm-jira/package.json b/coderhelm-jira/package.json index ebe061378..498882d5b 100644 --- a/coderhelm-jira/package.json +++ b/coderhelm-jira/package.json @@ -8,7 +8,7 @@ "@forge/react": "^12.6.0", "@forge/resolver": "^1.8.0", "@forge/ui": "^1.11.4", - "react": "^19.3.1" + "react": "^18.3.1" }, "overrides": { "glob": "^14.0.2", From cb2ca0dbe0950f85d5b1be6a2a6d27526961659d Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 20:57:57 -0500 Subject: [PATCH 12/19] For you: an approved plan is coded as shown The answer run takes up the planning run's plan (resume_from) instead of planning again with the answer in the plan's key. --- services/gateway/src/routes/run_answer.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/gateway/src/routes/run_answer.rs b/services/gateway/src/routes/run_answer.rs index afe263bc7..76d43c6eb 100644 --- a/services/gateway/src/routes/run_answer.rs +++ b/services/gateway/src/routes/run_answer.rs @@ -215,6 +215,12 @@ pub async fn answer( // history (the worker merges them in). ticket.answers = answers.clone(); ticket.new_run_id = Some(new_run_id.clone()); + // An approved plan (For you's "Draft a plan first") is coded as shown: + // the new run takes up this run's plan instead of planning again with + // the answer in its key. + if common::foryou::plan_approved(&answers) { + ticket.resume_from = Some(run_id.to_string()); + } claim( state, From 86de848fa1c01e24c5c740c63af5d4f40e62cbee Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 21:59:40 -0500 Subject: [PATCH 13/19] Jira link: a strict, size-limited request with no field it doesn't know The link webhook reads its body into a typed struct (deny_unknown_fields, plain bounded strings, 2 KiB at most) instead of a JSON value, checks the code's signature before any read, and uses the code up only while it is unexpired, in the same conditional delete. --- services/gateway/src/routes/foryou_link.rs | 110 ++++++++++++++++----- 1 file changed, 88 insertions(+), 22 deletions(-) diff --git a/services/gateway/src/routes/foryou_link.rs b/services/gateway/src/routes/foryou_link.rs index 6cdc4bc0d..795d0a585 100644 --- a/services/gateway/src/routes/foryou_link.rs +++ b/services/gateway/src/routes/foryou_link.rs @@ -23,6 +23,7 @@ use aws_sdk_dynamodb::types::AttributeValue; use axum::body::Bytes; use axum::{extract::State, http::StatusCode, Extension, Json}; use common::foryou; +use serde::Deserialize; use serde_json::{json, Value}; use tracing::{info, warn}; @@ -178,23 +179,55 @@ pub async fn not_me( Ok(Json(json!({ "ok": true }))) } +/// The largest link request taken. The real one is a few hundred bytes. +pub const MAX_LINK_BODY: usize = 2048; + +/// The team's proof, as the Jira app sends it (`linkBody` in +/// `coderhelm-jira/src/link.js`). Nothing else is accepted. +#[derive(Debug, Deserialize)] +#[serde(deny_unknown_fields)] +struct LinkProof { + team_id: String, + forge_secret: String, + #[serde(default)] + app_version: Option, + #[serde(default)] + app_id: Option, +} + +/// A link request: plain strings only, every field known, nothing dynamic. +#[derive(Debug, Deserialize)] +#[serde(deny_unknown_fields)] +struct LinkRequest { + coderhelm: LinkProof, + #[serde(default)] + account_id: String, + #[serde(default)] + code: String, +} + /// What the Jira app sent, checked: the team, its proof, the account and -/// the code. -fn read_link(body: &Value) -> Result<(String, String, String, String), StatusCode> { - let team = body - .pointer("/coderhelm/team_id") - .and_then(|v| v.as_str()) - .unwrap_or("") - .trim(); - let secret = body - .pointer("/coderhelm/forge_secret") - .and_then(|v| v.as_str()) - .unwrap_or(""); - let account = body["account_id"].as_str().unwrap_or("").trim(); - let code = body["code"].as_str().unwrap_or("").trim(); +/// the code. Over-long bodies and any field this doesn't know are refused +/// before anything is read; each string is bounded. +fn read_link(body: &[u8]) -> Result<(String, String, String, String), StatusCode> { + if body.is_empty() || body.len() > MAX_LINK_BODY { + return Err(StatusCode::PAYLOAD_TOO_LARGE); + } + let req: LinkRequest = serde_json::from_slice(body).map_err(|_| StatusCode::BAD_REQUEST)?; + let short = |v: &Option| v.as_deref().is_none_or(|x| x.len() <= 128); + if !short(&req.coderhelm.app_version) || !short(&req.coderhelm.app_id) { + return Err(StatusCode::BAD_REQUEST); + } + let team = req.coderhelm.team_id.trim(); + let secret = req.coderhelm.forge_secret.as_str(); + let account = req.account_id.trim(); + let code = req.code.trim(); if team.is_empty() || secret.is_empty() { return Err(StatusCode::UNAUTHORIZED); } + if team.len() > 128 || secret.len() > 256 { + return Err(StatusCode::BAD_REQUEST); + } if !foryou::valid_account_id(account) || code.is_empty() || code.len() > 40 { return Err(StatusCode::BAD_REQUEST); } @@ -225,10 +258,7 @@ pub async fn forge_link( State(state): State>, body: Bytes, ) -> (StatusCode, Json) { - let Ok(payload) = serde_json::from_slice::(&body) else { - return answer(StatusCode::BAD_REQUEST, "That request couldn't be read."); - }; - let (team, secret, account, code) = match read_link(&payload) { + let (team, secret, account, code) = match read_link(&body) { Ok(x) => x, Err(c) => return answer(c, "That request is missing what CoderHelm needs."), }; @@ -270,7 +300,11 @@ pub async fn forge_link( .table_name(&state.config.settings_table_name) .key("pk", s(&team)) .key("sk", s(&foryou::code_sk(&team, &code))) - .condition_expression("attribute_exists(sk)") + .condition_expression("attribute_exists(sk) AND expires_at > :now") + .expression_attribute_values( + ":now", + aws_sdk_dynamodb::types::AttributeValue::N(now().to_string()), + ) .return_values(aws_sdk_dynamodb::types::ReturnValue::AllOld) .send() .await; @@ -435,15 +469,47 @@ mod tests { #[test] fn a_link_request_needs_the_team_its_proof_an_account_and_a_code() { - let ok = json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "ABCD-EFGH-JKMN-PQRS"}); + let b = |v: Value| serde_json::to_vec(&v).unwrap(); + let ok = b( + json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x", "app_version": "7.1.0"}, "account_id": "557058:a1b2c3d4", "code": "ABCD-EFGH-JKMN-PQRS"}), + ); let (team, _, account, _) = read_link(&ok).unwrap(); assert_eq!(team, "TEAM#acme1"); assert_eq!(account, "557058:a1b2c3d4"); - let no_secret = json!({"coderhelm": {"team_id": "acme1"}, "account_id": "557058:a1b2c3d4", "code": "x"}); + let no_secret = b( + json!({"coderhelm": {"team_id": "acme1", "forge_secret": ""}, "account_id": "557058:a1b2c3d4", "code": "x"}), + ); assert_eq!(read_link(&no_secret).unwrap_err(), StatusCode::UNAUTHORIZED); - let bad_id = json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "x\" OR 1=1", "code": "c"}); + let bad_id = b( + json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "x\" OR 1=1", "code": "c"}), + ); assert_eq!(read_link(&bad_id).unwrap_err(), StatusCode::BAD_REQUEST); - let no_code = json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4"}); + let no_code = b( + json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4"}), + ); assert_eq!(read_link(&no_code).unwrap_err(), StatusCode::BAD_REQUEST); } + + #[test] + fn a_link_request_is_small_plain_and_has_no_field_it_doesnt_know() { + let b = |v: Value| serde_json::to_vec(&v).unwrap(); + let extra = b( + json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "c", "user": "u_other"}), + ); + assert_eq!(read_link(&extra).unwrap_err(), StatusCode::BAD_REQUEST); + let nested = b( + json!({"coderhelm": {"team_id": {"$ne": ""}, "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "c"}), + ); + assert_eq!(read_link(&nested).unwrap_err(), StatusCode::BAD_REQUEST); + let big = vec![b' '; MAX_LINK_BODY + 1]; + assert_eq!(read_link(&big).unwrap_err(), StatusCode::PAYLOAD_TOO_LARGE); + assert_eq!(read_link(b"").unwrap_err(), StatusCode::PAYLOAD_TOO_LARGE); + let long_version = b( + json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x", "app_version": "9".repeat(200)}, "account_id": "557058:a1b2c3d4", "code": "c"}), + ); + assert_eq!( + read_link(&long_version).unwrap_err(), + StatusCode::BAD_REQUEST + ); + } } From a9695a46b18dab1bfd277ced49a4859946b4dd02 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 22:02:13 -0500 Subject: [PATCH 14/19] For you: the real plan and steps, Nudge, tests read from the repo, seen-on tickets, linking on self-hosted installs - GET /api/foryou/plan: a run's plan as written (common::plan_view), and the question to answer while it waits; the give preview shows it. - POST/DELETE /api/foryou/nudge: a GitHub comment to the one person a pull request waits on, naming who asked, once a day, with undo. - The fit's tests signal reads the repository (tree and workflows) instead of check names (foryou_tests, kept ten minutes per installation). - Is this you? carries the tickets the account was seen on. - Jira linking on self-hosted installs goes through the relay, sent once with the install's answer handed back (hybrid::relay_now). - Need rows link to /foryou/answer and /foryou/pr. --- docs/for-you.md | 19 +- services/common/src/foryou.rs | 308 +++++++++++++++- services/common/src/lib.rs | 1 + services/common/src/plan_view.rs | 250 +++++++++++++ services/gateway/src/main.rs | 5 + services/gateway/src/permissions.rs | 5 +- services/gateway/src/routes/api.rs | 32 +- services/gateway/src/routes/foryou.rs | 90 +++-- services/gateway/src/routes/foryou/tests.rs | 136 ++++++- services/gateway/src/routes/foryou_give.rs | 55 ++- services/gateway/src/routes/foryou_link.rs | 57 ++- services/gateway/src/routes/foryou_nudge.rs | 342 ++++++++++++++++++ services/gateway/src/routes/foryou_plan.rs | 149 ++++++++ services/gateway/src/routes/foryou_tests.rs | 157 ++++++++ services/gateway/src/routes/hybrid.rs | 77 ++++ services/gateway/src/routes/hybrid_install.rs | 46 +++ services/gateway/src/routes/jira_webhook.rs | 39 ++ services/gateway/src/routes/mod.rs | 3 + .../passes/incidents/bm_teams_never_cross.rs | 1 + .../incidents/ya_for_you_is_only_yours.rs | 4 + 20 files changed, 1715 insertions(+), 61 deletions(-) create mode 100644 services/common/src/plan_view.rs create mode 100644 services/gateway/src/routes/foryou_nudge.rs create mode 100644 services/gateway/src/routes/foryou_plan.rs create mode 100644 services/gateway/src/routes/foryou_tests.rs diff --git a/docs/for-you.md b/docs/for-you.md index b9f980880..61e73c208 100644 --- a/docs/for-you.md +++ b/docs/for-you.md @@ -8,7 +8,8 @@ Every route reads the session's team and the session's user. None takes a user, - **GitHub**: the login on the session (`claims.github_login`), set by GitHub sign-in. - **Jira**: the account the person linked themselves. On the dashboard, `POST /api/foryou/link/jira` makes a one-time code (16 characters, signed for the team, 15 minutes, stored by its hash under `FORYOU#CODE#`). In Jira, the app's **Link my CoderHelm account** issue action (`coderhelm-jira/src/link.js`) sends it with the account id Forge gives for the person who opened it, to `POST /webhooks/jira-link`, proven by the site's Forge secret. The code is checked against its signature first, then used up in the same delete that reads it. The link is two rows on the settings table: `FORYOU#JIRA#` (the account id) and `linked_user` on the account's own `JIRAUSER#` row. An account is linked to one person at a time. `DELETE /api/foryou/link/jira` removes both. -- An email never makes a link. A Jira user seen with the person's sign-in email, linked to nobody, is offered as "Is this you?" (`common::foryou::identity_suggestion`); yes starts the code flow, `POST /api/foryou/link/jira/not-me` stops asking. Chat's "what needs me" (`chat_work_needs::gather`) reads the same link and nothing else. +- **Self-hosted installs**: the code is made, checked and kept on the install, where the people are. When the Jira site's app was set up with an install's id, `POST /webhooks/jira-link` forwards the request to that install unchanged (the install checks the Forge secret itself); when a hosted team's site is linked to an install, CoderHelm checks the site's Forge secret, removes it, and forwards the request signed. Either way it is sent once and the install's answer is handed back to the Jira screen (`hybrid::relay_now`, never queued for a retry); the install takes it as a `jira` relay event `link` or `site_link` (`hybrid_install::intake`) and links with `foryou_link::link_with_code`. +- An email never makes a link. A Jira user seen with the person's sign-in email, linked to nobody, is offered as "Is this you?" (`common::foryou::identity_suggestion`); yes starts the code flow, `POST /api/foryou/link/jira/not-me` stops asking. The suggestion names the tickets the account was seen on (`seen_on`, the first few keys, kept on its `JIRAUSER#` row by the Jira webhook). Chat's "what needs me" (`chat_work_needs::gather`) reads the same link and nothing else. ## What it reads (nothing forked) @@ -16,6 +17,7 @@ Every route reads the session's team and the session's user. None takes a user, - **Runs, held tool calls, Jira mentions and assigned tickets**: `chat_work_needs::gather`, with the runs read once and the linked account passed in, GitHub left to the records. - **The open sprint**: the Jira app's get-issues trigger with `{ "sprint": { "account_id" } }`. The app runs as itself, so the account id is written into the JQL: `assignee = "" AND sprint in openSprints() AND statusCategory != Done ORDER BY rank ASC`. Story points and the sprint field are found per site by type (`fieldIds`). An app without the mode answers without `sprint`: the page says the site's app is older. - **History**: `pr_history::all_since` (90 days), for the review turnaround and the files a person changed. +- **Tests, from the repository**: for each sprint ticket's single repository (at most six a page), the file tree of its default branch and up to eight workflow files, through the team's GitHub app (`foryou_tests`, kept ten minutes per installation and repository). The test step CI runs comes from `common::test_env`, the test files from `setup::facts::is_test_path`; `common::foryou::tests_signal` says which, and the test files beside the files the ticket names. - The heavy reads are kept 30 seconds per installation, team and user (`foryou::READS`); the person's settings are read fresh. ## The fit bands @@ -23,14 +25,19 @@ Every route reads the session's team and the session's user. None takes a user, `common::foryou::fit`, a checklist with reasons and what is missing, never a percentage: - **Not suggested**: on the exclude list by title, type, labels or components (security, auth and permissions, personal data, incidents, production-critical, highest priority, three or more repositories), 8 points or more, or neither a repository nor acceptance criteria. -- **Good fit**: acceptance criteria, one repository known (a `coderhelm:` label, a repository the ticket names, or where the project's earlier runs went), 3 points or less (or a short description with no estimate), files or an area named, and tests not known to be missing. +- **Good fit**: acceptance criteria, one repository known (a `coderhelm:` label, a repository the ticket names, or where the project's earlier runs went), 3 points or less (or a short description with no estimate), files or an area named, and tests not known to be missing (a repository read with neither a CI test step nor test files has none CoderHelm can run). - **Maybe (plan first)**: the rest. ## Give to CoderHelm -- `GET /api/foryou/give?key=` previews: the fit, the repositories, the files named, the criteria, and that the plan comes first (the planner has no dry-run mode). +- `GET /api/foryou/give?key=` previews: the fit, the repositories, the files named, the criteria, and the plan the ticket's newest run wrote (`plan.view`, from its `tasks.md` and `design.md`), or what happens when there is none yet. - `POST /api/foryou/give {key, plan_first}` (the "runs" capability) accepts only a ticket in the person's own open sprint, writes `FORYOU#GIVE#` (the owner, their Jira account, `plan_first`), and asks the Jira app (`{ "give": { key, label, account_id } }`) to add the team's trigger label. The app checks the ticket is assigned to that account first. Jira sends the change like any label, and the run starts on the label path (`jira_webhook::ticket_triggers`); `foryou_give::owner_for_event` credits the person who gave it as the requester, once, within 15 minutes. CoderHelm is the delegate; the ticket stays assigned to the person. Answered `202` at once. -- With `plan_first`, the worker stops once the plan passes its checks and asks `common::foryou::PLAN_QUESTION`. The stop judge settles it by rule (`Picture::plan_first_for`, `PersonOnly::PlanApproval`): no model call, no default, no deadline. Answering "Approve the plan and start coding" on the run page starts the next run, which codes and marks the give approved. +- With `plan_first`, the worker stops once the plan passes its checks and asks `common::foryou::PLAN_QUESTION`. The stop judge settles it by rule (`Picture::plan_first_for`, `PersonOnly::PlanApproval`): no model call, no default, no deadline. This is the plan-only mode: the run plans, saves the plan and codes nothing. `GET /api/foryou/plan?run=` returns the plan as written (`common::plan_view`: the steps per repository with what is done, the files it names, its test steps) and, while the run waits, the question to answer (`awaiting_ok`). Approving it ("Approve the plan and start coding", `POST /api/runs/:id/answer`) starts the next run on that same plan (`resume_from`), which codes and marks the give approved; asking for a change plans again with the words given. +- The same `GET /api/foryou/plan` is the step checklist of a run at work: the implement pass ticks `- [x]` as it goes. + +## Nudge + +`POST /api/foryou/nudge {repo, number}` reminds the one person a pull request of yours waits on, as a GitHub comment that @mentions them and names who asked ("Hi @mara, a friendly reminder from @dana-ortiz ... @dana-ortiz can undo it", `common::foryou::nudge_text`). The pull request, the turn and the person are read again from the team's records; a team, CoderHelm or a check is never nudged. One per pull request a day: `FORYOU#NUDGE##` claimed with a `ttl` (`common::claim`). `DELETE` with the same body (only by whoever sent it) deletes the comment and frees the day. Team Slack channels are webhooks, which can neither mention a person nor take a message back, so they aren't used. Each waiting row carries `nudge {to, sent}`. ## Suggestions @@ -56,7 +63,7 @@ A suggestion stays about a week when nothing changes, then rests. A changed basi }, "sprint": {"state": "ok|not_linked|not_connected|app_old|failed", "detail": "", "meta": {"name": "Sprint 24", "project": "ENG", "end_date": "...", "days_left": 6, "points": 21}, "tickets": [Ticket]}, "working": [{"run_id": "...", "ticket": "ENG-142", "repo": "acme/web", "title": "...", "started_at": "...", "stage": "planning|coding|ci|waiting", "stage_label": "CI", "note": "...", "waiting_on_you": false, "plan_first": false, "owner": "you", "delegate": "CoderHelm", "pr": {"url": "...", "number": "491"}, "href": "/runs/detail?id=..."}], - "waiting": [{"key": "pr:acme/api#477", "where": "acme/api#477", "title": "...", "next": {"who": "mara", "what": "needs review", "text": "...", "turn": "person"}, "since": "...", "by_coderhelm": false, "href": "...", "nudge_href": "..."}], + "waiting": [{"key": "pr:acme/api#477", "where": "acme/api#477", "title": "...", "next": {"who": "mara", "what": "needs review", "text": "...", "turn": "person"}, "since": "...", "by_coderhelm": false, "href": "...", "nudge_href": "...", "pr": {"repo": "acme/api", "number": 477}, "nudge": {"to": "mara", "sent": null}}], "later": [{"key": "...", "later": "snoozed|not_in_sprint|fyi", "title": "...", "where": "...", "snoozed_until": "...", "href": "..."}], "stats": { "waiting_on_you": {"count": 6, "oldest": {"where": "acme/web#482", "since": "..."}}, @@ -83,4 +90,4 @@ The stats are the session's own; nothing else computes them, and no route reads ## Permissions -`GET /api/foryou` and the preview need "view". Settings, marks, suggestions and linking are the person's own ("own_account"). Giving a ticket needs "runs". +`GET /api/foryou` and the preview need "view". Settings, marks, suggestions and linking are the person's own ("own_account"). Giving a ticket needs "runs"; a nudge and its undo need "reviews". The plan needs "view", like the run page's. diff --git a/services/common/src/foryou.rs b/services/common/src/foryou.rs index c85b9e81e..b0861543f 100644 --- a/services/common/src/foryou.rs +++ b/services/common/src/foryou.rs @@ -154,6 +154,39 @@ pub struct SeenJiraUser { pub email: String, /// Already linked to someone. pub linked: bool, + /// Tickets this account was seen on (the first few), so "Is this you?" + /// shows where the match came from. + pub seen_on: Vec, +} + +/// How many tickets a seen Jira account keeps as where it was seen. +pub const SEEN_ON_KEEP: usize = 5; + +/// The tickets to show for a match: valid keys only, sorted, at most +/// [`SEEN_ON_KEEP`]. +pub fn seen_on_shown(keys: &[String]) -> Vec { + let mut out: Vec = keys + .iter() + .map(|k| k.trim().to_string()) + .filter(|k| is_ticket_key(k)) + .collect(); + out.sort(); + out.dedup(); + out.truncate(SEEN_ON_KEEP); + out +} + +/// A Jira issue key: a project key (a letter, then letters, digits or `_`) +/// and a number. +pub fn is_ticket_key(k: &str) -> bool { + let Some((p, n)) = k.split_once('-') else { + return false; + }; + p.chars().next().is_some_and(|c| c.is_ascii_uppercase()) + && p.chars() + .all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_') + && !n.is_empty() + && n.chars().all(|c| c.is_ascii_digit()) } /// The one Jira user that may be offered as "Is this you?": seen with this @@ -176,6 +209,67 @@ pub fn identity_suggestion<'a>( hits.next().is_none().then_some(first) } +// ── Nudges ────────────────────────────────────────────────────────────────── + +/// One nudge per pull request per team at a time: `pk` = team, this + the +/// pull request, with a `ttl` a day out ([`NUDGE_SECS`]). +pub const NUDGE_PREFIX: &str = "FORYOU#NUDGE#"; +/// How long a nudge holds the pull request: at most one a day. +pub const NUDGE_SECS: u64 = 86_400; + +pub fn nudge_sk(repo: &str, number: u64) -> String { + format!("{NUDGE_PREFIX}{}#{number}", repo.to_ascii_lowercase()) +} + +/// A nudge sent, as the page shows it and Undo needs it. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct Nudged { + /// The CoderHelm user who asked for it (only they can undo it). + pub by_user: String, + /// Their GitHub login, named in the comment. + pub by_login: String, + /// Who was reminded. + pub to: String, + /// When (unix seconds). + pub at: i64, + /// The comment on the pull request. + pub comment_id: u64, + pub comment_url: String, +} + +/// The reminder's words: polite, names who asked, says what is waiting, +/// and how to stop it. +pub fn nudge_text(to: &str, by: &str, waiting_for: &str) -> String { + let what = waiting_for.trim().trim_end_matches('.'); + let what = if what.is_empty() { + "it's waiting on you".to_string() + } else { + let mut c = what.chars(); + match c.next() { + Some(f) => format!("{}{}", f.to_lowercase(), c.as_str()), + None => String::new(), + } + }; + format!( + "Hi @{to}, a friendly reminder from @{by}: this pull request is waiting on you ({what}). \ + No rush if it's already on your list, and thank you!\n\n\ + Sent by CoderHelm when @{by} pressed Nudge. One reminder a day at most; @{by} can undo it." + ) +} + +/// Whether a nudge can go: the pull request is the person's own, waiting on +/// one other person (not a team, CoderHelm or a check). +pub fn nudge_target(turn: &str, next_from: &[String], me: &str) -> Option { + if turn != "person" { + return None; + } + next_from + .iter() + .find_map(|f| f.strip_prefix("person:")) + .filter(|p| !p.is_empty() && !p.eq_ignore_ascii_case(me)) + .map(str::to_string) +} + // ── The person's own settings ─────────────────────────────────────────────── /// The page's sections, in their default order. @@ -411,8 +505,106 @@ pub struct TicketFacts { /// empty. pub repo_source: String, /// Whether the (single) repository has tests CoderHelm can run, when - /// known. + /// known ([`tests_signal`]). pub tests: Option, + /// What was found, in words, for the "why" line. + pub tests_why: String, +} + +// ── Tests, read from the repository ───────────────────────────────────────── + +/// What a repository holds for tests, read from its default branch: the +/// test step its CI runs and its test files. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct RepoTests { + /// The first test command CI runs (`test_env`), if any. + pub command: Option, + /// The workflow and job it is in. + pub ci: String, + /// The test files (`setup::facts::is_test_path`), at most [`TEST_PATHS_KEPT`]. + pub test_paths: Vec, +} + +pub const TEST_PATHS_KEPT: usize = 5_000; + +/// Reads a repository's tests from its workflow files (`(path, text)`) and +/// its file tree. +pub fn repo_tests(workflows: &[(String, String)], tree: &[String]) -> RepoTests { + let env = crate::test_env::from_workflows(workflows, tree); + RepoTests { + command: env + .as_ref() + .and_then(|e| e.test.first().cloned()) + .filter(|c| !c.trim().is_empty()), + ci: env.map(|e| e.source).unwrap_or_default(), + test_paths: tree + .iter() + .filter(|p| crate::setup::facts::is_test_path(p)) + .take(TEST_PATHS_KEPT) + .cloned() + .collect(), + } +} + +/// The test files beside the files a ticket names: in the same folder, a +/// `__tests__` or `tests` folder next to it, or named after it. +pub fn tests_near(rt: &RepoTests, named: &[String]) -> Vec { + let mut out: Vec = Vec::new(); + for f in named { + let f = f.trim_start_matches("./"); + let (dir, file) = f.rsplit_once('/').unwrap_or(("", f)); + let stem = file.split('.').next().unwrap_or(file).to_ascii_lowercase(); + for t in &rt.test_paths { + let (tdir, tfile) = t.rsplit_once('/').unwrap_or(("", t.as_str())); + let beside = tdir == dir + || tdir == format!("{dir}/__tests__").trim_start_matches('/') + || tdir == format!("{dir}/tests").trim_start_matches('/'); + let named_after = + !stem.is_empty() && tfile.to_ascii_lowercase().starts_with(&format!("{stem}.")); + if (beside || named_after) && !out.contains(t) { + out.push(t.clone()); + } + } + } + out.sort(); + out.truncate(5); + out +} + +/// Whether a repository has tests CoderHelm can run, and why, from what was +/// read. `None` when the repository wasn't read. +pub fn tests_signal( + repo: &str, + rt: Option<&RepoTests>, + named: &[String], +) -> (Option, String) { + let Some(rt) = rt else { + return (None, String::new()); + }; + let near = tests_near(rt, named); + let near_words = match near.as_slice() { + [] => String::new(), + [one] => format!(", with {one} beside the files the ticket names"), + [first, rest @ ..] => format!( + ", with {first} and {} more beside the files the ticket names", + rest.len() + ), + }; + match &rt.command { + Some(c) => ( + Some(true), + format!("Tests run in {repo}'s CI (`{c}`){near_words}"), + ), + None if !rt.test_paths.is_empty() => ( + Some(true), + format!( + "{repo} has {} test file{}{near_words}; CI runs none of them", + rt.test_paths.len(), + if rt.test_paths.len() == 1 { "" } else { "s" } + ), + ), + None => (Some(false), String::new()), + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] @@ -789,7 +981,11 @@ pub fn fit(t: &TicketFacts) -> Fit { )), } match (t.tests, repo_one) { - (Some(true), true) => why.push(format!("Tests exist in {}", t.repos[0])), + (Some(true), true) => why.push(if t.tests_why.is_empty() { + format!("Tests exist in {}", t.repos[0]) + } else { + t.tests_why.clone() + }), (Some(false), true) => missing.push(format!( "{} has no tests CoderHelm can run, so the change can't be proven", t.repos[0] @@ -1290,6 +1486,113 @@ mod tests { const AC: &str = "The refund email links to the help page.\n\nAcceptance criteria\n- [ ] The link opens /help/refunds\n\nChange web/src/emails/refund.tsx"; + #[test] + fn tests_are_read_from_the_repo_and_found_beside_the_named_files() { + let tree: Vec = [ + "src/checkout/Note.tsx", + "src/checkout/Note.test.tsx", + "src/emails/__tests__/confirmation.test.ts", + "src/emails/confirmation.html", + "README.md", + ] + .iter() + .map(|s| s.to_string()) + .collect(); + let rt = RepoTests { + command: Some("npm test".into()), + ci: "ci.yml test".into(), + test_paths: tree + .iter() + .filter(|p| crate::setup::facts::is_test_path(p)) + .cloned() + .collect(), + }; + assert_eq!( + tests_near( + &rt, + &[ + "src/checkout/Note.tsx".into(), + "src/emails/confirmation.html".into() + ] + ), + vec![ + "src/checkout/Note.test.tsx", + "src/emails/__tests__/confirmation.test.ts" + ] + ); + let (has, why) = tests_signal("acme/web", Some(&rt), &["src/checkout/Note.tsx".into()]); + assert_eq!(has, Some(true)); + assert_eq!( + why, + "Tests run in acme/web's CI (`npm test`), with src/checkout/Note.test.tsx beside the files the ticket names" + ); + let files_only = RepoTests { + command: None, + ..rt.clone() + }; + let (has, why) = tests_signal("acme/web", Some(&files_only), &[]); + assert_eq!(has, Some(true)); + assert!(why.ends_with("CI runs none of them"), "{why}"); + let (has, _) = tests_signal("acme/web", Some(&RepoTests::default()), &[]); + assert_eq!(has, Some(false)); + assert_eq!(tests_signal("acme/web", None, &[]).0, None); + } + + #[test] + fn a_nudge_names_who_asked_what_waits_and_how_to_undo() { + let t = nudge_text("mara", "dana-ortiz", "Review requested."); + assert!(t.starts_with("Hi @mara, a friendly reminder from @dana-ortiz")); + assert!(t.contains("(review requested)")); + assert!(t.contains("@dana-ortiz can undo it")); + assert!(nudge_text("mara", "dana-ortiz", "").contains("(it's waiting on you)")); + assert_eq!(nudge_sk("Acme/Web", 482), "FORYOU#NUDGE#acme/web#482"); + } + + #[test] + fn only_one_other_person_can_be_nudged() { + let from = |v: &[&str]| v.iter().map(|s| s.to_string()).collect::>(); + assert_eq!( + nudge_target("person", &from(&["person:mara"]), "dana-ortiz").as_deref(), + Some("mara") + ); + assert_eq!( + nudge_target("person", &from(&["team:acme/web"]), "dana-ortiz"), + None + ); + assert_eq!( + nudge_target("coderhelm", &from(&["person:mara"]), "dana-ortiz"), + None + ); + assert_eq!( + nudge_target("person", &from(&["person:Dana-Ortiz"]), "dana-ortiz"), + None + ); + } + + #[test] + fn where_a_match_was_seen_is_a_few_real_ticket_keys() { + let keys: Vec = [ + "BOOK-12", + "BOOK-3", + "not a key", + "BOOK-12", + "B-", + "-1", + "BOOK-7", + "BOOK-8", + "BOOK-9", + "BOOK-10", + ] + .iter() + .map(|s| s.to_string()) + .collect(); + let shown = seen_on_shown(&keys); + assert_eq!(shown.len(), SEEN_ON_KEEP); + assert!(shown.iter().all(|k| is_ticket_key(k))); + assert!(!is_ticket_key("book-1")); + assert!(is_ticket_key("WEB2-42")); + } + #[test] fn a_code_is_signed_for_its_team_and_typed_loosely() { let (code, sk) = issue_code(SECRET, "TEAM#a", [1, 2, 3, 4, 5]); @@ -1327,6 +1630,7 @@ mod tests { #[test] fn email_alone_is_only_a_suggestion_and_never_a_guess() { let u = |id: &str, email: &str, linked: bool| SeenJiraUser { + seen_on: vec![], account_id: id.into(), name: "Dana Ortiz".into(), email: email.into(), diff --git a/services/common/src/lib.rs b/services/common/src/lib.rs index 560f66594..934f682b0 100644 --- a/services/common/src/lib.rs +++ b/services/common/src/lib.rs @@ -263,6 +263,7 @@ pub mod plan_dependents; pub mod plan_repos; pub mod plan_state; pub mod plan_sync; +pub mod plan_view; /// Every body CoderHelm sends GitHub fits GitHub's limit. pub mod pr_body; pub mod pr_body_fit; diff --git a/services/common/src/plan_view.rs b/services/common/src/plan_view.rs new file mode 100644 index 000000000..36e7da1be --- /dev/null +++ b/services/common/src/plan_view.rs @@ -0,0 +1,250 @@ +//! A run's plan as a person reads it: the steps of `tasks.md` per repo, with +//! whether each is done, the files the plan names, and its test steps. +//! +//! The planner writes markdown (`worker/src/passes/plan.rs`): `## owner/repo` +//! headers, `- [ ]` steps that the implement pass ticks to `- [x]`, and file +//! paths inside the step text and `design.md`. This reads that markdown and +//! nothing else, so what For you shows is the plan the run codes from. + +use serde::Serialize; + +/// One step of the plan. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct Step { + pub text: String, + pub done: bool, + /// A step that writes or runs tests. + pub test: bool, + /// Files this step names. + pub files: Vec, +} + +/// The steps for one repository. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct RepoPlan { + /// `owner/repo`, or empty when the plan has no repo headers. + pub repo: String, + pub steps: Vec, +} + +/// The whole plan. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)] +pub struct PlanView { + pub repos: Vec, + /// Every file the steps or the design name, sorted, once each. + pub files: Vec, + /// The test steps' text, in order. + pub tests: Vec, + pub done: usize, + pub total: usize, +} + +impl PlanView { + pub fn is_empty(&self) -> bool { + self.total == 0 + } +} + +/// Reads `tasks.md` (and `design.md` for files) into a [`PlanView`]. +pub fn parse(tasks: &str, design: &str) -> PlanView { + let mut repos: Vec = Vec::new(); + let mut current = RepoPlan { + repo: String::new(), + steps: Vec::new(), + }; + for line in tasks.lines() { + let t = line.trim(); + if let Some(h) = t.strip_prefix("## ") { + let h = h.trim().trim_matches('`'); + if is_repo(h) { + if !current.steps.is_empty() || !current.repo.is_empty() { + repos.push(std::mem::replace( + &mut current, + RepoPlan { + repo: String::new(), + steps: Vec::new(), + }, + )); + } + current.repo = h.to_string(); + } + continue; + } + let (done, rest) = + if let Some(r) = t.strip_prefix("- [x]").or_else(|| t.strip_prefix("- [X]")) { + (true, r) + } else if let Some(r) = t.strip_prefix("- [ ]") { + (false, r) + } else { + continue; + }; + let text = rest.trim().to_string(); + if text.is_empty() { + continue; + } + let files = paths_in(&text); + current.steps.push(Step { + test: is_test_step(&text, &files), + text, + done, + files, + }); + } + if !current.steps.is_empty() || !current.repo.is_empty() { + repos.push(current); + } + repos.retain(|r| !r.steps.is_empty()); + + let mut files: Vec = repos + .iter() + .flat_map(|r| r.steps.iter().flat_map(|s| s.files.clone())) + .chain(paths_in(design)) + .collect(); + files.sort(); + files.dedup(); + let tests = repos + .iter() + .flat_map(|r| r.steps.iter().filter(|s| s.test).map(|s| s.text.clone())) + .collect(); + let total = repos.iter().map(|r| r.steps.len()).sum(); + let done = repos + .iter() + .map(|r| r.steps.iter().filter(|s| s.done).count()) + .sum(); + PlanView { + repos, + files, + tests, + done, + total, + } +} + +fn is_repo(h: &str) -> bool { + let Some((o, n)) = h.split_once('/') else { + return false; + }; + let ok = |s: &str| { + !s.is_empty() + && s.chars() + .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_' | '.')) + }; + ok(o) && ok(n) +} + +/// A step that writes or runs tests: it names a test file, or says so. +fn is_test_step(text: &str, files: &[String]) -> bool { + if files.iter().any(|f| crate::setup::facts::is_test_path(f)) { + return true; + } + let low = text.to_ascii_lowercase(); + ["test", "spec ", "specs", "e2e", "coverage"] + .iter() + .any(|w| low.contains(w)) +} + +/// File paths written in the text: in backticks, or a bare word with a `/` +/// or a known extension. +fn paths_in(text: &str) -> Vec { + let mut out: Vec = Vec::new(); + for (i, part) in text.split('`').enumerate() { + if i % 2 == 1 { + let p = part.trim(); + if looks_like_path(p) { + out.push(p.trim_start_matches("./").to_string()); + } + } else { + for w in part.split_whitespace() { + let w = + w.trim_matches(|c: char| matches!(c, ',' | ';' | ':' | '(' | ')' | '"' | '\'')); + let w = w.trim_end_matches('.'); + if looks_like_path(w) && w.contains('/') { + out.push(w.trim_start_matches("./").to_string()); + } + } + } + } + out.sort(); + out.dedup(); + out +} + +fn looks_like_path(p: &str) -> bool { + if p.is_empty() || p.len() > 200 || p.contains(char::is_whitespace) || p.contains("://") { + return false; + } + if !p + .chars() + .all(|c| c.is_ascii_alphanumeric() || matches!(c, '/' | '.' | '_' | '-' | '[' | ']' | '@')) + { + return false; + } + let name = p.rsplit('/').next().unwrap_or(p); + match name.rsplit_once('.') { + Some((stem, ext)) => { + !stem.is_empty() + && (1..=5).contains(&ext.len()) + && ext.chars().all(|c| c.is_ascii_alphanumeric()) + && !ext.chars().all(|c| c.is_ascii_digit()) + } + None => false, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + const TASKS: &str = "# Tasks\n\n## acme/web\n\n- [x] Add the gift-wrap field to `src/checkout/Note.tsx`\n- [ ] Show the note in src/emails/confirmation.html.\n- [ ] Add a test in `src/checkout/Note.test.tsx`\n\n## acme/api\n\n- [ ] Store the note on the order (api/orders/model.py)\n- [ ] Run the existing pytest suite\n"; + + #[test] + fn steps_are_read_per_repo_with_what_is_done() { + let p = parse(TASKS, ""); + assert_eq!(p.repos.len(), 2); + assert_eq!(p.repos[0].repo, "acme/web"); + assert_eq!(p.repos[1].repo, "acme/api"); + assert_eq!((p.done, p.total), (1, 5)); + assert!(p.repos[0].steps[0].done); + assert_eq!(p.repos[0].steps[0].files, vec!["src/checkout/Note.tsx"]); + } + + #[test] + fn files_and_tests_come_from_the_plan_text() { + let p = parse(TASKS, "Touches `src/checkout/Note.tsx` and web/README.md."); + assert_eq!( + p.files, + vec![ + "api/orders/model.py", + "src/checkout/Note.test.tsx", + "src/checkout/Note.tsx", + "src/emails/confirmation.html", + "web/README.md", + ] + ); + assert_eq!( + p.tests, + vec![ + "Add a test in `src/checkout/Note.test.tsx`", + "Run the existing pytest suite" + ] + ); + } + + #[test] + fn a_plan_without_repo_headers_is_one_list_and_nothing_else_is_a_step() { + let p = parse( + "Some words\n- [ ] One\n* [ ] not a step\n- [ ] \n- [X] Two", + "", + ); + assert_eq!(p.repos.len(), 1); + assert_eq!(p.repos[0].repo, ""); + assert_eq!((p.done, p.total), (1, 2)); + assert!(parse("", "").is_empty()); + } + + #[test] + fn versions_urls_and_words_are_not_files() { + assert!(paths_in("bump to 1.2.3, see https://example.com/a.md, and v2.0").is_empty()); + assert_eq!(paths_in("edit `Cargo.toml`"), vec!["Cargo.toml"]); + } +} diff --git a/services/gateway/src/main.rs b/services/gateway/src/main.rs index 1216cd949..bfb3bbd90 100644 --- a/services/gateway/src/main.rs +++ b/services/gateway/src/main.rs @@ -703,6 +703,11 @@ fn build_app(state: Arc) -> Router { "/foryou/give", get(routes::foryou_give::preview).post(routes::foryou_give::give), ) + .route("/foryou/plan", get(routes::foryou_plan::plan)) + .route( + "/foryou/nudge", + post(routes::foryou_nudge::nudge).delete(routes::foryou_nudge::undo), + ) .route( "/foryou/link/jira", post(routes::foryou_link::make_code).delete(routes::foryou_link::unlink), diff --git a/services/gateway/src/permissions.rs b/services/gateway/src/permissions.rs index 8c90205a1..c7eb80c83 100644 --- a/services/gateway/src/permissions.rs +++ b/services/gateway/src/permissions.rs @@ -129,6 +129,7 @@ pub const CAPABILITIES: &[Capability] = &[ "prs::get_pr", "foryou::get_for_you", "foryou_give::preview", + "foryou_plan::plan", "prs_overview::get_overview", "review_lessons::list_lessons", "learning::get_learning", @@ -307,7 +308,7 @@ pub const CAPABILITIES: &[Capability] = &[ }, Capability { key: "reviews", - label: "Ask for a re-review, rate reviews, send release notes and release now", + label: "Ask for a re-review, nudge whoever your pull request waits on, rate reviews, send release notes and release now", short_label: "Act on reviews and releases", min_role: "member", @@ -317,6 +318,8 @@ pub const CAPABILITIES: &[Capability] = &[ "reviewer::send_release", "reviewer::release_now", "reviewer::control_gate", + "foryou_nudge::nudge", + "foryou_nudge::undo", ], }, Capability { diff --git a/services/gateway/src/routes/api.rs b/services/gateway/src/routes/api.rs index 58b537a09..b169623e6 100644 --- a/services/gateway/src/routes/api.rs +++ b/services/gateway/src/routes/api.rs @@ -2661,14 +2661,32 @@ pub async fn get_run_openspec( Extension(claims): Extension, axum::extract::Path(run_id): axum::extract::Path, ) -> Result, StatusCode> { + read_run_openspec(&state, &claims.team_id, &run_id) + .await + .map(|(files, _)| Json(Value::Object(files))) +} + +/// A run's planner files (`proposal`, `design`, `tasks`, `spec`, each when +/// present) and its run row, for a run of this team. `NOT_FOUND` for a run +/// that isn't the team's. +pub(crate) async fn read_run_openspec( + state: &AppState, + team_id: &str, + run_id: &str, +) -> Result< + ( + serde_json::Map, + std::collections::HashMap, + ), + StatusCode, +> { // First verify the run belongs to this team let result = state .dynamo .get_item() .table_name(&state.config.runs_table_name) - .key("team_id", attr_s(&claims.team_id)) - .key("run_id", attr_s(&run_id)) - .projection_expression("ticket_id, repo") + .key("team_id", attr_s(team_id)) + .key("run_id", attr_s(run_id)) .send() .await .map_err(|e| { @@ -2676,7 +2694,7 @@ pub async fn get_run_openspec( StatusCode::INTERNAL_SERVER_ERROR })?; - let item = result.item().ok_or(StatusCode::NOT_FOUND)?; + let item = result.item().ok_or(StatusCode::NOT_FOUND)?.clone(); let ticket_id = item .get("ticket_id") .and_then(|v| v.as_s().ok()) @@ -2691,13 +2709,13 @@ pub async fn get_run_openspec( .map(|(owner, name)| { format!( "teams/{}/runs/{}/openspec/{owner}__{name}", - claims.team_id, + team_id, ticket_id.to_lowercase() ) }); let legacy = format!( "teams/{}/runs/{}/openspec", - claims.team_id, + team_id, ticket_id.to_lowercase() ); let prefixes: Vec = repo_scoped.into_iter().chain([legacy]).collect(); @@ -2728,7 +2746,7 @@ pub async fn get_run_openspec( } } - Ok(Json(Value::Object(files))) + Ok((files, item)) } /// What a run action did. diff --git a/services/gateway/src/routes/foryou.rs b/services/gateway/src/routes/foryou.rs index 6be007468..103977ea7 100644 --- a/services/gateway/src/routes/foryou.rs +++ b/services/gateway/src/routes/foryou.rs @@ -538,24 +538,6 @@ pub fn repo_hints( } } -/// Repositories whose pull requests run a test check, with that check's -/// name (from the records' check attempts). -pub fn test_checks(recs: &[common::pr_record::PrRecord]) -> BTreeMap { - let mut out = BTreeMap::new(); - for r in recs { - for c in &r.check_attempts { - let n = c.name.to_ascii_lowercase(); - if ["test", "spec", "jest", "pytest", "vitest", "e2e"] - .iter() - .any(|w| n.contains(w)) - { - out.entry(r.repo.clone()).or_insert_with(|| c.name.clone()); - } - } - } - out -} - /// A run's stage on the page's bar. pub fn stage_of(item: &Item) -> (&'static str, String) { let status = st(item, "status"); @@ -570,6 +552,24 @@ pub fn stage_of(item: &Item) -> (&'static str, String) { } } +/// Whether the row's pull request can be nudged, and the nudge already sent. +fn nudge_of(row: &Row, v: &Viewer, nudges: &BTreeMap) -> Value { + let me = v.github.as_deref().unwrap_or_default(); + let to = foryou::nudge_target(&row.turn, &row.next.from, me); + let key = format!("{}#{}", row.repo.to_ascii_lowercase(), row.number); + let sent = nudges.get(&key).map(|n| { + json!({ + "to": n.to, + "by": n.by_login, + "at": n.at, + "mine": n.by_user == v.user, + "comment_url": n.comment_url, + "until": n.at + foryou::NUDGE_SECS as i64, + }) + }); + json!({"to": to, "sent": sent}) +} + fn first_person(from: &[String]) -> Option { from.iter() .find_map(|f| f.strip_prefix("person:")) @@ -600,8 +600,8 @@ fn pr_href(row: &Row, action: &str) -> String { row.number ); match row.coderhelm.as_ref().and_then(|c| c.run_id.clone()) { - Some(run) => format!("/inbox/pr?{q}&run={}", urlencoding::encode(&run)), - None => format!("/inbox/pr?{q}"), + Some(run) => format!("/foryou/pr?{q}&run={}", urlencoding::encode(&run)), + None => format!("/foryou/pr?{q}"), } } "Open checks" => format!("{}/checks", row.url), @@ -632,6 +632,11 @@ pub struct Input<'a> { pub team_repos: &'a [String], pub layout: foryou::Layout, pub now: i64, + /// What each sprint ticket's repository holds for tests, read from it + /// (`foryou_tests`). + pub repo_tests: &'a BTreeMap, + /// Live nudges by `repo#number` (`foryou_nudge`). + pub nudges: &'a BTreeMap, } /// The page, for one person, from what was read. Changes `prefs` only in @@ -722,6 +727,7 @@ pub fn build(input: &Input, prefs: &mut Prefs) -> Value { "by_coderhelm": by_coderhelm, "href": row.url, "nudge_href": row.url, + "nudge": nudge_of(row, v, input.nudges), "pr": {"repo": row.repo, "number": row.number}, }); place("waiting", item, &since, &mut later); @@ -798,7 +804,7 @@ pub fn build(input: &Input, prefs: &mut Prefs) -> Value { let href = if run_id.is_empty() { n.link.clone() } else { - format!("/inbox/answer?run={}", urlencoding::encode(&run_id)) + format!("/foryou/answer?run={}", urlencoding::encode(&run_id)) }; let item = json!({ "key": format!("run:{run_id}"), @@ -910,7 +916,6 @@ pub fn build(input: &Input, prefs: &mut Prefs) -> Value { } // The sprint, with a fit per ticket. - let tests = test_checks(input.records); let mut sprint_tickets: Vec = Vec::new(); let mut facts: Vec<(SprintTicket, foryou::Fit, TicketFacts)> = Vec::new(); for t in &tickets { @@ -967,8 +972,17 @@ pub fn build(input: &Input, prefs: &mut Prefs) -> Value { points: t.points, repos: repos.clone(), repo_source: source.into(), - tests: (repos.len() == 1 && tests.contains_key(&repos[0])).then_some(true), + tests: None, + tests_why: String::new(), }; + let mut tf = tf; + if repos.len() == 1 { + let named = foryou::named_files(&t.description); + let (has, why) = + foryou::tests_signal(&repos[0], input.repo_tests.get(&repos[0]), &named); + tf.tests = has; + tf.tests_why = why; + } let fit = (t.category == "new" && delegated.is_none()).then(|| foryou::fit(&tf)); let pr_note = input .rows @@ -1094,12 +1108,6 @@ pub fn build(input: &Input, prefs: &mut Prefs) -> Value { href: None, }) .collect(); - if let Some(c) = tests.get(&repo) { - evidence.push(Evidence { - text: format!("{repo} runs the check {c} on its pull requests"), - href: None, - }); - } if !t.sprint_name.is_empty() { evidence.push(Evidence { text: format!( @@ -1389,7 +1397,7 @@ pub fn build(input: &Input, prefs: &mut Prefs) -> Value { // Accounts. let suggestion = foryou::identity_suggestion(&reads.seen_users, &v.email, &prefs.identity_no).map(|u| { - json!({"account_id": u.account_id, "name": u.name, "why": "Seen in Jira with your sign-in email. Not linked: saying yes gives you a code to link it from Jira."}) + json!({"account_id": u.account_id, "name": u.name, "seen_on": foryou::seen_on_shown(&u.seen_on), "why": "Seen in Jira with your sign-in email. Not linked: saying yes gives you a code to link it from Jira."}) }); let jira_state = match (&v.jira, &reads.sprint) { (Some(_), _) => "linked", @@ -1506,6 +1514,26 @@ pub async fn get_for_you( jira_name, }; let team_repos: Vec = repos.iter().map(|r| r.name.clone()).collect(); + let single: Vec = match &reads.sprint { + Sprint::Ok(list) => { + let mut v: Vec = list + .iter() + .map(sprint_ticket) + .filter_map(|t| { + let (r, _) = repo_hints(&t, &team_repos, &reads.runs); + (r.len() == 1).then(|| r[0].clone()) + }) + .collect(); + v.sort(); + v.dedup(); + v + } + _ => Vec::new(), + }; + let (repo_tests, nudges) = tokio::join!( + super::foryou_tests::for_repos(&state, &claims.team_id, &single), + super::foryou_nudge::live(&state, &claims.team_id), + ); for _ in 0..3 { let (mut prefs, v) = read_prefs(&state, &claims.team_id, &user).await; let before = prefs.clone(); @@ -1519,6 +1547,8 @@ pub async fn get_for_you( team_repos: &team_repos, layout, now: t, + repo_tests: &repo_tests, + nudges: &nudges, }, &mut prefs, ); diff --git a/services/gateway/src/routes/foryou/tests.rs b/services/gateway/src/routes/foryou/tests.rs index 13b31e0d0..9381c25c4 100644 --- a/services/gateway/src/routes/foryou/tests.rs +++ b/services/gateway/src/routes/foryou/tests.rs @@ -97,6 +97,8 @@ pub fn page(v: &Viewer, rows: &[Row], records: &[PrRecord], r: &Reads, prefs: &m ], layout: prefs.layout.normalized(), now: NOW, + repo_tests: &BTreeMap::new(), + nudges: &BTreeMap::new(), }, prefs, ) @@ -173,7 +175,7 @@ fn needs_are_grouped_by_whose_turn_it_is_and_counted() { assert!(out["needs"]["reviews"][0]["action"]["href"] .as_str() .unwrap() - .starts_with("/inbox/pr?repo=acme%2Fweb&number=482")); + .starts_with("/foryou/pr?repo=acme%2Fweb&number=482")); assert_eq!(keys(&out["needs"]["returned"]), vec!["pr:acme/api#479"]); assert_eq!( out["needs"]["returned"][0]["action"]["label"], @@ -282,7 +284,7 @@ fn coderhelm_asks_come_from_gather_with_their_question() { asks[0]["why"], "CoderHelm asks: Should counts stored as 2.5 round down to 2 or up to 3?" ); - assert_eq!(asks[0]["action"]["href"], "/inbox/answer?run=01RUN"); + assert_eq!(asks[0]["action"]["href"], "/foryou/answer?run=01RUN"); assert_eq!(asks[1]["label"], "Plan to approve"); assert_eq!(asks[1]["action"]["label"], "Review plan"); } @@ -558,12 +560,17 @@ fn an_unlinked_person_gets_a_suggestion_never_a_link() { name: "Dana Ortiz".into(), email: "dana@example.com".into(), linked: false, + seen_on: vec!["BOOK-112".into()], }]; let mut v = dana(); v.jira = None; let mut p = Prefs::default(); let out = page(&v, &[], &[], &r, &mut p); assert_eq!(out["accounts"]["jira"]["state"], "not_linked"); + assert_eq!( + out["accounts"]["jira"]["suggestion"]["seen_on"], + json!(["BOOK-112"]) + ); assert_eq!(out["accounts"]["jira"]["suggestion"]["name"], "Dana Ortiz"); assert_eq!(out["sprint"]["state"], "not_linked"); assert!(out["sprint"]["tickets"].as_array().unwrap().is_empty()); @@ -625,3 +632,128 @@ fn repositories_are_known_from_a_label_the_ticket_or_past_runs() { (Vec::new(), "") ); } + +fn page_with( + rows: &[Row], + r: &Reads, + repo_tests: &BTreeMap, + nudges: &BTreeMap, +) -> Value { + let mut prefs = Prefs::default(); + build( + &Input { + viewer: &dana(), + rows, + records: &[], + reads: r, + team_repos: &["acme/web".to_string()], + layout: prefs.layout.normalized(), + now: NOW, + repo_tests, + nudges, + }, + &mut prefs, + ) +} + +#[test] +fn a_waiting_pull_request_offers_a_nudge_to_the_one_person_and_shows_one_sent() { + let rows = vec![ + row( + "acme/api", + 477, + "dana-ortiz", + "needs_review", + "person", + &["person:mara"], + ), + row( + "acme/api", + 478, + "dana-ortiz", + "needs_review", + "person", + &["team:acme/api"], + ), + ]; + let none = BTreeMap::new(); + let out = page_with(&rows, &reads(), &BTreeMap::new(), &none); + let by = |k: &str| { + out["waiting"] + .as_array() + .unwrap() + .iter() + .find(|w| w["key"] == k) + .cloned() + .unwrap() + }; + assert_eq!(by("pr:acme/api#477")["nudge"]["to"], "mara"); + assert!(by("pr:acme/api#477")["nudge"]["sent"].is_null()); + assert!( + by("pr:acme/api#478")["nudge"]["to"].is_null(), + "a team has no one person to nudge" + ); + + let mut sent = BTreeMap::new(); + sent.insert( + "acme/api#477".to_string(), + foryou::Nudged { + by_user: dana().user, + by_login: "dana-ortiz".into(), + to: "mara".into(), + at: NOW - 600, + comment_id: 9, + comment_url: "https://github.com/acme/api/pull/477#issuecomment-9".into(), + }, + ); + let out = page_with(&rows, &reads(), &BTreeMap::new(), &sent); + let w = out["waiting"] + .as_array() + .unwrap() + .iter() + .find(|w| w["key"] == "pr:acme/api#477") + .cloned() + .unwrap(); + assert_eq!(w["nudge"]["sent"]["to"], "mara"); + assert_eq!(w["nudge"]["sent"]["mine"], true); + assert_eq!(w["nudge"]["sent"]["until"], NOW - 600 + 86_400); +} + +#[test] +fn the_tests_signal_comes_from_the_repository_not_check_names() { + let mut r = reads(); + r.sprint = Sprint::Ok(vec![ticket( + "BOOK-118", + "Fix the broken help link in the refund email", + "Acceptance criteria\n- [ ] The link opens /help/refunds\nChange web/src/emails/refund.tsx\nRepo: acme/web", + 1.0, + "new", + &["coderhelm:acme/web"], + )]); + let mut tests = BTreeMap::new(); + tests.insert( + "acme/web".to_string(), + foryou::RepoTests { + command: Some("npm test".into()), + ci: "ci.yml test".into(), + test_paths: vec!["web/src/emails/refund.test.tsx".into()], + }, + ); + let out = page_with(&[], &r, &tests, &BTreeMap::new()); + let why = out["sprint"]["tickets"][0]["fit"]["why"].to_string(); + assert!( + why.contains("Tests run in acme/web's CI (`npm test`)"), + "{why}" + ); + assert!(why.contains("web/src/emails/refund.test.tsx"), "{why}"); + + let mut none = BTreeMap::new(); + none.insert("acme/web".to_string(), foryou::RepoTests::default()); + let out = page_with(&[], &r, &none, &BTreeMap::new()); + let missing = out["sprint"]["tickets"][0]["fit"]["missing"].to_string(); + assert!( + missing.contains("has no tests CoderHelm can run"), + "{missing}" + ); + assert_ne!(out["sprint"]["tickets"][0]["fit"]["band"], "good"); +} diff --git a/services/gateway/src/routes/foryou_give.rs b/services/gateway/src/routes/foryou_give.rs index d2550d9d3..179a99288 100644 --- a/services/gateway/src/routes/foryou_give.rs +++ b/services/gateway/src/routes/foryou_give.rs @@ -104,7 +104,16 @@ pub async fn preview( repos: hint.clone(), repo_source: source.into(), tests: None, + tests_why: String::new(), }; + let mut facts = facts; + if hint.len() == 1 { + let read = super::foryou_tests::for_repos(&state, &claims.team_id, &hint).await; + let named = foryou::named_files(&t.description); + let (has, why) = foryou::tests_signal(&hint[0], read.get(&hint[0]), &named); + facts.tests = has; + facts.tests_why = why; + } let fit = foryou::fit(&facts); let criteria: Vec = t .description @@ -121,6 +130,45 @@ pub async fn preview( .filter(|l| !l.is_empty()) .take(8) .collect(); + // A plan this ticket's newest run already wrote (a "Draft a plan first" + // run, or one at work): shown as written, steps, files and tests. + let newest = r + .runs + .iter() + .filter(|x| x.get("ticket_id").and_then(|v| v.as_s().ok()) == Some(&t.key)) + .max_by_key(|x| { + x.get("created_at") + .and_then(|v| v.as_s().ok()) + .cloned() + .unwrap_or_default() + }) + .and_then(|x| x.get("run_id").and_then(|v| v.as_s().ok()).cloned()); + let written = match &newest { + Some(run) => match super::api::read_run_openspec(&state, &claims.team_id, run).await { + Ok((files, _)) => { + let text = |k: &str| files.get(k).and_then(Value::as_str).unwrap_or_default(); + Some(( + run.clone(), + common::plan_view::parse(text("tasks"), text("design")), + )) + } + Err(_) => None, + }, + None => None, + } + .filter(|(_, v)| !v.is_empty()); + let plan = match &written { + Some((run, view)) => json!({ + "available": true, + "run_id": run, + "text": "The plan CoderHelm's planner wrote for this ticket, before any code.", + "view": view, + }), + None => json!({ + "available": false, + "text": "CoderHelm writes its plan from the ticket and the code before any change. With \"Pause after the plan\" it plans only, then shows you every step, file and test for your OK before it codes.", + }), + }; Ok(Json(json!({ "key": t.key, "title": t.title, @@ -130,12 +178,7 @@ pub async fn preview( "repo_source": source, "files": foryou::named_files(&t.description), "criteria": criteria, - // No dry-run planner exists: say what is known, and that the plan - // comes first. - "plan": { - "available": false, - "text": "CoderHelm writes its plan first, from the ticket and the code, before any change. With \"Pause after the plan\" it waits for your OK on the run page before it codes.", - }, + "plan": plan, "plan_first_default": fit.band != foryou::Band::Good, "owner": "you", "delegate": "CoderHelm", diff --git a/services/gateway/src/routes/foryou_link.rs b/services/gateway/src/routes/foryou_link.rs index 6cdc4bc0d..92a4fa0e9 100644 --- a/services/gateway/src/routes/foryou_link.rs +++ b/services/gateway/src/routes/foryou_link.rs @@ -232,11 +232,12 @@ pub async fn forge_link( Ok(x) => x, Err(c) => return answer(c, "That request is missing what CoderHelm needs."), }; - if common::hybrid::sign::is_install_id(team.trim_start_matches("TEAM#")) { - return answer( - StatusCode::CONFLICT, - "This Jira site sends its work to a self-hosted CoderHelm: link your account there.", - ); + // A Forge app set up with a self-hosted install's id: the install holds + // the code and the people, and checks the Forge secret itself. + let bare = team.trim_start_matches("TEAM#"); + if common::hybrid::sign::is_install_id(bare) { + let (c, m) = super::hybrid::relay_now(&state, bare, "link", &body).await; + return answer(c, &relayed_words(c, &m)); } let config = state .dynamo @@ -256,6 +257,43 @@ pub async fn forge_link( warn!(team_id = %team, "Jira link: invalid or missing forge_secret"); return answer(StatusCode::FORBIDDEN, ""); } + // A hosted team's site linked to a self-hosted install: the code was + // made there, so the install checks it and keeps the link. The secret + // stays here. + if let Some(install) = super::hybrid_jira::standing_route(&state, &team).await { + let fwd = super::hybrid_jira::without_secret(&body); + let (c, m) = super::hybrid::relay_now(&state, &install, "site_link", &fwd).await; + return answer(c, &relayed_words(c, &m)); + } + let (c, m) = link_with_code(&state, &team, &account, &code).await; + answer(c, &m) +} + +/// The words for an install's answer to a relayed link. +fn relayed_words(c: StatusCode, words: &str) -> String { + if c.is_success() { + "Linked. Your sprint now shows on your CoderHelm's For you page.".into() + } else if words.trim().is_empty() { + "Your self-hosted CoderHelm didn't take the link. Try again in a minute.".into() + } else { + words.trim().to_string() + } +} + +/// Links the account to the dashboard user the code was made for, on this +/// deployment: the code's signature for the team, then the code used up, +/// then both rows. Hosted calls it for its own teams; a self-hosted install +/// for the links CoderHelm relays to it. +pub(crate) async fn link_with_code( + state: &AppState, + team: &str, + account: &str, + code: &str, +) -> (StatusCode, String) { + let answer = |c: StatusCode, m: &str| (c, m.to_string()); + let team = team.to_string(); + let account = account.to_string(); + let code = code.to_string(); // The signature first: a guessed code, or another team's, costs no read. if !foryou::verify_code(state.secrets.jwt_secret.as_bytes(), &team, &code) { return answer( @@ -301,10 +339,10 @@ pub async fn forge_link( "That code has expired or was already used. Make a new one on the For you page.", ); } - match link(&state, &team, &user, &account).await { + match link(state, &team, &user, &account).await { Ok(()) => { info!(team_id = %team, "For you: a person linked their Jira account"); - let name = user_name(&state, &team, &user).await; + let name = user_name(state, &team, &user).await; answer( StatusCode::OK, &match name { @@ -419,6 +457,11 @@ pub async fn seen_jira_users(state: &AppState, team: &str) -> Vec); + +fn refuse(c: StatusCode, m: &str) -> Refusal { + (c, Json(json!({"error": m}))) +} + +fn s(v: &str) -> AttributeValue { + AttributeValue::S(v.to_string()) +} + +fn n(v: impl ToString) -> AttributeValue { + AttributeValue::N(v.to_string()) +} + +fn get_s(i: &HashMap, k: &str) -> String { + i.get(k) + .and_then(|v| v.as_s().ok()) + .cloned() + .unwrap_or_default() +} + +fn get_n(i: &HashMap, k: &str) -> i64 { + i.get(k) + .and_then(|v| v.as_n().ok()) + .and_then(|v| v.parse().ok()) + .unwrap_or(0) +} + +fn nudged_of(i: &HashMap) -> Nudged { + Nudged { + by_user: get_s(i, "by_user"), + by_login: get_s(i, "by_login"), + to: get_s(i, "to"), + at: get_n(i, "at"), + comment_id: get_n(i, "comment_id").max(0) as u64, + comment_url: get_s(i, "comment_url"), + } +} + +/// The live nudges of a team, by `repo#number` (lower case). +pub async fn live(state: &AppState, team: &str) -> BTreeMap { + let now = chrono::Utc::now().timestamp(); + let mut out = BTreeMap::new(); + let mut start = None; + for _ in 0..3 { + let Ok(r) = state + .dynamo + .query() + .table_name(&state.config.settings_table_name) + .key_condition_expression("pk = :p AND begins_with(sk, :s)") + .expression_attribute_values(":p", s(team)) + .expression_attribute_values(":s", s(foryou::NUDGE_PREFIX)) + .set_exclusive_start_key(start.take()) + .send() + .await + else { + break; + }; + for i in r.items() { + if get_s(i, "pk") != team || get_n(i, "ttl") <= now || get_n(i, "comment_id") == 0 { + continue; + } + let key = get_s(i, "sk") + .trim_start_matches(foryou::NUDGE_PREFIX) + .to_string(); + out.insert(key, nudged_of(i)); + } + match r.last_evaluated_key() { + Some(k) if !k.is_empty() => start = Some(k.clone()), + _ => break, + } + } + out +} + +/// The pull request, if it is the caller's own and waits on one other +/// person: who that is, and what it waits for. +async fn target( + state: &AppState, + claims: &Claims, + login: &str, + repo: &str, + number: u64, +) -> Result<(String, String), Refusal> { + let (data, _) = super::prs::read_all(state, &claims.team_id) + .await + .map_err(|c| refuse(c, "Pull requests couldn't be read."))?; + let rows = common::pr_view::rows( + &claims.team_id, + &data.0, + &data.1, + Some(login), + chrono::Utc::now().timestamp(), + ); + let row = rows + .iter() + .find(|r| r.repo.eq_ignore_ascii_case(repo) && r.number == number) + .ok_or_else(|| { + refuse( + StatusCode::NOT_FOUND, + "That pull request isn't open in your team's repositories.", + ) + })?; + if foryou::pr_group(row, login) != Some(foryou::PrGroup::Waiting) { + return Err(refuse( + StatusCode::CONFLICT, + "Only your own pull requests waiting on someone else can be nudged.", + )); + } + let to = foryou::nudge_target(&row.turn, &row.next.from, login).ok_or_else(|| { + refuse( + StatusCode::CONFLICT, + "It isn't waiting on one person right now, so there's no one to nudge.", + ) + })?; + Ok((to, row.next.text.clone())) +} + +/// `POST /api/foryou/nudge` +pub async fn nudge( + State(state): State>, + Extension(claims): Extension, + Json(body): Json, +) -> Result, Refusal> { + let allowed = claims.require_role(1); + allowed.map_err(|c| refuse(c, "Your role can't send nudges."))?; + let Some(login) = claims.github_login.clone().filter(|l| !l.trim().is_empty()) else { + return Err(refuse(StatusCode::CONFLICT, "Connect GitHub first.")); + }; + let repo = body.repo.trim(); + super::reviewer::validate_repo(repo).map_err(|c| refuse(c, "No such pull request."))?; + let (to, waiting) = target(&state, &claims, &login, repo, body.number).await?; + + let team = claims.team_id.as_str(); + let table = &state.config.settings_table_name; + let sk = foryou::nudge_sk(repo, body.number); + match claim(&state.dynamo, table, team, &sk, foryou::NUDGE_SECS).await { + Claim::Won => {} + Claim::Held => { + return Err(refuse( + StatusCode::TOO_MANY_REQUESTS, + "It was nudged in the last day. One reminder a day is enough.", + )) + } + Claim::Failed(e) => { + warn!(team, error = %e, "nudge: claim failed"); + return Err(refuse( + StatusCode::SERVICE_UNAVAILABLE, + "The nudge couldn't be sent. Try again.", + )); + } + } + let free = || async { + let _ = state + .dynamo + .delete_item() + .table_name(table) + .key("pk", s(team)) + .key("sk", s(&sk)) + .send() + .await; + }; + let Some(token) = super::brain::github_token(&state, team).await else { + free().await; + return Err(refuse( + StatusCode::SERVICE_UNAVAILABLE, + "CoderHelm can't reach GitHub for this team right now.", + )); + }; + let text = foryou::nudge_text(&to, &login, &waiting); + let sent = state + .http + .post(format!( + "https://api.github.com/repos/{repo}/issues/{}/comments", + body.number + )) + .bearer_auth(&token) + .header("Accept", "application/vnd.github+json") + .header("User-Agent", "coderhelm") + .json(&json!({"body": text})) + .send() + .await; + let comment = match sent { + Ok(r) if r.status().is_success() => r.json::().await.unwrap_or_default(), + Ok(r) => { + free().await; + return Err(refuse( + StatusCode::BAD_GATEWAY, + &format!("GitHub didn't take the comment ({}).", r.status().as_u16()), + )); + } + Err(_) => { + free().await; + return Err(refuse( + StatusCode::BAD_GATEWAY, + "GitHub couldn't be reached.", + )); + } + }; + let id = comment["id"].as_u64().unwrap_or(0); + let url = comment["html_url"].as_str().unwrap_or_default().to_string(); + let at = chrono::Utc::now().timestamp(); + let kept = state + .dynamo + .update_item() + .table_name(table) + .key("pk", s(team)) + .key("sk", s(&sk)) + .update_expression( + "SET by_user = :u, by_login = :l, #to = :t, #at = :a, comment_id = :c, comment_url = :w", + ) + .expression_attribute_names("#to", "to") + .expression_attribute_names("#at", "at") + .expression_attribute_values(":u", s(&user_of(&claims))) + .expression_attribute_values(":l", s(&login)) + .expression_attribute_values(":t", s(&to)) + .expression_attribute_values(":a", n(at)) + .expression_attribute_values(":c", n(id)) + .expression_attribute_values(":w", s(&url)) + .send() + .await; + if let Err(e) = kept { + warn!(team, error = %e, "nudge: sent, but its record wasn't kept"); + } + super::foryou::forget(&state, &claims).await; + Ok(Json(json!({ + "nudged": true, + "to": to, + "comment_url": url, + "until": at + foryou::NUDGE_SECS as i64, + "effect": format!("Reminded @{to} on GitHub. Undo takes the comment back."), + }))) +} + +/// `DELETE /api/foryou/nudge`: takes the reminder back. +pub async fn undo( + State(state): State>, + Extension(claims): Extension, + Json(body): Json, +) -> Result, Refusal> { + let allowed = claims.require_role(1); + allowed.map_err(|c| refuse(c, "Your role can't send nudges."))?; + let repo = body.repo.trim(); + super::reviewer::validate_repo(repo).map_err(|c| refuse(c, "No such pull request."))?; + let team = claims.team_id.as_str(); + let table = &state.config.settings_table_name; + let sk = foryou::nudge_sk(repo, body.number); + let item = state + .dynamo + .get_item() + .table_name(table) + .key("pk", s(team)) + .key("sk", s(&sk)) + .consistent_read(true) + .send() + .await + .map_err(|_| refuse(StatusCode::SERVICE_UNAVAILABLE, "Try again."))? + .item + .ok_or_else(|| refuse(StatusCode::NOT_FOUND, "There's no nudge to undo."))?; + let was = nudged_of(&item); + if was.by_user != user_of(&claims) { + return Err(refuse( + StatusCode::FORBIDDEN, + "Only the person who sent a nudge can undo it.", + )); + } + if was.comment_id > 0 { + let Some(token) = super::brain::github_token(&state, team).await else { + return Err(refuse( + StatusCode::SERVICE_UNAVAILABLE, + "CoderHelm can't reach GitHub for this team right now.", + )); + }; + let r = state + .http + .delete(format!( + "https://api.github.com/repos/{repo}/issues/comments/{}", + was.comment_id + )) + .bearer_auth(&token) + .header("Accept", "application/vnd.github+json") + .header("User-Agent", "coderhelm") + .send() + .await + .map_err(|_| refuse(StatusCode::BAD_GATEWAY, "GitHub couldn't be reached."))?; + // Gone already (someone deleted it) is as good as deleted. + if !r.status().is_success() && r.status() != reqwest::StatusCode::NOT_FOUND { + return Err(refuse( + StatusCode::BAD_GATEWAY, + &format!("GitHub kept the comment ({}).", r.status().as_u16()), + )); + } + } + let _ = state + .dynamo + .delete_item() + .table_name(table) + .key("pk", s(team)) + .key("sk", s(&sk)) + .condition_expression("by_user = :u") + .expression_attribute_values(":u", s(&was.by_user)) + .send() + .await; + super::foryou::forget(&state, &claims).await; + Ok(Json( + json!({"undone": true, "effect": "The reminder is taken back."}), + )) +} diff --git a/services/gateway/src/routes/foryou_plan.rs b/services/gateway/src/routes/foryou_plan.rs new file mode 100644 index 000000000..462539296 --- /dev/null +++ b/services/gateway/src/routes/foryou_plan.rs @@ -0,0 +1,149 @@ +//! `GET /api/foryou/plan?run=`: a run's real plan, read from the files +//! the planner wrote (`common::plan_view`): its steps per repo with what is +//! done, the files it names and its test steps. For you shows it in two +//! places: the plan a "Draft a plan first" run waits on (with the question +//! to answer to approve it), and the step checklist of a run at work. +//! +//! Same reach as the run page's plan (`GET /api/runs/:id/openspec`): a run +//! of the caller's team, under "view". + +use std::sync::Arc; + +use axum::{ + extract::{Query, State}, + http::StatusCode, + Extension, Json, +}; +use common::foryou; +use serde::Deserialize; +use serde_json::{json, Value}; + +use crate::models::Claims; +use crate::AppState; + +#[derive(Deserialize)] +pub struct PlanQuery { + pub run: String, +} + +/// The run's plan, and whether it waits for an OK. +pub async fn plan( + State(state): State>, + Extension(claims): Extension, + Query(q): Query, +) -> Result, (StatusCode, Json)> { + let run = q.run.trim(); + if run.is_empty() || run.len() > 64 || !run.chars().all(|c| c.is_ascii_alphanumeric()) { + return Err(( + StatusCode::BAD_REQUEST, + Json(json!({"error": "That isn't a run id."})), + )); + } + let (files, item) = super::api::read_run_openspec(&state, &claims.team_id, run) + .await + .map_err(|c| { + ( + c, + Json(json!({"error": "No run with this id in the team."})), + ) + })?; + let text = |k: &str| files.get(k).and_then(Value::as_str).unwrap_or_default(); + let view = common::plan_view::parse(text("tasks"), text("design")); + let st = |k: &str| { + item.get(k) + .and_then(|v| v.as_s().ok()) + .cloned() + .unwrap_or_default() + }; + let status = st("status"); + let asked = super::api::run_asked(&item); + Ok(Json(shape( + run, + &status, + &st("ticket_id"), + asked.as_ref(), + &view, + ))) +} + +/// The answer body: the plan, and the question to answer when the run waits +/// on the plan's OK. +pub fn shape( + run: &str, + status: &str, + ticket: &str, + asked: Option<&common::run_questions::Asked>, + view: &common::plan_view::PlanView, +) -> Value { + let question = asked + .filter(|_| status == common::run_status::NEEDS_INPUT) + .and_then(|a| { + a.questions + .iter() + .find(|q| q.question.trim() == foryou::PLAN_QUESTION) + }); + json!({ + "run_id": run, + "ticket": (!ticket.is_empty()).then_some(ticket), + "status": status, + "ready": !view.is_empty(), + "awaiting_ok": question.map(|q| json!({ + "question_id": q.id, + "approve": foryou::PLAN_APPROVE, + "change": foryou::PLAN_CHANGE, + })), + "plan": view, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use common::run_questions::{Asked, Question}; + + fn asked(q: &str) -> Asked { + Asked { + questions: vec![Question { + id: "q1".into(), + question: q.into(), + ..Default::default() + }], + ..Default::default() + } + } + + #[test] + fn a_plan_waiting_for_its_ok_names_the_question_to_answer() { + let view = common::plan_view::parse("## acme/web\n- [ ] Add the note field", ""); + let a = asked(foryou::PLAN_QUESTION); + let out = shape( + "01RUN", + common::run_status::NEEDS_INPUT, + "BOOK-112", + Some(&a), + &view, + ); + assert_eq!(out["awaiting_ok"]["question_id"], "q1"); + assert_eq!(out["awaiting_ok"]["approve"], foryou::PLAN_APPROVE); + assert_eq!(out["plan"]["repos"][0]["repo"], "acme/web"); + assert_eq!(out["ready"], true); + } + + #[test] + fn another_question_or_a_running_run_waits_on_no_ok() { + let view = common::plan_view::parse("- [x] One", ""); + let other = asked("Which coupon wins?"); + let out = shape( + "01RUN", + common::run_status::NEEDS_INPUT, + "", + Some(&other), + &view, + ); + assert!(out["awaiting_ok"].is_null()); + let plan_q = asked(foryou::PLAN_QUESTION); + let out = shape("01RUN", "running", "", Some(&plan_q), &view); + assert!(out["awaiting_ok"].is_null()); + assert_eq!(out["plan"]["done"], 1); + } +} diff --git a/services/gateway/src/routes/foryou_tests.rs b/services/gateway/src/routes/foryou_tests.rs new file mode 100644 index 000000000..dff2aa390 --- /dev/null +++ b/services/gateway/src/routes/foryou_tests.rs @@ -0,0 +1,157 @@ +//! The "tests in repo" signal of For you's fit bands, read from the +//! repository itself: its file tree on the default branch (test files) and +//! its workflow files (the test command CI runs, `common::test_env`). +//! Through the team's GitHub app, kept ten minutes per installation and +//! repository ([`TESTS`]). + +use std::collections::BTreeMap; +use std::sync::{Arc, LazyLock}; +use std::time::{Duration, Instant}; + +use base64::Engine as _; +use common::foryou::RepoTests; +use serde_json::Value; + +use super::run_checks::{read_key, TtlCache}; +use crate::AppState; + +const KEEP: Duration = Duration::from_secs(600); +/// A failed read is tried again sooner. +const KEEP_FAILED: Duration = Duration::from_secs(60); +/// Workflow files read per repository, at most. +const WORKFLOWS_READ: usize = 8; +/// Repositories read for one page, at most. +pub const REPOS_PER_PAGE: usize = 6; + +/// `None`: the repository couldn't be read. +static TESTS: LazyLock>>> = LazyLock::new(TtlCache::new); + +async fn get(state: &AppState, token: &str, url: &str) -> Option { + let r = state + .http + .get(url) + .bearer_auth(token) + .header("Accept", "application/vnd.github+json") + .header("User-Agent", "coderhelm") + .send() + .await + .ok()?; + if !r.status().is_success() { + return None; + } + r.json().await.ok() +} + +async fn read(state: &AppState, token: &str, repo: &str) -> Option { + let meta = get( + state, + token, + &format!("https://api.github.com/repos/{repo}"), + ) + .await?; + let branch = meta["default_branch"].as_str()?.to_string(); + let tree = get( + state, + token, + &format!( + "https://api.github.com/repos/{repo}/git/trees/{}?recursive=1", + urlencoding::encode(&branch) + ), + ) + .await?; + let paths: Vec = tree["tree"] + .as_array()? + .iter() + .filter(|e| e["type"] == "blob") + .filter_map(|e| e["path"].as_str().map(str::to_string)) + .collect(); + let mut workflows: Vec<(String, String)> = Vec::new(); + for p in paths + .iter() + .filter(|p| { + p.starts_with(".github/workflows/") && (p.ends_with(".yml") || p.ends_with(".yaml")) + }) + .take(WORKFLOWS_READ) + { + let Some(f) = get( + state, + token, + &format!( + "https://api.github.com/repos/{repo}/contents/{p}?ref={}", + urlencoding::encode(&branch) + ), + ) + .await + else { + continue; + }; + let b64: String = f["content"] + .as_str() + .unwrap_or_default() + .chars() + .filter(|c| !c.is_whitespace()) + .collect(); + if let Ok(bytes) = base64::engine::general_purpose::STANDARD.decode(b64) { + if let Ok(text) = String::from_utf8(bytes) { + workflows.push((p.clone(), text)); + } + } + } + Some(common::foryou::repo_tests(&workflows, &paths)) +} + +/// What each repository holds for tests, for at most [`REPOS_PER_PAGE`] of +/// them; a repository that couldn't be read is left out. +pub async fn for_repos( + state: &AppState, + team: &str, + repos: &[String], +) -> BTreeMap { + let mut out = BTreeMap::new(); + if repos.is_empty() { + return out; + } + let installation = super::api::get_team_installation_id(state, team) + .await + .unwrap_or(0); + if installation == 0 { + return out; + } + let mut want: Vec<&String> = Vec::new(); + for r in repos.iter().take(REPOS_PER_PAGE) { + let key = read_key( + installation, + &format!("foryou-tests#{}", r.to_ascii_lowercase()), + ); + match TESTS.get(&key, Instant::now()) { + Some(hit) => { + if let Some(t) = hit.as_ref() { + out.insert(r.clone(), t.clone()); + } + } + None => want.push(r), + } + } + if want.is_empty() { + return out; + } + let Some(token) = super::brain::github_token(state, team).await else { + return out; + }; + let read_all = want.iter().map(|r| async { + let got = read(state, &token, r).await; + (r.to_string(), got) + }); + for (repo, got) in futures::future::join_all(read_all).await { + let key = read_key( + installation, + &format!("foryou-tests#{}", repo.to_ascii_lowercase()), + ); + let keep = if got.is_some() { KEEP } else { KEEP_FAILED }; + TESTS.put(key, Arc::new(got.clone()), keep, Instant::now()); + if let Some(t) = got { + out.insert(repo, t); + } + } + out +} diff --git a/services/gateway/src/routes/hybrid.rs b/services/gateway/src/routes/hybrid.rs index e64b213ff..290d8b90f 100644 --- a/services/gateway/src/routes/hybrid.rs +++ b/services/gateway/src/routes/hybrid.rs @@ -2783,6 +2783,83 @@ pub async fn relay_jira( Some(StatusCode::OK) } +/// A Jira event the person waits on (For you's "Link my CoderHelm +/// account"): sent to the install once, now, and its answer handed back, +/// never queued for a retry (the person tries again). `event` is `link` +/// (the Forge app was set up with the install's id; the install checks the +/// Forge secret itself) or `site_link` (a hosted team's site linked to the +/// install; CoderHelm checked the secret and removed it). The answer is the +/// install's status, and its words on a refusal. +pub async fn relay_now( + state: &AppState, + install_id: &str, + event: &str, + body: &[u8], +) -> (StatusCode, String) { + let unreachable = ( + StatusCode::BAD_GATEWAY, + "Your self-hosted CoderHelm couldn't be reached. Try again in a minute.".to_string(), + ); + let Some(master) = master(state) else { + return unreachable; + }; + if !sign::is_install_id(install_id) { + return unreachable; + } + let pk = relay::install_pk(install_id); + let mut d = Delivery::new( + Direction::Outbound, + relay::source_for("jira"), + &format!("jira.{event}"), + install_id, + ); + d.payload_bytes = body.len(); + let install = match load_install(state, install_id).await { + Ok(Some(i)) if i.verified() && i.integrations.iter().any(|x| x == "jira") => i, + _ => { + d.finish(Status::Failed, "Not linked", "relay_not_linked"); + deliveries::record(&state.dynamo, &state.config.settings_table_name, &pk, &d).await; + return ( + StatusCode::NOT_FOUND, + "This Jira site's self-hosted CoderHelm isn't linked for Jira any more.".into(), + ); + } + }; + let key = sign::relay_key(master, &install.id); + let origin = install.origin(); + let attempt = relay::send(&relay::Forward { + origin: &origin, + install_id: &install.id, + relay_key: &key, + source: "jira", + event, + delivery_id: &d.id.clone(), + body, + }) + .await; + let (code, words) = (attempt.code, attempt.error.clone()); + d.push_attempt(attempt); + match code { + Some(c) if (200..300).contains(&c) => { + d.finish(Status::Handled, "Forwarded to the install", "") + } + _ => d.finish( + Status::Failed, + "The install refused or didn't answer", + "relay_failed", + ), + } + deliveries::record(&state.dynamo, &state.config.settings_table_name, &pk, &d).await; + match code { + Some(c) if (200..300).contains(&c) => (StatusCode::OK, String::new()), + Some(c) => ( + StatusCode::from_u16(c).unwrap_or(StatusCode::BAD_GATEWAY), + words, + ), + None => unreachable, + } +} + // ── Relay and broker deliveries for the install ────────────────────────── /// GET /hybrid/deliveries (signed): this install's relay and broker records, diff --git a/services/gateway/src/routes/hybrid_install.rs b/services/gateway/src/routes/hybrid_install.rs index 202e3615a..00bc1fadb 100644 --- a/services/gateway/src/routes/hybrid_install.rs +++ b/services/gateway/src/routes/hybrid_install.rs @@ -2079,6 +2079,52 @@ pub async fn intake( fail(code, "handler_error", "Handling the Jira event failed.") }); } + // For you's "Link my CoderHelm account", relayed while the + // person waits: the code was made on this install, so it is + // checked and the link kept here. `link`: the app was set up + // with this install's id and the Forge secret came along + // (checked by the link route against this install's copy). + // `site_link`: a hosted team's site; CoderHelm checked the + // secret and signed the forward. + if event == "link" || event == "site_link" { + let team = only_team(&state).await.ok_or_else(|| { + fail( + StatusCode::CONFLICT, + "no_team", + "This install has no team yet. Sign up first.", + ) + })?; + let (code, words) = if event == "link" { + payload["coderhelm"]["team_id"] = json!(team); + let bytes = Bytes::from(serde_json::to_vec(&payload).unwrap_or_default()); + let (c, Json(v)) = + super::foryou_link::forge_link(State(state.clone()), bytes).await; + (c, v["message"].as_str().unwrap_or_default().to_string()) + } else { + if let Err((code, reason)) = ensure_jira_synced(&state).await { + let msg = deliveries::reason(reason).message; + return Err(fail(code, reason, msg)); + } + let account = payload["account_id"].as_str().unwrap_or("").trim(); + let code = payload["code"].as_str().unwrap_or("").trim(); + if !common::foryou::valid_account_id(account) + || code.is_empty() + || code.len() > 40 + { + return Err(fail( + StatusCode::BAD_REQUEST, + "bad_payload", + "That link request is missing what CoderHelm needs.", + )); + } + super::foryou_link::link_with_code(&state, &team, account, code).await + }; + return if code.is_success() { + Ok(StatusCode::OK) + } else { + Err(fail(code, "link_refused", &words)) + }; + } // The Forge app was set up with this install's id as its team id: // the install's own team takes the event. if payload diff --git a/services/gateway/src/routes/jira_webhook.rs b/services/gateway/src/routes/jira_webhook.rs index cc6cd9565..8c38cf99a 100644 --- a/services/gateway/src/routes/jira_webhook.rs +++ b/services/gateway/src/routes/jira_webhook.rs @@ -1613,6 +1613,45 @@ async fn remember_jira_users(state: &AppState, team_id: &str, payload: &Value) { if let Err(e) = update.send().await { warn!(team_id, error = %e, "Could not keep a Jira user's name"); } + // Where this account was seen, for For you's "Is this you?": a few + // ticket keys, never more (a full set or one already there is left). + let Some(key) = payload + .pointer("/issue/key") + .and_then(Value::as_str) + .filter(|k| common::foryou::is_ticket_key(k)) + else { + continue; + }; + let seen = state + .dynamo + .update_item() + .table_name(&state.config.settings_table_name) + .key("pk", attr_s(team_id)) + .key("sk", attr_s(&common::requester::jira_user_sk(id))) + .update_expression("ADD seen_on :k") + .condition_expression( + "attribute_exists(pk) AND (attribute_not_exists(seen_on) OR size(seen_on) < :max)", + ) + .expression_attribute_values( + ":k", + aws_sdk_dynamodb::types::AttributeValue::Ss(vec![key.to_string()]), + ) + .expression_attribute_values( + ":max", + aws_sdk_dynamodb::types::AttributeValue::N( + common::foryou::SEEN_ON_KEEP.to_string(), + ), + ) + .send() + .await; + if let Err(e) = seen { + let full = e + .as_service_error() + .is_some_and(|s| s.is_conditional_check_failed_exception()); + if !full { + warn!(team_id, error = %e, "Could not keep where a Jira user was seen"); + } + } } } diff --git a/services/gateway/src/routes/mod.rs b/services/gateway/src/routes/mod.rs index c77b0f93e..84079d1ab 100644 --- a/services/gateway/src/routes/mod.rs +++ b/services/gateway/src/routes/mod.rs @@ -42,6 +42,9 @@ pub mod followup_dedupe; pub mod foryou; pub mod foryou_give; pub mod foryou_link; +pub mod foryou_nudge; +pub mod foryou_plan; +pub mod foryou_tests; pub mod github; pub mod github_hybrid; pub mod github_webhook; diff --git a/services/worker/src/passes/incidents/bm_teams_never_cross.rs b/services/worker/src/passes/incidents/bm_teams_never_cross.rs index c00906272..155bbb917 100644 --- a/services/worker/src/passes/incidents/bm_teams_never_cross.rs +++ b/services/worker/src/passes/incidents/bm_teams_never_cross.rs @@ -359,6 +359,7 @@ const CACHES: &[(&str, &str)] = &[ ("gateway/src/permissions.rs::ROUTES", "route table; no data"), ("gateway/src/routes/chat_work_prs.rs::CACHE", "URL, reused only on a 304 to the team's own token; repo checked against the team's repos first"), ("gateway/src/routes/github_webhook.rs::SEEN", "installation id; log throttle"), + ("gateway/src/routes/foryou_tests.rs::TESTS", "installation id plus the repository (read_key(installation_id, \"foryou-tests#\")): what the repository holds for tests, read with that installation's own token"), ("gateway/src/routes/foryou.rs::READS", "installation id plus the team and the session user (read_key(installation_id, \"foryou##\")): one person's own reads, never another's"), ( "gateway/src/routes/prs_overview.rs::OVERVIEW", diff --git a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs index 931478899..bd6960ba2 100644 --- a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs +++ b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs @@ -42,6 +42,9 @@ const FILES: &[&str] = &[ "gateway/src/routes/foryou.rs", "gateway/src/routes/foryou_give.rs", "gateway/src/routes/foryou_link.rs", + "gateway/src/routes/foryou_nudge.rs", + "gateway/src/routes/foryou_plan.rs", + "gateway/src/routes/foryou_tests.rs", ]; /// Every struct that derives `Deserialize`, from its derive to its closing @@ -227,6 +230,7 @@ fn email_alone_never_links_an_identity() { name: "Dana Ortiz".into(), email: "dana@example.com".into(), linked: false, + seen_on: vec!["BOOK-112".into()], }]; assert!(foryou::identity_suggestion(&seen, "dana@example.com", &Default::default()).is_some()); // A link needs a code signed for the team: no email in it, and another From 3e3b6767d95255389394cc86532911436470df00 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 23:01:33 -0500 Subject: [PATCH 15/19] For you's privacy case reads the code's use-up with its expiry --- .../src/passes/incidents/ya_for_you_is_only_yours.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs index 931478899..c43f0124a 100644 --- a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs +++ b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs @@ -261,12 +261,11 @@ fn email_alone_never_links_an_identity() { } let link = code("gateway/src/routes/foryou_link.rs"); let verify = link.find("foryou::verify_code(").unwrap(); + // Used up only while unexpired, in the same conditional delete. let used_up = link - .find("condition_expression(\"attribute_exists(sk)\")") - .unwrap(); - let write = link - .find("match link(&state, &team, &user, &account)") + .find("condition_expression(\"attribute_exists(sk) AND expires_at > :now\")") .unwrap(); + let write = link.find("match link(").unwrap(); assert!(verify < used_up && used_up < write); // Chat's "what needs me" reads only the link, never an email match. let needs = code("gateway/src/routes/chat_work_needs.rs"); From cec46e734e663db31805d194599baf66db175cf8 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 23:01:51 -0500 Subject: [PATCH 16/19] For you's privacy case reads the code's use-up with its expiry --- .../src/passes/incidents/ya_for_you_is_only_yours.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs index bd6960ba2..3532f22fb 100644 --- a/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs +++ b/services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs @@ -265,12 +265,11 @@ fn email_alone_never_links_an_identity() { } let link = code("gateway/src/routes/foryou_link.rs"); let verify = link.find("foryou::verify_code(").unwrap(); + // Used up only while unexpired, in the same conditional delete. let used_up = link - .find("condition_expression(\"attribute_exists(sk)\")") - .unwrap(); - let write = link - .find("match link(&state, &team, &user, &account)") + .find("condition_expression(\"attribute_exists(sk) AND expires_at > :now\")") .unwrap(); + let write = link.find("match link(").unwrap(); assert!(verify < used_up && used_up < write); // Chat's "what needs me" reads only the link, never an email match. let needs = code("gateway/src/routes/chat_work_needs.rs"); From 950dc2ae942c8af69b9d1f30ba53a25fdc4022f7 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sun, 6 Dec 2026 00:14:25 -0500 Subject: [PATCH 17/19] Deliveries: the Jira link sent at once is a timed relay record --- services/gateway/src/routes/deliveries.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/gateway/src/routes/deliveries.rs b/services/gateway/src/routes/deliveries.rs index fff0b11bb..2008d09b2 100644 --- a/services/gateway/src/routes/deliveries.rs +++ b/services/gateway/src/routes/deliveries.rs @@ -529,7 +529,7 @@ mod tests { ("common/src/deliveries.rs", 2, "email(): the send's time, given by its caller; from_chat(): an attempt with the post's time"), ("common/src/webhooks/deliver.rs", 1, "new_record(): each send is an attempt with its time"), ("gateway/src/routes/github_webhook.rs", 1, "made at receipt; process() sets the handling time"), - ("gateway/src/routes/hybrid.rs", 4, "broker and relay records: attempts with their times, refusals from receipt, the token handout since the request"), + ("gateway/src/routes/hybrid.rs", 5, "broker and relay records: attempts with their times (a Jira link sent at once included), refusals from receipt, the token handout since the request"), ("gateway/src/routes/hybrid_install.rs", 2, "a refused forward since its arrival; name records: an untimed attempt"), ("gateway/src/routes/hybrid_email.rs", 1, "relay_delivery(): since the request"), ("gateway/src/routes/hybrid_jira.rs", 1, "relay forward: attempts with their times"), From dfa6c647f5b9439ab014505cc14c87df30d461e1 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sun, 6 Dec 2026 01:35:38 -0500 Subject: [PATCH 18/19] Jira link: axum reads the body into the strict request, at most 2 KiB The link route takes Json (deny_unknown_fields, plain strings) behind a 2 KiB body limit, so no request body is deserialized by hand. --- services/gateway/src/main.rs | 7 +- services/gateway/src/routes/foryou_link.rs | 83 +++++++++------------- 2 files changed, 39 insertions(+), 51 deletions(-) diff --git a/services/gateway/src/main.rs b/services/gateway/src/main.rs index 1216cd949..ec5940ee3 100644 --- a/services/gateway/src/main.rs +++ b/services/gateway/src/main.rs @@ -1732,7 +1732,12 @@ fn build_app(state: Arc) -> Router { .route("/jira/:token", post(routes::jira_webhook::handle)) .route("/jira", post(routes::jira_webhook::handle_forge)) // The Jira app's "Link my CoderHelm account" (a person's one-time code). - .route("/jira-link", post(routes::foryou_link::forge_link)) + .route( + "/jira-link", + post(routes::foryou_link::forge_link).layer(axum::extract::DefaultBodyLimit::max( + routes::foryou_link::MAX_LINK_BODY, + )), + ) .route("/alerts/sns", post(routes::alerts::handle_sns)) // Knowledge sources: a provider says pages changed (signed). .route( diff --git a/services/gateway/src/routes/foryou_link.rs b/services/gateway/src/routes/foryou_link.rs index 795d0a585..3bb4d7314 100644 --- a/services/gateway/src/routes/foryou_link.rs +++ b/services/gateway/src/routes/foryou_link.rs @@ -20,10 +20,10 @@ use std::sync::Arc; use aws_sdk_dynamodb::types::AttributeValue; -use axum::body::Bytes; +use axum::extract::rejection::JsonRejection; use axum::{extract::State, http::StatusCode, Extension, Json}; use common::foryou; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use tracing::{info, warn}; @@ -184,36 +184,33 @@ pub const MAX_LINK_BODY: usize = 2048; /// The team's proof, as the Jira app sends it (`linkBody` in /// `coderhelm-jira/src/link.js`). Nothing else is accepted. -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -struct LinkProof { - team_id: String, - forge_secret: String, +pub(crate) struct LinkProof { + pub(crate) team_id: String, + pub(crate) forge_secret: String, #[serde(default)] - app_version: Option, + pub(crate) app_version: Option, #[serde(default)] - app_id: Option, + pub(crate) app_id: Option, } /// A link request: plain strings only, every field known, nothing dynamic. -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -struct LinkRequest { - coderhelm: LinkProof, +pub(crate) struct LinkRequest { + pub(crate) coderhelm: LinkProof, #[serde(default)] - account_id: String, + pub(crate) account_id: String, #[serde(default)] - code: String, + pub(crate) code: String, } /// What the Jira app sent, checked: the team, its proof, the account and -/// the code. Over-long bodies and any field this doesn't know are refused -/// before anything is read; each string is bounded. -fn read_link(body: &[u8]) -> Result<(String, String, String, String), StatusCode> { - if body.is_empty() || body.len() > MAX_LINK_BODY { - return Err(StatusCode::PAYLOAD_TOO_LARGE); - } - let req: LinkRequest = serde_json::from_slice(body).map_err(|_| StatusCode::BAD_REQUEST)?; +/// the code. The body was read by axum into [`LinkRequest`] (no field it +/// doesn't know, at most [`MAX_LINK_BODY`] bytes); each string is bounded +/// here before anything is read. +fn read_link(req: &LinkRequest) -> Result<(String, String, String, String), StatusCode> { let short = |v: &Option| v.as_deref().is_none_or(|x| x.len() <= 128); if !short(&req.coderhelm.app_version) || !short(&req.coderhelm.app_id) { return Err(StatusCode::BAD_REQUEST); @@ -256,8 +253,11 @@ fn answer(code: StatusCode, message: &str) -> (StatusCode, Json) { /// and used up here. pub async fn forge_link( State(state): State>, - body: Bytes, + body: Result, JsonRejection>, ) -> (StatusCode, Json) { + let Ok(Json(body)) = body else { + return answer(StatusCode::BAD_REQUEST, "That request couldn't be read."); + }; let (team, secret, account, code) = match read_link(&body) { Ok(x) => x, Err(c) => return answer(c, "That request is missing what CoderHelm needs."), @@ -467,46 +467,29 @@ pub async fn seen_jira_users(state: &AppState, team: &str) -> Vec Result { + serde_json::from_value(v) + } + #[test] fn a_link_request_needs_the_team_its_proof_an_account_and_a_code() { - let b = |v: Value| serde_json::to_vec(&v).unwrap(); - let ok = b( - json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x", "app_version": "7.1.0"}, "account_id": "557058:a1b2c3d4", "code": "ABCD-EFGH-JKMN-PQRS"}), - ); + let ok = req(json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x", "app_version": "7.1.0"}, "account_id": "557058:a1b2c3d4", "code": "ABCD-EFGH-JKMN-PQRS"})).unwrap(); let (team, _, account, _) = read_link(&ok).unwrap(); assert_eq!(team, "TEAM#acme1"); assert_eq!(account, "557058:a1b2c3d4"); - let no_secret = b( - json!({"coderhelm": {"team_id": "acme1", "forge_secret": ""}, "account_id": "557058:a1b2c3d4", "code": "x"}), - ); + let no_secret = req(json!({"coderhelm": {"team_id": "acme1", "forge_secret": ""}, "account_id": "557058:a1b2c3d4", "code": "x"})).unwrap(); assert_eq!(read_link(&no_secret).unwrap_err(), StatusCode::UNAUTHORIZED); - let bad_id = b( - json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "x\" OR 1=1", "code": "c"}), - ); + let bad_id = req(json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "x\" OR 1=1", "code": "c"})).unwrap(); assert_eq!(read_link(&bad_id).unwrap_err(), StatusCode::BAD_REQUEST); - let no_code = b( - json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4"}), - ); + let no_code = req(json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4"})).unwrap(); assert_eq!(read_link(&no_code).unwrap_err(), StatusCode::BAD_REQUEST); } #[test] - fn a_link_request_is_small_plain_and_has_no_field_it_doesnt_know() { - let b = |v: Value| serde_json::to_vec(&v).unwrap(); - let extra = b( - json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "c", "user": "u_other"}), - ); - assert_eq!(read_link(&extra).unwrap_err(), StatusCode::BAD_REQUEST); - let nested = b( - json!({"coderhelm": {"team_id": {"$ne": ""}, "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "c"}), - ); - assert_eq!(read_link(&nested).unwrap_err(), StatusCode::BAD_REQUEST); - let big = vec![b' '; MAX_LINK_BODY + 1]; - assert_eq!(read_link(&big).unwrap_err(), StatusCode::PAYLOAD_TOO_LARGE); - assert_eq!(read_link(b"").unwrap_err(), StatusCode::PAYLOAD_TOO_LARGE); - let long_version = b( - json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x", "app_version": "9".repeat(200)}, "account_id": "557058:a1b2c3d4", "code": "c"}), - ); + fn a_link_request_is_plain_and_has_no_field_it_doesnt_know() { + assert!(req(json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "c", "user": "u_other"})).is_err()); + assert!(req(json!({"coderhelm": {"team_id": {"$ne": ""}, "forge_secret": "x"}, "account_id": "557058:a1b2c3d4", "code": "c"})).is_err()); + let long_version = req(json!({"coderhelm": {"team_id": "acme1", "forge_secret": "x", "app_version": "9".repeat(200)}, "account_id": "557058:a1b2c3d4", "code": "c"})).unwrap(); assert_eq!( read_link(&long_version).unwrap_err(), StatusCode::BAD_REQUEST From 9eebaffea56418944c711f3b3036f023556d6b53 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sun, 6 Dec 2026 01:58:29 -0500 Subject: [PATCH 19/19] Jira link route: the body limit by a named constant, so the route reads as its handler --- services/gateway/src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/gateway/src/main.rs b/services/gateway/src/main.rs index ec5940ee3..53a1aca7a 100644 --- a/services/gateway/src/main.rs +++ b/services/gateway/src/main.rs @@ -48,6 +48,9 @@ pub struct AppState { pub cognito_client_secret: String, } +/// The largest Jira link request taken (`routes::foryou_link::MAX_LINK_BODY`). +const JIRA_LINK_BODY_LIMIT: usize = routes::foryou_link::MAX_LINK_BODY; + #[tokio::main] async fn main() -> Result<(), Error> { // Structured JSON logging for CloudWatch @@ -1734,9 +1737,8 @@ fn build_app(state: Arc) -> Router { // The Jira app's "Link my CoderHelm account" (a person's one-time code). .route( "/jira-link", - post(routes::foryou_link::forge_link).layer(axum::extract::DefaultBodyLimit::max( - routes::foryou_link::MAX_LINK_BODY, - )), + post(routes::foryou_link::forge_link) + .layer(axum::extract::DefaultBodyLimit::max(JIRA_LINK_BODY_LIMIT)), ) .route("/alerts/sns", post(routes::alerts::handle_sns)) // Knowledge sources: a provider says pages changed (signed).