From 74ab827664828981f8dcf12c220dc3f9020eedcb Mon Sep 17 00:00:00 2001 From: Pranav Mathad Date: Sun, 29 Nov 2026 04:42:54 +0100 Subject: [PATCH] Do not show a simulation result where nothing was tested --- README.md | 9 ++- spec.md | 2 +- web/src/screens/decisions/FixFirst.tsx | 103 ++++++++++++++++++++----- web/src/screens/grid/FixPanel.tsx | 15 ++-- 4 files changed, 100 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 0abde6be..fab9850f 100644 --- a/README.md +++ b/README.md @@ -194,8 +194,13 @@ top 5 and of the top 10 are still in the top 5 and top 10 under the test. answers. It does not make a new call, so it does not show how the AI text would change on a run with the cache off. - A simulated fix that leaves its target link on the map is shown as "Simulated: the link - remains" (on the grid, "Fix simulated: the link remains"), not as checked: 32 of the 50 - simulated fixes on Artemis, 10 of 19 on Shopware and 35 of 50 on Graylog. + remains" (on the grid, "Fix simulated: the link remains"), not as checked: 29 of the 50 + simulated fixes on Artemis, 1 of 19 on Shopware and 22 of 50 on Graylog. +- The simulation works on link counts between modules, and a move moves the whole + declaring file. Of the 119 simulated fixes, 14 are fixes that remove a link (Artemis 8, + Shopware 5, Graylog 1): the link is taken away by assumption, so they are shown as + "Effect if the link is removed", not as checked. Another 26 (Artemis 4, Shopware 9, + Graylog 13) changed nothing on the map and are shown as "Not simulated". - When the AI answer names no fix action (for example when it judges the link to be intended wiring), the finding shows "No improvement proposed." and the AI's fix text is not shown. In the list to fix first that is 2 of 10 findings on Artemis, 5 of 10 on diff --git a/spec.md b/spec.md index 49b0964b..a203742a 100644 --- a/spec.md +++ b/spec.md @@ -483,7 +483,7 @@ For `move_symbol`, and for fixes that remove a specific link, the tool applies t "links_removed": 1, "links_added": 0, "new_exceptions": []} ``` -The report shows "fix checked by simulation" with these numbers. A simulated fix that does not remove the link it targets is shown as "simulated: the link remains", not as "fix checked by simulation". Other fix types are shown as "not simulated". A fix whose simulation creates new exceptions is shown with that warning. +The report shows "fix checked by simulation" with these numbers. A simulated fix that does not remove the link it targets is shown as "simulated: the link remains", not as "fix checked by simulation". A fix that removes a link (`route_through_api`, `invert_dependency`, `extract_interface`) is not tested: the map is shown with the link taken away and labelled "effect if the link is removed". A simulation that changes nothing on the map is shown as "not simulated". Other fix types are shown as "not simulated". A fix whose simulation creates new exceptions is shown with that warning. `split_by_responsibility` is shown as "not simulated". diff --git a/web/src/screens/decisions/FixFirst.tsx b/web/src/screens/decisions/FixFirst.tsx index 36641be4..109e86d1 100644 --- a/web/src/screens/decisions/FixFirst.tsx +++ b/web/src/screens/decisions/FixFirst.tsx @@ -2,7 +2,7 @@ import { type KeyboardEvent, type ReactNode, useEffect, useRef, useState } from import { Link } from "react-router"; import { Badge } from "../../components/Badge"; import { formatDate, formatSponsorDate } from "../../components/Shell"; -import type { Decision, Finding, Simulation } from "../../contracts/generated"; +import type { Decision, Finding, Fix, Simulation } from "../../contracts/generated"; import { viewLink } from "../../data/view"; import { ACTION_LABEL, @@ -142,7 +142,7 @@ export function FixFirst({ )} - {simulationShort(finding.simulation)} + {simulationShort(finding)} {finding.priority.score.toFixed(2)}

- +

@@ -389,24 +439,37 @@ function FindingDetail({ ); } -function SimulationText({ simulation }: { simulation: Simulation | null }) { - if (!simulation?.simulated) { - return <>Not simulated. Only moves and single-link removals are tried on the map.; - } +function SimulationText({ finding }: { finding: Finding }) { + const kind = simulationKind(finding); + const simulation: Simulation | null = finding.simulation; + if (kind === "not-simulated" || !simulation) return <>{NOT_SIMULATED_TEXT}; + if (kind === "nothing-changed") return <>{NOTHING_CHANGED_TEXT}; const loops = simulation.loops_before !== null && simulation.loops_after !== null ? `loops ${num(simulation.loops_before)} to ${num(simulation.loops_after)}` : "loops not counted"; const added = simulation.new_exceptions.length; - const remains = linkRemains(simulation); + const exceptions = + added === 0 ? "No new exceptions." : `Warning: ${added} new exception${added === 1 ? "" : "s"}.`; + if (kind === "effect-if-removed") { + const removed = simulation.links_removed; + const taken = + removed === 1 + ? "the 1 link between the two modules is taken away" + : `all ${num(removed)} links between the two modules are taken away`; + return ( + <> + Effect if the link is removed: {taken}, {loops}. {exceptions} + + ); + } + const remains = kind === "link-remains"; return ( <> {remains ? "Simulated: the link remains. " : "Fix checked by simulation: "} {remains ? loops[0].toUpperCase() + loops.slice(1) : loops}, {num(simulation.links_removed)} link {simulation.links_removed === 1 ? "" : "s"} removed, {num(simulation.links_added)} added.{" "} - {added === 0 - ? "No new exceptions." - : `Warning: ${added} new exception${added === 1 ? "" : "s"}.`} + {exceptions} ); } diff --git a/web/src/screens/grid/FixPanel.tsx b/web/src/screens/grid/FixPanel.tsx index d9e5f7de..da476860 100644 --- a/web/src/screens/grid/FixPanel.tsx +++ b/web/src/screens/grid/FixPanel.tsx @@ -3,7 +3,7 @@ import { Badge } from "../../components/Badge"; import type { BatchSimulation, Finding } from "../../contracts/generated"; import type { View } from "../../data/view"; -import { linkRemains } from "../decisions/FixFirst"; +import { NOTHING_CHANGED_TEXT, NOT_SIMULATED_TEXT, simulationKind } from "../decisions/FixFirst"; interface Props { finding: Finding | undefined; @@ -32,7 +32,8 @@ function Warning({ exceptions }: { exceptions: string[] }) { export function FixPanel({ finding, batch, fix, setFix }: Props) { const simulation = finding?.simulation; - const canTry = Boolean(simulation?.simulated); + const kind = simulationKind(finding); + const canTry = kind !== "not-simulated" && kind !== "nothing-changed"; const oneOn = fix === "one" && canTry; const allOn = fix === "all" && batch !== null; if (!finding && !batch) return null; @@ -45,14 +46,16 @@ export function FixPanel({ finding, batch, fix, setFix }: Props) {

{oneOn - ? linkRemains(simulation) - ? "Fix simulated: the link remains" - : "Fix checked by simulation" + ? kind === "effect-if-removed" + ? "Effect if the link is removed" + : kind === "link-remains" + ? "Fix simulated: the link remains" + : "Fix checked by simulation" : `The fix for finding ${finding.priority.rank}`}

{!canTry && (

- Not simulated. Only moves and single-link removals are tried on the map. + {kind === "nothing-changed" ? NOTHING_CHANGED_TEXT : NOT_SIMULATED_TEXT}

)} {oneOn && simulation && (