diff --git a/README.md b/README.md index 5f33eafd..cfd01e65 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ writes prose on top of those facts, and the app marks every AI sentence as AI. | Stage 3, `model`: the map of modules per snapshot | Works on all three repositories | | Stage 5, `analyze`: decisions, finding types, before and after | Works on all three repositories | | Stage 7, `report`: ranking, `findings.json`, the web bundle | Works on all three repositories | -| Web app: Overview, Decisions, Findings and finding detail, Map, Change, Trust, Size | Works on the three bundles and the two synthetic fixtures in `web/public/bundles/`; see [Web app](#web-app) | +| Web app: the tabs Report, Findings (with finding detail), Map, Before and after, Approach, and the Decisions and Size screens | Works on the three bundles and the two synthetic fixtures in `web/public/bundles/`; see [Web app](#web-app) | | Stage 6, `judge`: AI text for the shown findings | Works with `LLM_API_KEY` set; answers are cached in the run folder, so a re-run makes no call | | `decisions propose`: rules proposed from written decision documents | Works with `LLM_API_KEY` set; writes `proposals.yaml` for review, and the reviewed rules are in `rules/` | | `check ..`: decisions a change breaks | Works; lists each broken decision with file and line, and exits 1 when there is one | @@ -204,15 +204,15 @@ to include it in `web/dist`. | Address (after `#`) | Screen | |---|---| -| `/` | every repository, with its verdict and the finding to fix first | -| `/r/` | Overview: verdict, yardsticks, decisions, the simulated fix batch, the top findings | -| `/r//decisions` | Decisions: each checked decision with its conformance over time, and the written ones that cannot be checked | +| `/` | every repository, with the finding to fix first and its decisions by status; how the pipeline works | +| `/r/` | Report: verdict, yardsticks, decisions, the simulated fix batch, the top findings | +| `/r//decisions` | Decisions, reached from Report: each checked decision with its conformance over time, and the written ones that cannot be checked | | `/r//findings` | Findings: the ranked list and how the ranking is worked out | | `/r//findings/` | one finding: the reading of the code, the cited lines, the simulation, the priority | | `/r//map` | Map: the module grid. `?view=before\|now\|after`, `?cell=,`, `?finding=`, `?fix=` | -| `/r//change` | Change: before and after the compared date, structural events, hotspots | -| `/r//trust` | Trust: coverage, limits, stability of the ranking, AI calls and their cost | -| `/r//size` | Size: lines by module and file, and where the new lines landed | +| `/r//change` | Before and after: before and after the compared date, structural events, hotspots | +| `/r//trust` | Approach: coverage, limits, stability of the ranking, AI calls and their cost | +| `/r//size` | Size, reached from Map: lines by module and file, and where the new lines landed | Some values show "not measured in this run" because the bundle does not carry them yet: diff --git a/web/public/bundles/artemis/journeys.json b/web/public/bundles/artemis/journeys.json new file mode 100644 index 00000000..757e076f --- /dev/null +++ b/web/public/bundles/artemis/journeys.json @@ -0,0 +1,769 @@ +{ + "lanes": [ + "Browser", + "Web entry", + "Feature services", + "Course core", + "Queues & workers" + ], + "journeys": [ + { + "id": "push", + "name": "A student pushes code for a programming exercise", + "summary": "8 stops · 4 modules · 1 queue · ends with a live score in the browser", + "stops": [ + { + "lane": 0, + "module": "client", + "label": "git push", + "caption": "The student pushes their solution with git. Artemis hosts the repository itself, so the push goes straight to the server.", + "file": "git client → /git/ARTEMIS101/artemis101-alice.git", + "method": "HTTP POST · git-receive-pack", + "via": null, + "findingRank": null, + "payload": { + "type": "GitPush", + "definedIn": "git smart HTTP", + "fields": [ + { + "key": "ref", + "value": "\"refs/heads/main\"" + }, + { + "key": "commit", + "value": "\"8f2c1e4\"" + }, + { + "key": "changedFiles", + "value": "3" + } + ] + } + }, + { + "lane": 1, + "module": "programming", + "label": "accept push", + "caption": "The git servlet checks that the student is allowed to push and finds which participation the repository belongs to.", + "file": "programming/service/localvc/LocalVCServletService.java:412", + "method": "processNewPush(commitHash, repository)", + "via": { + "kind": "call", + "label": "HTTP request" + }, + "findingRank": null, + "payload": { + "type": "PushContext", + "definedIn": "LocalVCServletService.java", + "fields": [ + { + "key": "commit", + "value": "\"8f2c1e4\"" + }, + { + "key": "participationId", + "value": "48213" + }, + { + "key": "exerciseId", + "value": "3071" + }, + { + "key": "branch", + "value": "\"main\"" + } + ] + } + }, + { + "lane": 2, + "module": "programming", + "label": "save submission", + "caption": "A submission record is saved for this commit, so the build result can be attached to it later.", + "file": "programming/service/ProgrammingSubmissionService.java:118", + "method": "processNewProgrammingSubmission(participation, commit)", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "ProgrammingSubmission", + "definedIn": "programming/domain/ProgrammingSubmission.java", + "fields": [ + { + "key": "id", + "value": "902114" + }, + { + "key": "commitHash", + "value": "\"8f2c1e4\"" + }, + { + "key": "participationId", + "value": "48213" + }, + { + "key": "type", + "value": "\"MANUAL\"" + }, + { + "key": "submissionDate", + "value": "\"2026-11-27T14:02:11Z\"" + } + ] + } + }, + { + "lane": 4, + "module": "programming", + "label": "queue build", + "caption": "Instead of building right away, the job goes onto a shared queue so that any free build agent can pick it up.", + "file": "programming/service/localci/LocalCITriggerService.java:96", + "method": "triggerBuild(participation, commitHash)", + "via": { + "kind": "queue", + "label": "Hazelcast queue buildJobQueue" + }, + "findingRank": null, + "payload": { + "type": "BuildJobQueueItem", + "definedIn": "buildagent/dto/BuildJobQueueItem.java", + "fields": [ + { + "key": "id", + "value": "\"bj-77a1\"" + }, + { + "key": "participationId", + "value": "48213" + }, + { + "key": "repositoryUri", + "value": "\"…/artemis101-alice.git\"" + }, + { + "key": "commitHash", + "value": "\"8f2c1e4\"" + }, + { + "key": "priority", + "value": "2" + }, + { + "key": "buildConfig", + "value": "{ dockerImage: \"ls1tum/artemis-maven\", timeoutSec: 120 }" + } + ] + } + }, + { + "lane": 4, + "module": "buildagent", + "label": "run tests", + "caption": "A build agent takes the job, runs the instructor's tests in a container, and reports which tests passed.", + "file": "buildagent/service/BuildJobExecutionService.java:201", + "method": "runBuildJob(buildJob, containerName)", + "via": { + "kind": "queue", + "label": "polled from buildJobQueue" + }, + "findingRank": null, + "payload": { + "type": "BuildResult", + "definedIn": "buildagent/dto/BuildResult.java", + "fields": [ + { + "key": "jobId", + "value": "\"bj-77a1\"" + }, + { + "key": "successful", + "value": "false" + }, + { + "key": "testResults", + "value": "[ 17 passed, 3 failed ]" + }, + { + "key": "buildLogs", + "value": "\"214 lines\"" + }, + { + "key": "durationMs", + "value": "38412" + } + ] + } + }, + { + "lane": 3, + "module": "assessment", + "label": "score result", + "caption": "The test results become a score with one piece of feedback per test, and it is stored against the submission.", + "file": "assessment/service/ResultService.java:233", + "method": "processNewProgrammingExerciseResult(participation, buildResult)", + "via": { + "kind": "queue", + "label": "Hazelcast result queue" + }, + "findingRank": null, + "payload": { + "type": "Result", + "definedIn": "assessment/domain/Result.java", + "fields": [ + { + "key": "id", + "value": "1500872" + }, + { + "key": "submissionId", + "value": "902114" + }, + { + "key": "score", + "value": "85.0" + }, + { + "key": "successful", + "value": "false" + }, + { + "key": "feedbacks", + "value": "[ 20 items ]" + }, + { + "key": "completionDate", + "value": "\"2026-11-27T14:02:52Z\"" + } + ] + } + }, + { + "lane": 1, + "module": "communication", + "label": "push to browser", + "caption": "The new result is sent over a websocket to the topic the student's browser is already listening on.", + "file": "communication/service/WebsocketMessagingService.java:58", + "method": "sendMessage(\"/topic/participation/48213/newResults\", result)", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "ResultDTO", + "definedIn": "assessment/dto/ResultDTO.java", + "fields": [ + { + "key": "topic", + "value": "\"/topic/participation/48213/newResults\"" + }, + { + "key": "score", + "value": "85.0" + }, + { + "key": "successful", + "value": "false" + }, + { + "key": "testCaseCount", + "value": "20" + }, + { + "key": "passedTestCaseCount", + "value": "17" + } + ] + } + }, + { + "lane": 0, + "module": "client", + "label": "show score", + "caption": "The exercise page updates without a reload and shows 85% with the three failing tests listed.", + "file": "webapp/app/programming/…/result.component.ts", + "method": "subscribe → onNewResult(result)", + "via": { + "kind": "ws", + "label": "websocket" + }, + "findingRank": null, + "payload": { + "type": "UI state", + "definedIn": "Angular component", + "fields": [ + { + "key": "badge", + "value": "\"85 %\"" + }, + { + "key": "passed", + "value": "\"17 of 20 tests\"" + }, + { + "key": "failing", + "value": "[\"testSortEmpty\", \"testSortNull\", \"testStable\"]" + } + ] + } + } + ] + }, + { + "id": "exam", + "name": "An instructor starts an exam for 412 students", + "summary": "7 stops · 3 modules · 1 step is a finding", + "stops": [ + { + "lane": 0, + "module": "client", + "label": "click Start", + "caption": "The instructor clicks Start exercises on the exam page.", + "file": "webapp/app/exam/manage/exam-checklist.component.ts", + "method": "POST /api/exam/courses/12/exams/77/student-exams/start-exercises", + "via": null, + "findingRank": null, + "payload": { + "type": "HTTP request", + "definedIn": "REST", + "fields": [ + { + "key": "courseId", + "value": "12" + }, + { + "key": "examId", + "value": "77" + } + ] + } + }, + { + "lane": 1, + "module": "exam", + "label": "exam endpoint", + "caption": "The exam endpoint checks the instructor's role and hands the work to the exam service.", + "file": "exam/web/StudentExamResource.java:340", + "method": "startExercises(courseId, examId)", + "via": { + "kind": "call", + "label": "HTTP request" + }, + "findingRank": null, + "payload": { + "type": "StartRequest", + "definedIn": "exam/web/StudentExamResource.java", + "fields": [ + { + "key": "courseId", + "value": "12" + }, + { + "key": "examId", + "value": "77" + }, + { + "key": "requestedBy", + "value": "\"instructor42\"" + } + ] + } + }, + { + "lane": 2, + "module": "exam", + "label": "plan participations", + "caption": "The service loads every student exam and works out which exercises each student gets.", + "file": "exam/service/StudentExamService.java:512", + "method": "startExercises(examId)", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "List", + "definedIn": "exam/domain/StudentExam.java", + "fields": [ + { + "key": "examId", + "value": "77" + }, + { + "key": "studentExams", + "value": "412" + }, + { + "key": "exercisesPerStudent", + "value": "5" + } + ] + } + }, + { + "lane": 4, + "module": "programming", + "label": "read repo table", + "caption": "Exam reads programming's repository class directly to load the exercise templates. That repository is used by 107 files and changed 30 times in 12 months, which is finding #22.", + "file": "exam/service/StudentExamService.java:548 → programming/repository/ProgrammingExerciseRepository.java", + "method": "findByIdWithTemplateAndSolutionParticipationElseThrow(id)", + "via": { + "kind": "find", + "label": "direct repository access" + }, + "findingRank": 22, + "payload": { + "type": "ProgrammingExercise", + "definedIn": "programming/domain/ProgrammingExercise.java", + "fields": [ + { + "key": "id", + "value": "3071" + }, + { + "key": "templateParticipation", + "value": "{ id: 901 }" + }, + { + "key": "solutionParticipation", + "value": "{ id: 902 }" + }, + { + "key": "buildConfig", + "value": "{ … }" + } + ] + } + }, + { + "lane": 2, + "module": "programming", + "label": "create participations", + "caption": "For each student, a personal repository is copied from the template and a participation is created.", + "file": "programming/service/ParticipationService.java:190", + "method": "startExercise(exercise, student)", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "StudentParticipation", + "definedIn": "exercise/domain/participation/StudentParticipation.java", + "fields": [ + { + "key": "created", + "value": "412" + }, + { + "key": "failed", + "value": "0" + }, + { + "key": "repositoriesCopied", + "value": "412" + } + ] + } + }, + { + "lane": 1, + "module": "communication", + "label": "report progress", + "caption": "Progress is pushed to the instructor's page while students are processed.", + "file": "exam/service/StudentExamService.java:603", + "method": "convertAndSend(\"/topic/exams/77/exercise-start-status\")", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "ExerciseStartStatus", + "definedIn": "exam/dto/ExamExerciseStartPreparationStatus.java", + "fields": [ + { + "key": "finished", + "value": "412" + }, + { + "key": "failed", + "value": "0" + }, + { + "key": "participationCount", + "value": "2060" + } + ] + } + }, + { + "lane": 0, + "module": "client", + "label": "show 100%", + "caption": "The progress bar reaches 412 of 412 and the exam can open.", + "file": "webapp/app/exam/manage/exam-checklist.component.ts", + "method": "subscribe → updateProgress(status)", + "via": { + "kind": "ws", + "label": "websocket" + }, + "findingRank": null, + "payload": { + "type": "UI state", + "definedIn": "Angular component", + "fields": [ + { + "key": "progress", + "value": "\"412 / 412\"" + }, + { + "key": "readyToOpen", + "value": "true" + } + ] + } + } + ] + }, + { + "id": "grade", + "name": "A tutor grades a text answer", + "summary": "7 stops · 4 modules · ends with a notification to the student", + "stops": [ + { + "lane": 0, + "module": "client", + "label": "submit grade", + "caption": "The tutor highlights parts of the answer, adds comments, and clicks Submit.", + "file": "webapp/app/text/manage/assess/text-submission-assessment.component.ts", + "method": "PUT /api/text/participations/5521/results/889/submit-text-assessment", + "via": null, + "findingRank": null, + "payload": { + "type": "HTTP body", + "definedIn": "REST", + "fields": [ + { + "key": "feedbacks", + "value": "[ 4 items ]" + }, + { + "key": "textBlocks", + "value": "[ 6 items ]" + } + ] + } + }, + { + "lane": 1, + "module": "text", + "label": "grading endpoint", + "caption": "The text endpoint checks that this tutor holds the lock on the submission.", + "file": "text/web/TextAssessmentResource.java:171", + "method": "submitTextAssessment(participationId, resultId, dto)", + "via": { + "kind": "call", + "label": "HTTP request" + }, + "findingRank": null, + "payload": { + "type": "TextAssessmentDTO", + "definedIn": "text/dto/TextAssessmentDTO.java", + "fields": [ + { + "key": "participationId", + "value": "5521" + }, + { + "key": "resultId", + "value": "889" + }, + { + "key": "feedbacks", + "value": "[ 4 items ]" + }, + { + "key": "textBlocks", + "value": "[ 6 items ]" + } + ] + } + }, + { + "lane": 2, + "module": "text", + "label": "store feedback", + "caption": "Each comment is tied to the highlighted text block so it can be shown in place later.", + "file": "text/service/TextAssessmentService.java:84", + "method": "saveFeedback(textBlocks, feedbacks)", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "List", + "definedIn": "assessment/domain/Feedback.java", + "fields": [ + { + "key": "resultId", + "value": "889" + }, + { + "key": "feedbacks", + "value": "[ 4 items ]" + }, + { + "key": "linkedBlocks", + "value": "4" + }, + { + "key": "totalCredits", + "value": "7.5" + } + ] + } + }, + { + "lane": 3, + "module": "assessment", + "label": "finalise result", + "caption": "The result is scored, marked as rated, and locked against further edits.", + "file": "assessment/service/ResultService.java:301", + "method": "submitManualAssessment(resultId)", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "Result", + "definedIn": "assessment/domain/Result.java", + "fields": [ + { + "key": "id", + "value": "889" + }, + { + "key": "score", + "value": "75.0" + }, + { + "key": "rated", + "value": "true" + }, + { + "key": "assessor", + "value": "\"tutor17\"" + }, + { + "key": "completionDate", + "value": "\"2026-11-27T16:40:03Z\"" + } + ] + } + }, + { + "lane": 2, + "module": "athena", + "label": "share for learning", + "caption": "If the course allows it, the graded feedback is sent to Athena so it can suggest feedback for similar answers.", + "file": "athena/service/AthenaFeedbackSendingService.java:72", + "method": "sendFeedback(exercise, submission, feedbacks)", + "via": { + "kind": "call", + "label": "method call (async)" + }, + "findingRank": null, + "payload": { + "type": "AthenaFeedbackDTO", + "definedIn": "athena/dto/TextFeedbackDTO.java", + "fields": [ + { + "key": "exerciseId", + "value": "2210" + }, + { + "key": "submissionId", + "value": "5521" + }, + { + "key": "feedbacks", + "value": "[ 4 items ]" + }, + { + "key": "module", + "value": "\"module_text_cofee\"" + } + ] + } + }, + { + "lane": 1, + "module": "communication", + "label": "notify student", + "caption": "The student gets a notification that their answer was graded.", + "file": "communication/service/notifications/SingleUserNotificationService.java:140", + "method": "notifyUserAboutAssessedExerciseSubmission(exercise, user)", + "via": { + "kind": "call", + "label": "method call" + }, + "findingRank": null, + "payload": { + "type": "SingleUserNotification", + "definedIn": "communication/domain/notification/SingleUserNotification.java", + "fields": [ + { + "key": "recipient", + "value": "\"alice\"" + }, + { + "key": "title", + "value": "\"Exercise assessed\"" + }, + { + "key": "exerciseId", + "value": "2210" + }, + { + "key": "score", + "value": "75.0" + } + ] + } + }, + { + "lane": 0, + "module": "client", + "label": "see feedback", + "caption": "The student opens the notification and sees each comment next to the sentence it is about.", + "file": "webapp/app/text/overview/text-result.component.ts", + "method": "subscribe → onNotification(n)", + "via": { + "kind": "ws", + "label": "websocket" + }, + "findingRank": null, + "payload": { + "type": "UI state", + "definedIn": "Angular component", + "fields": [ + { + "key": "score", + "value": "\"75 %\"" + }, + { + "key": "inlineComments", + "value": "4" + } + ] + } + } + ] + } + ] +} diff --git a/web/src/App.tsx b/web/src/App.tsx index 3aa764fb..655c2fb2 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -4,6 +4,7 @@ import { Change } from "./routes/Change"; import { Decisions } from "./routes/Decisions"; import { FindingDetail } from "./routes/FindingDetail"; import { Findings } from "./routes/Findings"; +import { Journeys } from "./routes/Journeys"; import { Landing } from "./routes/Landing"; import { MapPage } from "./routes/MapPage"; import { NotFound } from "./routes/NotFound"; @@ -20,6 +21,7 @@ export function App() { } /> }> } /> + } /> } /> } /> } /> diff --git a/web/src/components/cx/closeup.tsx b/web/src/components/cx/closeup.tsx index fe85b554..95d7615c 100644 --- a/web/src/components/cx/closeup.tsx +++ b/web/src/components/cx/closeup.tsx @@ -163,7 +163,7 @@ export function Closeup({ repo, finding }: { repo: RepoBundle; finding: Finding const ly = (sy + ey) / 2 + (off ? ny * 1.8 : (dx / len) * 8) + 3; return ( - {`${at.get(e.src)!.label} uses ${at.get(e.dst)!.label}: ${e.count} ${e.count === 1 ? "link" : "links"}, ${e.against ? "against" : "with"} the grain`} + {`${at.get(e.src)!.label} uses ${at.get(e.dst)!.label}: ${e.count} ${e.count === 1 ? "link" : "links"}, ${e.against ? "backward" : "forward"}`}
  • - with the grain + forward link
  • - against the grain + backward link
  • {partners && (
  • diff --git a/web/src/components/cx/code-block.tsx b/web/src/components/cx/code-block.tsx index 792f6e05..23efd07b 100644 --- a/web/src/components/cx/code-block.tsx +++ b/web/src/components/cx/code-block.tsx @@ -94,9 +94,13 @@ export function EvidencePane({ repo, evidence }: { repo: RepoBundle; evidence: E const [root, setRoot] = useState(() => readCloneRoot(repo.id)); const [editing, setEditing] = useState(false); const [opened, setOpened] = useState>(() => new Set()); - const askRoot = () => setEditing(true); + const [moreFiles, setMoreFiles] = useState(false); + const [showCommits, setShowCommits] = useState(false); const shown = files.slice(0, OPEN_FILES); const listed = files.slice(OPEN_FILES); + const commitCount = commits.reduce((n, ev) => n + ev.commits.length, 0); + const listId = useId(); + const commitsId = useId(); return (
    @@ -126,13 +130,24 @@ export function EvidencePane({ repo, evidence }: { repo: RepoBundle; evidence: E

    This finding holds no evidence record.

    )} {shown.map((g) => ( - + ))} {listed.length > 0 && ( -
    + setMoreFiles((on) => !on)} + controls={listId} + label={ + moreFiles + ? `Hide the ${fmtCount(listed.length, "other file", "other files")}` + : `Show ${fmtCount(listed.length, "more file", "more files")}` + } + /> + )} + {listed.length > 0 && moreFiles && ( +

    - {listed.length} more {listed.length === 1 ? "file" : "files"} · open one to read its - lines + Open a file to read its lines.

      {listed.map((g) => { @@ -173,7 +188,7 @@ export function EvidencePane({ repo, evidence }: { repo: RepoBundle; evidence: E {open && (
      - +
      )} @@ -182,13 +197,64 @@ export function EvidencePane({ repo, evidence }: { repo: RepoBundle; evidence: E
    )} - {commits.map((ev) => ( - - ))} + {commitCount > 0 && ( + setShowCommits((on) => !on)} + controls={commitsId} + label={ + showCommits + ? "Hide the commits" + : `Show the ${fmtCount(commitCount, "commit", "commits")}` + } + /> + )} + {commitCount > 0 && showCommits && ( +
    + {commits.map((ev) => ( + + ))} +
    + )}
    ); } +const fmtCount = (n: number, one: string, many: string) => + `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`; + +/** One closed control that opens the rest of the evidence. */ +function Disclosure({ + open, + onToggle, + controls, + label, +}: { + open: boolean; + onToggle: () => void; + controls: string; + label: string; +}) { + return ( + + ); +} + function CloneFolder({ repoId, root, @@ -279,12 +345,10 @@ function FileBlock({ repo, group, root, - onAskRoot, }: { repo: RepoBundle; group: FileGroup; root: string | null; - onAskRoot: () => void; }) { const first = group.records.find((r) => r.startLine !== null) ?? group.records[0]!; const file = group.path.split("/").pop() ?? group.path; @@ -309,16 +373,11 @@ function FileBlock({ {hostName(repo.host)} @ {repo.endSha.slice(0, 7)} )} - {editor ? ( + {editor && ( Editor - ) : ( - )} diff --git a/web/src/components/cx/journeys.tsx b/web/src/components/cx/journeys.tsx new file mode 100644 index 00000000..ec07f89f --- /dev/null +++ b/web/src/components/cx/journeys.tsx @@ -0,0 +1,584 @@ +// The journey player: one user action drawn as a line across the layers of the codebase. A dip +// means the request goes down into core code, a rise means the result comes back up. Plain SVG +// and CSS; the only animation is a small packet travelling along the edge being played. +import { ChevronLeft, ChevronRight, Pause, Play } from "lucide-react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { Link } from "react-router"; +import { findingPath } from "../../cx/address"; +import { TYPE } from "../../cx/meta"; +import type { RepoBundle } from "../../cx/types"; +import type { Journey, JourneyBundle, JourneyStop } from "../../data/journeys"; +import { FOCUS, cn } from "./cn"; +import { allFindings } from "./finding-fix"; + +const W = 1000; +const X0 = 190; +const X1 = 950; +const LANE_H = 72; + +/** How long the packet takes along one edge, and how long a stop stays open while playing. */ +const TRAVEL_MS = 1000; +const DWELL_MS = 1900; + +const VIA_TEXT: Record = { + call: "method call", + queue: "queue, handled later", + ws: "pushed to the browser", + find: "step that is a ranked finding", +}; + +function reducedMotion(): boolean { + return ( + typeof window !== "undefined" && + !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches + ); +} + +/** "A student pushes code for a programming exercise" → "Student pushes code". */ +function shortName(name: string): string { + const s = name.replace(/^(An?|The) /, "").replace(/ for .*$/, ""); + return s.charAt(0).toUpperCase() + s.slice(1); +} + +type Pt = { x: number; y: number }; + +function edgePath(a: Pt, b: Pt): string { + const mx = (a.x + b.x) / 2; + return `M${a.x},${a.y} C${mx},${a.y} ${mx},${b.y} ${b.x},${b.y}`; +} + +function edgeKind(s: JourneyStop): "call" | "queue" | "ws" | "find" { + if (s.findingRank) return "find"; + return s.via?.kind ?? "call"; +} + +const EDGE_STYLE: Record = + { + call: { stroke: "var(--grain)", width: 2.5 }, + queue: { stroke: "var(--foreground)", dash: "7 5", width: 2.5 }, + ws: { stroke: "var(--grain)", dash: "2 5", width: 2.5, cap: "round" }, + // A finding step is drawn heavier; vermilion only when the finding is code against a decision. + find: { stroke: "var(--foreground)", width: 4 }, + against: { stroke: "var(--against)", width: 4 }, + }; + +// ---- the wave --------------------------------------------------------------------------- + +function Wave({ + lanes, + journey, + idx, + travelling, + onPick, + against = new Set(), + compact = false, +}: { + lanes: string[]; + journey: Journey; + idx: number; + /** The edge the packet is on, or null. */ + travelling: number | null; + onPick?: (i: number) => void; + /** Ranks of findings that are code against a decision. */ + against?: Set; + compact?: boolean; +}) { + const stops = journey.stops; + const n = stops.length; + // The still preview packs the lanes closer so the drawing stays short on the report page. + const laneH = compact ? 50 : LANE_H; + const laneY = (i: number) => (compact ? 54 : 46) + i * laneH; + const pts = stops.map((s, i) => ({ + x: X0 + (i * (X1 - X0)) / Math.max(1, n - 1), + y: laneY(s.lane), + })); + const H = laneY(lanes.length - 1) + (compact ? 46 : 54); + const pathRefs = useRef<(SVGPathElement | null)[]>([]); + const packet = useRef(null); + + // Moves the packet along the edge being played. + useEffect(() => { + const g = packet.current; + if (!g) return; + if (travelling === null || reducedMotion()) { + g.style.opacity = "0"; + return; + } + const path = pathRefs.current[travelling]; + if (!path) return; + const len = path.getTotalLength(); + const start = performance.now(); + let raf = 0; + g.style.opacity = "1"; + const step = (now: number) => { + const k = Math.min(1, (now - start) / TRAVEL_MS); + const e = k < 0.5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2; + const p = path.getPointAtLength(len * e); + g.setAttribute("transform", `translate(${p.x},${p.y})`); + if (k < 1) raf = requestAnimationFrame(step); + else g.style.opacity = "0"; + }; + raf = requestAnimationFrame(step); + return () => cancelAnimationFrame(raf); + }, [travelling]); + + const label = travelling !== null ? (stops[travelling + 1]?.payload.type ?? "") : ""; + + return ( + + {lanes.map((l, i) => ( + + {i % 2 === 0 && ( + + )} + + + {l} + + + ))} + {pts.slice(1).map((b, i) => { + const next = stops[i + 1]; + const kind = next.findingRank && against.has(next.findingRank) ? "against" : edgeKind(next); + const st = EDGE_STYLE[kind]; + const future = i >= idx && travelling !== i; + return ( + { + pathRefs.current[i] = el; + }} + d={edgePath(pts[i], b)} + fill="none" + stroke={st.stroke} + strokeWidth={st.width} + strokeDasharray={st.dash} + strokeLinecap={st.cap} + className="transition-opacity duration-300" + opacity={future ? 0.2 : 1} + /> + ); + })} + {stops.map((s, i) => { + const p = pts[i]; + const up = i % 2 === 0; + const on = i === idx && travelling === null; + const future = i > idx; + const flag = !!s.findingRank; + const flagColor = + s.findingRank && against.has(s.findingRank) ? "var(--against)" : "var(--foreground)"; + return ( + onPick(i) : undefined} + onKeyDown={ + onPick + ? (e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + onPick(i); + } + } + : undefined + } + className={cn("group outline-none", onPick && "cursor-pointer")} + opacity={future ? 0.45 : 1} + > + + + + {s.module} + + + {s.label} + + + ); + })} + + + + {label} + + + + + ); +} + +function Legend() { + return ( +
      + {Object.entries(VIA_TEXT).map(([k, text]) => { + const st = EDGE_STYLE[k]; + return ( +
    • + + + + {text} +
    • + ); + })} +
    + ); +} + +// ---- the stop detail -------------------------------------------------------------------- + +function Payload({ stop, prev }: { stop: JourneyStop; prev: JourneyStop | null }) { + const before = new Set((prev?.payload.fields ?? []).map((f) => f.key)); + return ( +
    +
    + {stop.payload.type} + + {stop.payload.definedIn} + +
    +
    +        {"{"}
    +        {stop.payload.fields.map((f) => {
    +          const added = prev !== null && !before.has(f.key);
    +          return (
    +            
    +              {"  "}
    +              {f.key}
    +              : 
    +              {f.value}
    +            
    +          );
    +        })}
    +        {"}"}
    +      
    +

    + {prev ? "Highlighted fields are new at this stop. " : ""}Values are an example request. +

    +
    + ); +} + +function StopDetail({ + repo, + lanes, + journey, + idx, +}: { + repo: RepoBundle; + lanes: string[]; + journey: Journey; + idx: number; +}) { + const s = journey.stops[idx]; + const prev = idx > 0 ? journey.stops[idx - 1] : null; + const finding = s.findingRank + ? allFindings(repo).find((f) => f.rank === s.findingRank) + : undefined; + return ( +
    +
    +

    + Stop {idx + 1} of {journey.stops.length} + / + {lanes[s.lane]} +

    +

    {s.caption}

    +
    + {s.file} + + {s.method} + +
    +

    + {s.via ? ( + <> + Arrived by {s.via.label} + {prev && ( + <> + {" "} + from {prev.module} + + )} + + ) : ( + "Start of the journey" + )} +

    + {finding && ( + + #{finding.rank} + + {finding.title} + + Open the finding, its graph and its code + + + + )} +
    +
    + +
    +
    + ); +} + +// ---- the player ------------------------------------------------------------------------- + +const ctlBase = + "inline-flex h-8 min-w-8 items-center justify-center gap-1.5 rounded-md border px-2.5 font-mono text-xs transition-colors disabled:opacity-40"; +const ctl = cn(ctlBase, "bg-card hover:bg-muted", FOCUS); +const ctlPrimary = cn( + ctlBase, + "border-foreground bg-foreground px-3 text-background hover:bg-foreground/85", + FOCUS, +); + +export function JourneyPlayer({ + repo, + bundle, + start, +}: { + repo: RepoBundle; + bundle: JourneyBundle; + /** The journey id and 0-based stop to open first, from the address. */ + start?: { journey: string | null; stop: number }; +}) { + const startJ = Math.max( + 0, + bundle.journeys.findIndex((j) => j.id === start?.journey), + ); + const [jIdx, setJIdx] = useState(startJ); + const [idx, setIdx] = useState(() => + Math.max(0, Math.min(bundle.journeys[startJ].stops.length - 1, start?.stop ?? 0)), + ); + const [playing, setPlaying] = useState(false); + const [travelling, setTravelling] = useState(null); + const journey = bundle.journeys[jIdx]; + const last = journey.stops.length - 1; + + const stop = useCallback(() => { + setPlaying(false); + setTravelling(null); + }, []); + const go = useCallback( + (i: number) => { + stop(); + setIdx(Math.max(0, Math.min(last, i))); + }, + [last, stop], + ); + + // While playing: travel one edge, open the stop it reaches, stay there a moment, repeat. + useEffect(() => { + if (!playing) return; + if (travelling === null) { + if (idx >= last) { + setPlaying(false); + return; + } + const t = window.setTimeout(() => setTravelling(idx), DWELL_MS); + return () => window.clearTimeout(t); + } + const t = window.setTimeout( + () => { + setTravelling(null); + setIdx(travelling + 1); + }, + reducedMotion() ? 0 : TRAVEL_MS, + ); + return () => window.clearTimeout(t); + }, [playing, travelling, idx, last]); + + const togglePlay = () => { + if (playing) return stop(); + const from = idx >= last ? 0 : idx; + setIdx(from); + setPlaying(true); + setTravelling(from); + }; + + const onKey = (e: React.KeyboardEvent) => { + if ((e.target as HTMLElement).tagName === "BUTTON" && e.key === " ") return; + if (e.key === "ArrowRight") go(idx + 1); + else if (e.key === "ArrowLeft") go(idx - 1); + }; + + const modules = useMemo(() => new Set(journey.stops.map((s) => s.module)).size, [journey]); + const findingSteps = journey.stops.filter((s) => + allFindings(repo).some((f) => f.rank === s.findingRank), + ).length; + const against = useMemo( + () => + new Set( + allFindings(repo) + .filter((f) => TYPE[f.type].group === "Decision exception") + .map((f) => f.rank), + ), + [repo], + ); + + return ( +
    +
    +
    + {bundle.journeys.map((j, i) => ( + + ))} +
    +
    + + + +
    +
    +
    +

    {journey.name}

    +

    + {journey.stops.length} stops through {modules} modules + {findingSteps > 0 && + `, ${findingSteps} ${findingSteps === 1 ? "step is a ranked finding" : "steps are ranked findings"}`} + . +

    +
    +
    + +
    +
    + +
    + +
    + ); +} + +/** A still drawing of one journey for the report page. */ +export function JourneyPreview({ bundle, journey }: { bundle: JourneyBundle; journey: Journey }) { + return ( + + ); +} diff --git a/web/src/components/cx/map-controls.tsx b/web/src/components/cx/map-controls.tsx index 4fdbfc61..474be24b 100644 --- a/web/src/components/cx/map-controls.tsx +++ b/web/src/components/cx/map-controls.tsx @@ -5,11 +5,10 @@ import { type KeyboardEvent, useRef } from "react"; import type { MapView } from "../../cx/address"; import { fmt, pct } from "../../cx/meta"; import type { Finding, RepoBundle, Yardstick } from "../../cx/types"; -import { NotMeasured } from "./badges"; import { FOCUS, cn } from "./cn"; export const GRID_ORDER_NOTE = - "The grid uses one module order for both dates so the picture does not move. Yardstick totals use each date's own order, so they can differ from a count of the cells below the diagonal."; + "Every view keeps the same module order so squares line up between dates. The totals above use each date's own order, so they can differ slightly from the squares."; export function viewLabel(repo: RepoBundle, view: MapView): string { if (view === "before") return `Before · ${repo.beforeDate.slice(0, 7)}`; @@ -101,27 +100,12 @@ export function ViewToggle({ ); } -function Value({ - value, - format, - className, -}: { - value: number | null; - format: (v: number) => string; - className?: string; -}) { - return value === null ? ( - - ) : ( - {format(value)} - ); -} - const at = (y: Yardstick, view: "before" | "now") => (view === "before" ? y.before : y.now); /** * The stored numbers for the view: the yardsticks at the end snapshot or at the before - * date; for the fix batch and a tried fix, the simulation's own loop counts. + * date; for the fix batch and a tried fix, the simulation's own loop counts. A value the + * bundle does not hold is left out. */ export function GridNumbers({ repo, @@ -138,18 +122,13 @@ export function GridNumbers({ const cls = cn("flex flex-wrap gap-x-5 gap-y-1 font-mono", small ? "text-[11px]" : "text-xs"); if (fix?.simulation) { const s = fix.simulation; + if (s.loopsBefore === null || s.loopsAfter === null) return null; return (
    -
    loops in this simulation
    -
    - {s.loopsBefore === null || s.loopsAfter === null ? ( - - ) : ( - - {fmt(s.loopsBefore)} → {fmt(s.loopsAfter)} - - )} +
    module loops in this simulation
    +
    + {fmt(s.loopsBefore)} → {fmt(s.loopsAfter)}
    @@ -157,24 +136,13 @@ export function GridNumbers({ } if (view === "after") { const b = repo.batch; + if (!b) return null; return (
    -
    loops, simulation's count
    -
    - {b ? ( - - {fmt(b.loopsBefore)} → {fmt(b.loopsAfter)} - - ) : ( - - )} -
    -
    -
    -
    against grain after fixes
    -
    - +
    module loops, before and after the fixes
    +
    + {fmt(b.loopsBefore)} → {fmt(b.loopsAfter)}
    @@ -183,6 +151,7 @@ export function GridNumbers({ const share = at(y.againstGrainShare, view); const links = at(y.againstGrain, view); const pairs = at(y.twoWayPairs, view); + if (share === null && pairs === null) return null; return (
    -
    -
    against grain
    -
    - pct(v)} className="text-accent" /> - {!small && links !== null && ( - · {fmt(links)} links - )} -
    -
    -
    -
    two-way pairs
    -
    - -
    -
    + {share !== null && ( +
    +
    backward links
    +
    + {pct(share)} + {!small && links !== null && ( + · {fmt(links)} links + )} +
    +
    + )} + {pairs !== null && ( +
    +
    two-way dependencies
    +
    {fmt(pairs)}
    +
    + )}
    ); } @@ -232,10 +203,10 @@ export function MapLegend({ )} >
  • - with the grain + forward link
  • - against the grain + backward link
  • diff --git a/web/src/components/cx/matrix.tsx b/web/src/components/cx/matrix.tsx index c747874f..57effd3c 100644 --- a/web/src/components/cx/matrix.tsx +++ b/web/src/components/cx/matrix.tsx @@ -89,7 +89,7 @@ export function cellName( const v = values[i]![j]!; const head = `${src.path}${only(src)} uses ${dst.path}${only(dst)}`; const body = - v === 0 ? `${head}, no links` : `${head} ${times(v)}, ${i > j ? "against" : "with"} the grain`; + v === 0 ? `${head}, no links` : `${head} ${times(v)}, ${i > j ? "backward" : "forward"}`; return change ? `${body}; ${fmt(change.before)} to ${fmt(change.after)} links ${changeSource}`.trim() : body; @@ -327,7 +327,7 @@ export function Matrix({
    {" · "} j ? "text-accent" : "text-primary"}> - {i > j ? "against the grain" : "with the grain"} + {i > j ? "backward link" : "forward link"} )} @@ -870,7 +870,7 @@ function Tip({ {v > 0 && ( j ? "text-accent" : "text-primary"}> {" · "} - {i > j ? "against the grain" : "with the grain"} + {i > j ? "backward link" : "forward link"} )} diff --git a/web/src/components/cx/overview-map.tsx b/web/src/components/cx/overview-map.tsx index a3f9e1c3..68de887d 100644 --- a/web/src/components/cx/overview-map.tsx +++ b/web/src/components/cx/overview-map.tsx @@ -7,7 +7,6 @@ import { FOCUS, cn } from "./cn"; import { GridNumbers, MapLegend, ViewToggle, viewLabel } from "./map-controls"; import { gridMax, pictureFor, topFindingCells } from "./map-model"; import { Matrix } from "./matrix"; -import { SectionHead } from "./primitives"; /** The small grid on the Overview; a cell opens the Map with that cell selected. */ export function OverviewMap({ repo }: { repo: RepoBundle }) { @@ -18,21 +17,18 @@ export function OverviewMap({ repo }: { repo: RepoBundle }) { const flagged = useMemo(() => new Set(topFindingCells(repo).keys()), [repo]); return (
    - - Open map - - } - /> +
    +

    Which module uses which

    + + Open map + +
    @@ -67,7 +63,7 @@ export function OverviewMap({ repo }: { repo: RepoBundle }) { )}

    - Hover or focus a cell. Rows use columns. Click to open it on the Map. + Rows use columns. Click a cell to open it on the Map.

    0} />
    diff --git a/web/src/components/cx/site-header.tsx b/web/src/components/cx/site-header.tsx index a3b5acd5..fc8e08fd 100644 --- a/web/src/components/cx/site-header.tsx +++ b/web/src/components/cx/site-header.tsx @@ -1,7 +1,6 @@ import type { ReactNode } from "react"; import { Link } from "react-router"; import { repoPath } from "../../cx/address"; -import { STATUS } from "../../cx/meta"; import type { RepoSummary } from "../../cx/types"; import { loadRepoSummaries } from "../../data/repo"; import { FOCUS, cn } from "./cn"; @@ -12,7 +11,7 @@ const shortName = (name: string) => name.slice(name.lastIndexOf("/") + 1); /** * The top bar: logo and one button per real repository in the order of - * `bundles/index.json`. Synthetic bundles are linked from the landing page only. + * `bundles/index.json`. Synthetic bundles are reached by their address only. */ export function SiteHeader({ current }: { current?: string }) { const summaries = useLoaded(() => loadRepoSummaries(), "summaries"); @@ -53,26 +52,18 @@ export function SiteHeader({ current }: { current?: string }) { ))} -
    - - pipeline v1 · offline, deterministic -
    ); } -/** The bottom line of every page: what the numbers rest on, and the project credit. */ -export function SiteFooter({ children }: { children: ReactNode }) { +/** The bottom line of every page: what the numbers rest on, if given, and the project credit. */ +export function SiteFooter({ children }: { children?: ReactNode }) { return (
    -

    {children}

    -

    CodeXray · CHECK24 × hackaTUM

    + {children &&

    {children}

    } +

    CodeXray · CHECK24 × hackaTUM

    ); @@ -86,7 +77,7 @@ export function SitePage({ children, current }: { children: ReactNode; current?:
    {children}
    - Deterministic numbers, cited AI. Same commit, same report. +
    ); } diff --git a/web/src/cx/address.ts b/web/src/cx/address.ts index 875c740a..abb0510a 100644 --- a/web/src/cx/address.ts +++ b/web/src/cx/address.ts @@ -1,7 +1,7 @@ // Every view has an address (spec.md §10.3). These build the paths after the "#" and read // and write the Map's search parameters, so reloading or sharing a link restores the view. -export type RepoTab = "decisions" | "findings" | "map" | "change" | "trust" | "size"; +export type RepoTab = "journeys" | "decisions" | "findings" | "map" | "change" | "trust" | "size"; const seg = (s: string) => encodeURIComponent(s); diff --git a/web/src/cx/meta.ts b/web/src/cx/meta.ts index 0c032109..bbe4c3a4 100644 --- a/web/src/cx/meta.ts +++ b/web/src/cx/meta.ts @@ -12,26 +12,36 @@ import type { // Okabe-Ito categorical palette (colour-blind safe), spec §10.5 export const STATUS: Record = { - broken: { label: "Broken", color: "#D55E00", order: 0, hint: "Conformance below 90%" }, + broken: { + label: "Broken", + color: "#D55E00", + order: 0, + hint: "Kept in less than 90% of the code it covers", + }, slipping: { - label: "Slipping", + label: "Getting worse", color: "#E69F00", order: 1, - hint: "Fell by more than 1 point over the last two snapshots", + hint: "Kept less often than before: down more than 1 point over the last two snapshots", }, spreading: { - label: "Spreading", + label: "Reaching more modules", color: "#CC79A7", order: 2, - hint: "The number of modules the rule covers is growing", + hint: "The rule now covers more modules than before, so there is more code that has to keep it", }, mostly_holding: { label: "Mostly holding", color: "#56B4E9", order: 3, - hint: "90% to 98%, stable", + hint: "Kept in 90% to 98% of the code it covers, and stable", + }, + holding: { + label: "Holding", + color: "#009E73", + order: 4, + hint: "Kept in at least 98% of the code it covers", }, - holding: { label: "Holding", color: "#009E73", order: 4, hint: "Conformance at least 98%" }, }; export const STATUS_ORDER: Status[] = [ @@ -143,7 +153,43 @@ export const NO_FIX_TEXT = "No improvement proposed."; /** Said next to the simulated batch's loop counts, which are not the yardstick's pairs. */ export const BATCH_LOOPS_NOTE = - "Loop counts here are the simulation's own, on its set of module links, so they differ from the two-way pairs yardstick."; + "Loop counts here are the simulation's own, on its set of module links, so they differ from the two-way dependencies count."; + +/** + * A readable label for each stored fact key. The value is shown after it with the fact's + * stored unit. A key missing here is shown with its underscores as spaces. + */ +export const FACT_LABEL: Record = { + violating_links: "Links against the decision", + reverse_links: "Links in the opposite direction", + files: "Files holding those links", + weak_links: "Links in the weak direction", + strong_links: "Links in the strong direction", + symbol: "Declaration it imports", + feature_links: "Links into the feature module", + instability: "Instability (outgoing links ÷ all links)", + user_modules: "Modules that use it", + user_modules_in_area: "Modules in its area that use it", + other_modules_in_area: "Other modules in its area", + modules_total: "Modules with production code", + direct_users: "Used directly by", + dependencies: "Depends on", + changes_12m: "Changed in the last 12 months", + changes_a: "Changes to the first file", + changes_b: "Changes to the second file", + shared_commits: "Commits that change both", + shared_share: "Share of changes made together", + lines: "Length", + branches: "Branches", + score: "Score (changes × branches)", + top_functions: "Functions with the most branches", + longest_functions: "Longest functions", + reach: "Reach (files using it directly or at one remove)", + pressure: "Changes to the affected code in 12 months", +}; + +/** Fact keys whose value is a share between 0 and 1, shown as a percentage. */ +export const FACT_SHARE: ReadonlySet = new Set(["shared_share"]); export const fmt = (n: number) => n.toLocaleString("en-US"); export const pct = (n: number, d = 1) => `${(n * 100).toFixed(d)}%`; diff --git a/web/src/data/journeys.ts b/web/src/data/journeys.ts new file mode 100644 index 00000000..9ed80a78 --- /dev/null +++ b/web/src/data/journeys.ts @@ -0,0 +1,62 @@ +// Journeys: one user action traced through the main modules, step by step. They sit next to a +// repository's bundle as `journeys.json`; a repository without that file has no journeys and +// the screens leave the Journeys tab out. +import { bundlesRoot } from "./bundle"; +import { loadRepoList } from "./repo"; + +export type JourneyVia = { kind: "call" | "queue" | "ws" | "find"; label: string } | null; + +export interface JourneyStop { + /** Index into the bundle's lanes. */ + lane: number; + module: string; + /** A short verb phrase shown on the node. */ + label: string; + /** One sentence for a newcomer. */ + caption: string; + /** "path:line" of the code that runs at this stop. */ + file: string; + method: string; + /** How the request reached this stop; null on the first stop. */ + via: JourneyVia; + /** Set when this step is a ranked finding. */ + findingRank: number | null; + payload: { type: string; definedIn: string; fields: { key: string; value: string }[] }; +} + +export interface Journey { + id: string; + name: string; + summary: string; + stops: JourneyStop[]; +} + +export interface JourneyBundle { + lanes: string[]; + journeys: Journey[]; +} + +const loaded = new Map>(); + +/** The repository's journeys, or null when its bundle folder holds none. */ +export function loadJourneys(repoId: string): Promise { + const hit = loaded.get(repoId); + if (hit) return hit; + const loading = (async () => { + const entry = (await loadRepoList()).find((b) => b.repo_id === repoId); + if (!entry) return null; + const folder = entry.path.includes("/") + ? entry.path.slice(0, entry.path.lastIndexOf("/") + 1) + : ""; + try { + const res = await fetch(`${bundlesRoot()}${folder}journeys.json`); + if (!res.ok) return null; + const data = (await res.json()) as JourneyBundle; + return Array.isArray(data.journeys) && data.journeys.length > 0 ? data : null; + } catch { + return null; + } + })(); + loaded.set(repoId, loading); + return loading; +} diff --git a/web/src/routes/Change.tsx b/web/src/routes/Change.tsx index f7fc4b37..09a19b7e 100644 --- a/web/src/routes/Change.tsx +++ b/web/src/routes/Change.tsx @@ -1,31 +1,44 @@ import { ArrowRight } from "lucide-react"; import { Link } from "react-router"; -import { AiBadge, ComputedMark, NotMeasured } from "../components/cx/badges"; +import { AiBadge, ComputedMark } from "../components/cx/badges"; import { FOCUS, cn } from "../components/cx/cn"; -import { Eyebrow, Panel, SectionHead } from "../components/cx/primitives"; +import { Panel, SectionHead } from "../components/cx/primitives"; import { SeriesChart } from "../components/cx/series-chart"; import { useTitle } from "../components/cx/use-page"; import { findingPath } from "../cx/address"; import { fmt, hostLink, pct } from "../cx/meta"; import type { RepoBundle, StructuralEvent } from "../cx/types"; import { Drift } from "./change/drift"; +import { Impact } from "./change/impact"; import { LabelChip, StructuralEvents, labelCounts } from "./change/events"; import { ShowMoreButton, useShowMore } from "./decisions/show-more"; import { useRepo } from "./RepoLayout"; /** Hotspots and new links shown before "Show all". */ -const FIRST = 8; +const FIRST = 5; const pathLinkCls = cn("rounded-sm hover:underline decoration-border underline-offset-2", FOCUS); -/** The Change screen: before and after the comparison date (spec.md §12), descriptive only. */ +/** "March 2025" for "2025-03-01", read as a calendar date with no time zone. */ +function monthYear(date: string): string { + return new Date(`${date}T00:00:00Z`).toLocaleString("en-US", { + month: "long", + year: "numeric", + timeZone: "UTC", + }); +} + +/** The Before and after screen: what changed around the comparison date, descriptive only. */ export function Change() { const repo = useRepo(); - useTitle(`Change · ${repo.name}`); + useTitle(`Before and after · ${repo.name}`); return (
    - +
    + + +
    @@ -39,6 +52,7 @@ export function Change() { function Header({ repo }: { repo: RepoBundle }) { const series = repo.aiShareSeries; + const compared = repo.sponsorDate ?? repo.beforeDate; return (
    - Change

    - What changed in the structure before and after the comparison date, and whether it was - planned. + Before and after {monthYear(compared)}

    -
    +

    + Did the structure get better or worse once the team started using AI coding tools? +

    +

    + This page shows what changed between the two dates. It does not blame any change on AI: + only commits with an explicit AI marker are counted as AI, so that share is a lower bound, + and everything else is no AI signal. +

    +
    Comparison date:
    -
    - {repo.sponsorDate ?? } -
    -
    -
    -
    Detected adoption date:
    -
    - {repo.adoptionDate ?? ( - not detected in this run - )} -
    +
    {compared}
    + {repo.adoptionDate && ( +
    +
    Detected adoption date:
    +
    {repo.adoptionDate}
    +
    + )} {repo.adoptionEvidence && (
    Adoption evidence:
    @@ -93,9 +109,6 @@ function Header({ repo }: { repo: RepoBundle }) { domain={[0, Math.max(...series.map((p) => p.value), 0.1)]} label="Share of commits with an explicit AI marker" /> -

    - Markers are a lower bound: a commit without one has no AI signal, nothing more. -

    )}
    @@ -111,46 +124,16 @@ function missingAiData(repo: RepoBundle): string | null { return `This report holds ${gaps.join(" and ")}.`; } -function Note({ repo }: { repo: RepoBundle }) { - const missing = missingAiData(repo); - return ( - - ); -} - function Hotspots({ repo }: { repo: RepoBundle }) { const { shown, all, toggle } = useShowMore(repo.hotspots, FIRST); const maxZ = Math.max(...repo.hotspots.map((h) => h.z), 1); return (
    - -
    -

    - Rule: z = (recent − prior) ÷ √(prior + 1) of at least 3, with at least 2 changes per month - recently; new files and restructuring commits are left out. -

    -

    - recent: changes in the last 3 months.{" "} - prior: expected changes in 3 months, - from the months before. The bar is z. -

    -
    + +

    + Files that changed far more often in the last 3 months than their own history predicts. New + files and restructuring commits are left out. +

    {repo.hotspots.length === 0 ? (

    No file met the rule in this run.

    ) : ( @@ -174,10 +157,10 @@ function Hotspots({ repo }: { repo: RepoBundle }) { )} - prior {h.prior.toFixed(2)}{" "} - {" "} - recent{" "} - {fmt(h.recent)} + {fmt(h.recent)}{" "} + + changes, {h.prior.toFixed(1)} expected +
    {dir && ( @@ -192,15 +175,16 @@ function Hotspots({ repo }: { repo: RepoBundle }) { {h.moduleName ?? "no module"} - + - - z {h.z.toFixed(1)} -
  • ); @@ -240,16 +224,12 @@ function NewLinks({ repo }: { repo: RepoBundle }) { }; return (
    - +

    {fmt(added.length)} new {added.length === 1 ? "link" : "links"} between modules:{" "} - {fmt(c.planned)} planned, {fmt(c.none)} with no stated intent. Each one's evidence is - listed under structural events. + {fmt(c.planned)} planned, {fmt(c.none)} unexplained. Each one's evidence is listed under + "Show every change" above.

    {plan && (

    @@ -306,6 +286,7 @@ function NewLinks({ repo }: { repo: RepoBundle }) { function AiRisk({ repo }: { repo: RepoBundle }) { const sponsor = repo.sponsorDate ?? repo.beforeDate; + const missing = missingAiData(repo); return (

    @@ -349,16 +329,12 @@ function AiRisk({ repo }: { repo: RepoBundle }) { )}
    - } - /> + } />

    - Each evidence line is credited to the last change that touched it, which is not always the - change that first wrote it. The marked share counts explicit AI markers only, so it is a - lower bound. + For each top finding: how much of the code behind it changed after {sponsor}, and how much + of that carries an explicit AI marker. Each line counts toward the last change that + touched it. Only explicit markers count as AI, so the AI share is a lower bound. + {missing && ` ${missing}`}

    {repo.findings.length === 0 ? (

    No finding was ranked in this run.

    diff --git a/web/src/routes/Decisions.tsx b/web/src/routes/Decisions.tsx index 59ae66c8..c45f03e5 100644 --- a/web/src/routes/Decisions.tsx +++ b/web/src/routes/Decisions.tsx @@ -1,9 +1,9 @@ -import { ArrowRight } from "lucide-react"; +import { ArrowLeft, ChevronRight } from "lucide-react"; +import type { ReactNode } from "react"; import { Link } from "react-router"; -import { AiBadge, ComputedMark, NotMeasured } from "../components/cx/badges"; +import { AiBadge, ComputedMark } from "../components/cx/badges"; import { FOCUS, cn } from "../components/cx/cn"; -import { FindingRow } from "../components/cx/finding-row"; -import { Chip, Eyebrow, SectionHead, StatusDot, StatusPill } from "../components/cx/primitives"; +import { Eyebrow, StatusDot, StatusPill } from "../components/cx/primitives"; import { Sparkline, markIndex } from "../components/cx/sparkline"; import { useTitle } from "../components/cx/use-page"; import { findingPath, repoPath } from "../cx/address"; @@ -14,130 +14,97 @@ import { useRepo } from "./RepoLayout"; /** Written, not checkable statements shown before "Show all". */ const WRITTEN_SHOWN = 10; -/** Ranked findings shown below the decisions. */ -const FINDINGS_SHOWN = 5; +/** Width of a decision's trend line, in CSS pixels. */ +const TREND_W = 160; const byText = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0); -const linkCls = cn( - "inline-flex items-center gap-1 rounded-sm text-foreground hover:underline", - FOCUS, -); const sourceLinkCls = cn( "rounded-sm text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground", FOCUS, ); +const summaryBase = cn( + "inline-flex cursor-pointer list-none items-center gap-1 rounded-sm text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden", + FOCUS, +); -/** The Decisions screen (spec.md §10.2 screen 1): every rule, then what to fix first. */ +/** The decisions page (spec.md §10.2 screen 1): every checked decision as one compact row. */ export function Decisions() { const repo = useRepo(); - useTitle(`Decisions · ${repo.name}`); + useTitle(`Decisions checked · ${repo.name}`); const compareDate = repo.sponsorDate ?? repo.beforeDate; const list = [...repo.decisions].sort( (a, b) => STATUS[a.status].order - STATUS[b.status].order || byText(a.id, b.id), ); return ( -
    +
    - - Decisions · {fmt(list.length)} checked - {repo.written.length > 0 && ` · ${fmt(repo.written.length)} not checkable`} - -

    - Each rule is one of four shapes, checked against every link in the code. -

    + + Back to the report + + Decisions · {fmt(list.length)} checked +

    Decisions checked

    - Rules come from what the project enforces in its build, what its docs say, and habits the - code measurably keeps. Conformance is the share of links where the rule could apply and is - kept. + Decisions come from what the project enforces in its build and tests, what its documents + say, and habits the code measurably keeps; conformance is the share of links where a + decision could apply and is kept.

    - - {list.length === 0 ? (

    No decision could be checked in this run.

    ) : ( -
      - {list.map((d) => ( - - ))} -
    - )} - -
    - 0 && ( - - All {fmt(repo.findings.length)} findings{" "} - - - ) - } - /> - {repo.findings.length === 0 ? ( -

    No finding was ranked in this run.

    - ) : ( -
      - {repo.findings.slice(0, FINDINGS_SHOWN).map((f) => ( - +
      + +
        + {list.map((d) => ( + ))} -
    - )} -
    + +
    + )}
    ); } +/** The statuses with their counts on one line; each status's test is in its tooltip. */ function StatusLegend({ decisions, compareDate }: { decisions: Decision[]; compareDate: string }) { const counts = statusCounts(decisions); return ( -
    -

    - Legend -

    -
      - {STATUS_ORDER.map((s) => ( -
    • - - - - {STATUS[s].label}{" "} - {counts[s]} - - {STATUS[s].hint} - -
    • - ))} -
    -

    - Statuses are checked in this order and the first match wins. Each trend line runs over the - stored snapshots; the dashed line marks{" "} - {compareDate}. -

    -
    +
      + {STATUS_ORDER.map((s) => ( +
    • + + {STATUS[s].label} + {counts[s]} +
    • + ))} +
    • dashed line on a trend: {compareDate}
    • +
    ); } -function Provenance({ d }: { d: Pick }) { - if (d.proposedBy === "ai") { - return ( - - - {d.reviewed ? "AI-proposed · reviewed" : "AI-proposed · unreviewed"} - - - - ); - } - return {d.proposedBy === "computed" ? "computed" : "written by hand"}; +/** Who wrote the decision's statement: the AI badge, the computed mark, or "by hand". */ +function Origin({ d }: { d: Pick }) { + if (d.proposedBy === "ai") return ; + if (d.proposedBy === "computed") return ; + return ( + + by hand + + ); } /** The source as "path#Ls-e", linked to the host at the end commit when there is one. */ @@ -164,7 +131,36 @@ function SourceRef({ ); } -function DecisionCard({ +function Trend({ d, compareDate }: { d: Decision; compareDate: string }) { + const values = d.series.map((s) => s.conformance); + const dates = d.series.map((s) => s.date); + if (values.length === 0) return null; + if (values.length === 1) { + return ( +

    one check, at {dates[0]}

    + ); + } + return ( +
    + +
    + {dates[0]!.slice(0, 7)} + {dates.at(-1)!.slice(0, 7)} +
    +
    + ); +} + +function RuleRow({ repo, d, compareDate, @@ -174,161 +170,142 @@ function DecisionCard({ compareDate: string; }) { const findings = repo.findings.filter((f) => f.decisionId === d.id); - const values = d.series.map((s) => s.conformance); - const dates = d.series.map((s) => s.date); - const mark = markIndex(dates, compareDate); - const width = 240; - // Where the sparkline draws the dashed mark, as a share of its width. - const markAt = - mark !== undefined && values.length > 1 - ? (2 + (mark * (width - 4)) / (values.length - 1)) / width - : null; return ( -
  • -
    -
    - - {SHAPE[d.shape]} - {SOURCE[d.source.kind]} - -
    -

    +
  • +
    + +
    +
    +

    {d.statement} -

  • -

    - {d.id} · source{" "} - {" "} - · authority{" "} - {d.authority === null ? ( - - ) : ( - {d.authority.toFixed(2)} - )} +

    - {d.argList.length > 0 && ( -
    - {d.argList.map(({ key, values: v }) => ( -
    -
    {key} =
    -
    {v.join(", ")}
    -
    - ))} -
    - )} -
    - {( - [ - ["exceptions", fmt(d.exceptions)], - ["opportunities", fmt(d.opportunities)], - ["per 1,000 lines", d.perKloc.toFixed(2)], - ["modules covered", fmt(d.modulesCovered)], - ["allowed exceptions", fmt(d.allowed)], - ] as const - ).map(([k, v]) => ( -
    -
    {k}
    -
    {v}
    -
    - ))} -
    {findings.length > 0 && ( -
      +
        {findings.map((f) => ( -
      • +
      • #{f.rank} - {f.title} + {f.title}
      • ))}
      )} +
    -
    -
    -
    - Conformance - - {pct(d.conformance)} - -
    -

    +

    +
    + + {pct(d.conformance)} + + {fmt(d.exceptions)} of {fmt(d.opportunities)} links break it -

    +
    +
    +
    +
    - {values.length > 1 ? ( -
    - -
    - {dates[0]!.slice(0, 7)} - {markAt !== null && markAt > 0.3 && markAt < 0.7 && ( - - {compareDate.slice(0, 7)} - - )} - {dates.at(-1)!.slice(0, 7)} -
    -
    - ) : ( -

    - {values.length === 1 ? `one check only, at ${dates[0]}` : "no stored checks"} -

    - )}
  • ); } +/** The technical detail of one decision, closed until asked for. */ +function RuleDetails({ repo, d }: { repo: RepoBundle; d: Decision }) { + const rows: [string, ReactNode][] = [ + ["shape", SHAPE[d.shape]], + ...d.argList.map(({ key, values }): [string, ReactNode] => [key, values.join(", ")]), + ["id", d.id], + [ + "source", + <> + {SOURCE[d.source.kind]} + {d.source.path && ( + <> + {" · "} + + + )} + , + ], + ]; + if (d.proposedBy === "ai") { + rows.push(["proposed", d.reviewed ? "by an AI model, reviewed" : "by an AI model, not reviewed"]); + } + if (d.authority !== null) rows.push(["authority", d.authority.toFixed(2)]); + rows.push( + ["opportunities", fmt(d.opportunities)], + ["exceptions", fmt(d.exceptions)], + ["per 1,000 lines", d.perKloc.toFixed(2)], + ["modules covered", fmt(d.modulesCovered)], + ["allowed exceptions", fmt(d.allowed)], + ); + return ( +
    + + + Details + +
    + {rows.map(([k, v]) => ( +
    +
    {k}
    +
    {v}
    +
    + ))} +
    +
    + ); +} + function Written({ repo }: { repo: RepoBundle }) { const { shown, all, toggle } = useShowMore(repo.written, WRITTEN_SHOWN); - if (repo.written.length === 0) return null; + const n = repo.written.length; + if (n === 0) return null; return ( -
    - -
      - {shown.map((w) => ( - - ))} -
    - -
    +
    + + + {fmt(n)} written {n === 1 ? "decision cannot" : "decisions cannot"} be checked by machine + +
    +
      + {shown.map((w) => ( + + ))} +
    + +
    +
    ); } -function WrittenCard({ repo, w }: { repo: RepoBundle; w: WrittenDecision }) { +function WrittenRow({ repo, w }: { repo: RepoBundle; w: WrittenDecision }) { return ( -
  • -

    +

  • +

    “{w.statement}” {w.proposedBy === "ai" && }

    diff --git a/web/src/routes/FindingDetail.tsx b/web/src/routes/FindingDetail.tsx index a89de30f..a04830b4 100644 --- a/web/src/routes/FindingDetail.tsx +++ b/web/src/routes/FindingDetail.tsx @@ -4,7 +4,7 @@ import { EvidencePane } from "../components/cx/code-block"; import { allFindings } from "../components/cx/finding-fix"; import { ComputedMark } from "../components/cx/badges"; import { FOCUS, cn } from "../components/cx/cn"; -import { Chip, Eyebrow, Prose } from "../components/cx/primitives"; +import { Chip, Prose } from "../components/cx/primitives"; import { useTitle } from "../components/cx/use-page"; import { findingPath, repoPath } from "../cx/address"; import { TYPE, fmt } from "../cx/meta"; @@ -13,7 +13,7 @@ import { ShowMoreButton, useShowMore } from "./decisions/show-more"; import { Reading } from "./finding/Reading"; import { CloseupPanel, DecisionCard, FactsPanel, PriorityPanel, TrendPanel } from "./finding/Rail"; import { NotFound } from "./NotFound"; -import { useRepo } from "./RepoLayout"; +import { useJourneys, useRepo } from "./RepoLayout"; /** One finding of one repository, found by its slug among the top 10 and the rest. */ export function FindingDetail() { @@ -37,6 +37,11 @@ function FindingPage({ repo, f }: { repo: RepoBundle; f: Finding }) { const byId = new Map(all.map((x) => [x.id, x])); const related = f.related.map((id) => byId.get(id)).filter((x): x is Finding => Boolean(x)); const inTop = repo.findings.includes(f); + const journeys = useJourneys(); + const seenIn = (journeys?.journeys ?? []).flatMap((journey) => { + const stop = journey.stops.findIndex((s) => s.findingRank === f.rank); + return stop >= 0 ? [{ journey, stop }] : []; + }); return (
    @@ -75,49 +80,44 @@ function FindingPage({ repo, f }: { repo: RepoBundle; f: Finding }) { -
    -
    - {String(f.rank).padStart(2, "0")} -
    -
    -
    - {TYPE[f.type].label} - - · - - {TYPE[f.type].group} - - rank {f.rank} of {all.length} - - {!inTop && below the top {repo.findings.length}} -
    -

    - {f.title} -

    +
    +

    + #{f.rank} + of {fmt(all.length)} + / + {TYPE[f.type].label} + {!inTop && below the top {repo.findings.length}} +

    +

    + {f.title} +

    + {f.judgement && (
    -
    -

    - - Why it matters + )} + {seenIn.length > 0 && ( +

    + Seen in{" "} + {seenIn.map((x, i) => ( + + {i > 0 && ", "} + + the journey "{x.journey.name}", stop {x.stop + 1} + - -

    -

    {TYPE[f.type].why}

    -
    -
    + ))} +

    + )}
    + @@ -150,7 +150,6 @@ function FindingPage({ repo, f }: { repo: RepoBundle; f: Finding }) { - {decision && }
    @@ -185,10 +184,7 @@ function Related({ repo, related }: { repo: RepoBundle; related: Finding[] }) { > #{r.rank} - - {TYPE[r.type].label} - {" "} - {r.title} + {TYPE[r.type].label}. {r.title}
  • diff --git a/web/src/routes/Findings.tsx b/web/src/routes/Findings.tsx index 192e5868..98033b29 100644 --- a/web/src/routes/Findings.tsx +++ b/web/src/routes/Findings.tsx @@ -1,13 +1,12 @@ -import { EyeOff } from "lucide-react"; -import { useSearchParams } from "react-router"; -import { ComputedMark } from "../components/cx/badges"; +import { ArrowRight, ChevronRight, EyeOff } from "lucide-react"; +import { Link, useSearchParams } from "react-router"; import { FOCUS, cn } from "../components/cx/cn"; -import { weightOf } from "../components/cx/finding-fix"; import { FindingCompactRow, FindingListRow } from "../components/cx/finding-list-row"; -import { Eyebrow, Panel, SectionHead } from "../components/cx/primitives"; +import { Eyebrow, SectionHead } from "../components/cx/primitives"; import { useTitle } from "../components/cx/use-page"; -import { BATCH_LOOPS_NOTE, TYPE, fmt } from "../cx/meta"; -import type { Batch, Finding, RepoBundle } from "../cx/types"; +import { repoPath } from "../cx/address"; +import { BATCH_LOOPS_NOTE, fmt } from "../cx/meta"; +import type { Batch, Finding } from "../cx/types"; import { useRepo } from "./RepoLayout"; /** Findings below the top 10 shown before "Show all". */ @@ -16,6 +15,7 @@ const SUPPORTING_SHOWN = 25; const HIDE_PARAM = "hide"; const HIDE_VALUE = "legitimate-wiring"; const ALL_PARAM = "all"; +const BELOW_PARAM = "below"; const isLegitimate = (f: Finding) => f.judgement?.verdict === "legitimate_wiring"; @@ -31,6 +31,7 @@ export function Findings() { const [params, setParams] = useSearchParams(); const hideLegit = params.get(HIDE_PARAM) === HIDE_VALUE; const showAll = params.get(ALL_PARAM) === "1"; + const showBelow = showAll || params.get(BELOW_PARAM) === "1"; const compareDate = repo.sponsorDate ?? repo.beforeDate; const setParam = (key: string, value: string | null) => { @@ -45,35 +46,20 @@ export function Findings() { const restAll = hideLegit ? repo.supporting.filter((f) => !isLegitimate(f)) : repo.supporting; const rest = showAll ? restAll : restAll.slice(0, SUPPORTING_SHOWN); const legitCount = [...repo.findings, ...repo.supporting].filter(isLegitimate).length; - const groups = Array.from(new Set(repo.findings.map((f) => TYPE[f.type].group))); + const rankedCount = repo.findings.length + repo.supporting.length; return (
    -
    -
    - Findings · {repo.findings.length} ranked -

    - One list, ranked by what pays back first. -

    -

    - The order is arithmetic on stored numbers, explained below the list. No AI model changes - the order. Each finding carries its own evidence and caveats. -

    -
    - {groups.length > 0 && ( -
      - {groups.map((g) => ( -
    • - {g}{" "} - - {repo.findings.filter((f) => TYPE[f.type].group === g).length} - -
    • - ))} -
    - )} +
    +

    Findings

    +

    + {rankedCount === 1 ? "1 finding is ranked" : `${fmt(rankedCount)} findings are ranked`}, + in an order computed from stored numbers with no AI model. +

    + +
    @@ -119,10 +105,18 @@ export function Findings() { )}
    -
    - - -
    +

    + + How the rank is computed, under Approach + + +

    {repo.supporting.length > 0 && (
    @@ -131,29 +125,64 @@ export function Findings() { title="Ranked below the top 10" id="ranked-below" aside={ - - {rest.length} of {restAll.length} shown - + showBelow ? ( + + {fmt(rest.length)} of {fmt(restAll.length)} shown + + ) : undefined } /> -

    - The same ranking continues here. The top 10 is limited to a few findings per type and - per module, so some of these have a higher score than a finding above them. -

    -
      - {rest.map((f) => ( - - ))} -
    - {restAll.length > SUPPORTING_SHOWN && ( -
    + {showBelow ? ( + <> +

    + The top 10 holds at most a few findings per type and per module, so some of these + score higher than a finding above them. +

    +
      + {rest.map((f) => ( + + ))} +
    +
    + {restAll.length > SUPPORTING_SHOWN && ( + + )} + +
    + + ) : ( +
    )} @@ -163,51 +192,6 @@ export function Findings() { ); } -/** One decimal, or a dash when the weight is not stored. */ -const w = (v: number | null) => (v === null ? "–" : v.toFixed(1)); - -const LETTERS = [ - ["S", "Size"], - ["R", "Reach"], - ["P", "Change pressure"], - ["A", "Authority"], - ["ease", "Ease"], -] as const; - -function Formula({ repo }: { repo: RepoBundle }) { - return ( - -
    -

    - How the rank is computed -

    -
    -

    - impact = A × ({w(weightOf(repo, "S"))}·S + {w(weightOf(repo, "R"))}·R +{" "} - {w(weightOf(repo, "P"))}·P) -

    -

    priority = impact × ease, rounded to 2 places

    -

    order: priority, then finding id

    -
    -
    -
    -
    - {LETTERS.map(([k, label]) => ( -
    -
    {k}
    -
    {label}
    -
    - ))} -
    -

    - The weights are stored with the run; they are a judgement, not a standard. The top 10 then - holds at most 3 findings of one type and 2 from one module. -

    -
    -
    - ); -} - function BatchStrip({ batch }: { batch: Batch | null }) { return (
    @@ -219,25 +203,25 @@ function BatchStrip({ batch }: { batch: Batch | null }) {
    {( [ - ["loops", `${fmt(batch.loopsBefore)} → ${fmt(batch.loopsAfter)}`], - ["links cut", fmt(batch.linksRemoved)], - ["links added", fmt(batch.linksAdded)], - ["applied", fmt(batch.fixesApplied)], - ["skipped", fmt(batch.fixesSkipped)], + ["loops", `${fmt(batch.loopsBefore)} → ${fmt(batch.loopsAfter)}`, BATCH_LOOPS_NOTE], + ["links cut", fmt(batch.linksRemoved), undefined], + ["links added", fmt(batch.linksAdded), undefined], + ["applied", fmt(batch.fixesApplied), undefined], + ["skipped", fmt(batch.fixesSkipped), undefined], + ...(batch.newExceptions.length > 0 + ? ([["new exceptions", fmt(batch.newExceptions.length), undefined]] as const) + : []), ] as const - ).map(([k, v]) => ( -
    + ).map(([k, v, hint]) => ( +
    {k}
    {v}
    ))}

    - Every cheap-loop fix whose own simulation succeeded with no new exception, applied - together on a copy of the map. Nothing is applied to the code. - {batch.newExceptions.length > 0 && - ` The batch creates ${fmt(batch.newExceptions.length)} new ${batch.newExceptions.length === 1 ? "exception" : "exceptions"}.`}{" "} - {BATCH_LOOPS_NOTE} + Every cheap-loop fix that simulated cleanly, applied together on a copy of the map, not + to the code.

    ) : ( diff --git a/web/src/routes/Journeys.tsx b/web/src/routes/Journeys.tsx new file mode 100644 index 00000000..a222a67a --- /dev/null +++ b/web/src/routes/Journeys.tsx @@ -0,0 +1,37 @@ +import { useSearchParams } from "react-router"; +import { JourneyPlayer } from "../components/cx/journeys"; +import { useTitle } from "../components/cx/use-page"; +import { NotFound } from "./NotFound"; +import { useJourneys, useRepo } from "./RepoLayout"; + +/** Journeys: follow one user action through the code, the quickest way into a new codebase. */ +export function Journeys() { + const repo = useRepo(); + const journeys = useJourneys(); + const [params] = useSearchParams(); + const start = { + journey: params.get("j"), + stop: Math.max(0, Number(params.get("s") ?? 1) - 1 || 0), + }; + useTitle(`Journeys · ${repo.name}`); + if (!journeys) return ; + return ( +
    +
    +

    + Follow one request through the code +

    +

    + Each journey starts with something a person does in the browser and follows it through the + modules that handle it. The height of the line is the layer: a dip goes down into core + code, a rise brings the result back up. Press Play or pick any stop. +

    +
    + +

    + These journeys are a hand-traced sample for {repo.name}, not yet produced by the pipeline. + File paths are shortened to the module folder. +

    +
    + ); +} diff --git a/web/src/routes/Landing.tsx b/web/src/routes/Landing.tsx index 7f2b85b9..d328909d 100644 --- a/web/src/routes/Landing.tsx +++ b/web/src/routes/Landing.tsx @@ -1,8 +1,6 @@ import { ArrowUpRight } from "lucide-react"; import { Link } from "react-router"; -import { NotMeasured } from "../components/cx/badges"; import { FOCUS, cn } from "../components/cx/cn"; -import { Eyebrow, StatusDot } from "../components/cx/primitives"; import { SiteFooter, SiteHeader } from "../components/cx/site-header"; import { Sparkline, markIndex } from "../components/cx/sparkline"; import { useLoaded, useTitle } from "../components/cx/use-page"; @@ -11,22 +9,26 @@ import { STATUS, STATUS_ORDER, pct } from "../cx/meta"; import type { FixFirst, RepoCard, RepoSummary } from "../cx/types"; import { loadRepoCard, loadRepoFixFirst, loadRepoSummaries } from "../data/repo"; -const STEPS = [ +/** The pipeline's seven stages, split into the computed ones and those that carry AI text. */ +const COMPUTED = [ + ["Repository", "Reads the full history and records which commit last wrote each line."], + ["Parse", "Reads every file and resolves imports and calls into links between files."], + ["Model", "Groups the files into modules and stores the module map for each snapshot."], + ["Visualize", "Draws the module grid, ordered so that normal dependencies fall on one side."], [ - "Read the rules", - "Pull decisions from build checks, architecture docs and habits the code measurably keeps.", - ], - [ - "Check every link", - "Resolve imports and calls into a module graph and test each rule against it, snapshot by snapshot.", + "Analyze", + "Checks each decision against the links, snapshot by snapshot, and lists the exceptions.", ], +] as const; + +const WITH_AI = [ [ - "Rank the exceptions", - "Score by size, reach, change pressure, the rule’s authority and ease of the fix. AI reads the code only where numbers can’t decide.", + "LLM Judge", + "An AI model reads decision documents, judges the shown findings and describes modules. Its text is checked against the stored facts.", ], [ - "Replay the fix", - "Apply each proposed fix to a copy of the module map and report the loops it changes before anyone touches code.", + "Explain", + "Ranks the findings by arithmetic alone and shows the model's text beside them, marked AI.", ], ] as const; @@ -35,115 +37,108 @@ export function Landing() { const summaries = useLoaded(() => loadRepoSummaries(), "summaries"); const all = summaries.state === "ready" ? summaries.value : []; const real = all.filter((r) => !r.synthetic); - const fixtures = all.filter((r) => r.synthetic); const dates = [...new Set(real.map((r) => r.snapshotDate).filter((d): d is string => !!d))]; return (
    -
    -
    -
    - Architecture decisions · checked against the code -

    - Your team wrote down how the code should fit together.{" "} - Is it still true? -

    -

    - CodeXray measures how well a codebase keeps its own architecture decisions over - time, before and after the team adopted AI coding tools, and tells you which - exceptions to fix first. -

    +
    +
    +

    + Which architecture problems to fix first, with the code behind each +

    +

    + CodeXray checks a repository against its architecture decisions and ranks the + exceptions it finds. Each finding links to its place on the module map and to the + lines of code. +

    +
    + +
    +
    +

    + Reports +

    + {dates.length === 1 && ( +

    snapshot {dates[0]}

    + )}
    -
    -
      - {STEPS.map(([t, d], i) => ( -
    1. - - step {i + 1} - - {t} - {d} + {summaries.state === "loading" && ( +

      + Loading the list of reports… +

      + )} + {summaries.state === "failed" && ( +

      + The list of reports could not be loaded.{" "} + {summaries.why} +

      + )} + {summaries.state === "ready" && real.length === 0 && ( +

      + No report of a real repository is in bundles/index.json. +

      + )} + {real.length > 0 && ( +
        + {real.map((r) => ( +
      • +
      • ))} -
    -

    - Finding, counting and ranking are computed, with no AI model. An AI model writes - prose in three places only: reading written decisions, judging the code behind an - exception, and describing a module. Each of its sentences is checked against the - stored facts and marked AI. -

    -
    -
    -
    + + )} +
    -
    -
    -

    - Reports +
    +

    + How it works

    - {summaries.state === "ready" && ( -

    - {real.length} {real.length === 1 ? "repository" : "repositories"} - {dates.length === 1 && ` · snapshot ${dates[0]}`} -

    - )} -

    - {summaries.state === "loading" && ( -

    - Loading the list of reports… -

    - )} - {summaries.state === "failed" && ( -

    - The list of reports could not be loaded.{" "} - {summaries.why} -

    - )} - {summaries.state === "ready" && real.length === 0 && ( -

    - No report of a real repository is in bundles/index.json. -

    - )} - {real.length > 0 && ( -
      - {real.map((r, i) => ( -
    • - -
    • - ))} -
    - )} - {fixtures.length > 0 && ( -

    - Synthetic fixtures, for testing the screens:{" "} - {fixtures.map((r, i) => ( - - {i > 0 && " · "} - - {r.label} - - - ))} -

    - )} -
    +
    + + +
    +
    + - Deterministic numbers, cited AI. Same commit, same report. + + + ); +} + +function StageGroup({ + title, + stages, + from, +}: { + title: string; + stages: readonly (readonly [string, string])[]; + from: number; +}) { + return ( +
    +

    {title}

    +
      2 ? "lg:grid-cols-5" : "lg:grid-cols-2", + )} + > + {stages.map(([name, text], i) => ( +
    1. + {from + i} + {name} + + {text} + +
    2. + ))} +
    ); } @@ -158,9 +153,10 @@ function RepoCardView({ id, summary }: { id: string; summary: RepoSummary }) { const c = card.state === "ready" ? card.value : null; const counts = summary.statusCounts; const present = STATUS_ORDER.filter((s) => counts[s] > 0); + const checked = present.reduce((n, s) => n + counts[s], 0); const grain = c?.againstGrainShare ?? null; - const rising = grain && grain.now !== null && grain.before !== null && grain.now > grain.before; - const falling = grain && grain.now !== null && grain.before !== null && grain.now < grain.before; + const now = grain?.now ?? null; + const before = grain?.before ?? null; const compareDate = c ? (c.sponsorDate ?? c.beforeDate) : null; const langs = c ? c.languages.length > 3 @@ -172,13 +168,13 @@ function RepoCardView({ id, summary }: { id: string; summary: RepoSummary }) {
    -
    - {summary.name} +
    + {summary.name} {[langs, summary.snapshotDate && `snapshot ${summary.snapshotDate}`] .filter(Boolean) @@ -191,86 +187,74 @@ function RepoCardView({ id, summary }: { id: string; summary: RepoSummary }) {
    -
    -
    - - links against the grain - - {card.state === "failed" ? ( - could not be loaded - ) : !grain ? ( - … - ) : grain.now === null ? ( - - ) : ( - {pct(grain.now)} - )} - {grain && grain.before !== null && grain.now !== null && ( - - {rising ? "▲ " : falling ? "▼ " : ""} - {rising || falling ? "from" : "unchanged from"} {pct(grain.before)} - {compareDate && ` at ${compareDate.slice(0, 7)}`} - - )} -
    - {grain && ( - p.value)} - mark={markIndex( - grain.series.map((p) => p.date), - compareDate, - )} - width={130} - height={44} - area - color="var(--accent)" - label={`${summary.name}: against-the-grain share at each snapshot`} - /> - )} -
    - -
      - {present.flatMap((s) => - Array.from({ length: counts[s] }, (_, k) => ( -
    • - -
    • - )), - )} -
    • - {present.length === 0 - ? "no decision checked" - : present.map((s) => `${counts[s]} ${STATUS[s].label.toLowerCase()}`).join(" · ")} -
    • -
    - -
    - fix first - +
    + Fix first + {top.state === "ready" ? ( (top.value?.title ?? "No finding was ranked in this run.") ) : top.state === "failed" ? ( - could not be loaded + could not be loaded ) : ( - Loading… + Loading… )}
    + +

    + {checked === 0 + ? "No decision checked." + : `${checked} ${checked === 1 ? "decision" : "decisions"} checked: ${present + .map((s) => `${counts[s]} ${STATUS[s].label.toLowerCase()}`) + .join(", ")}`} +

    + + {card.state === "failed" && ( +

    + The rest of this card could not be loaded. +

    + )} + {grain && now !== null && ( +
    +
    + + links against the main dependency direction + + + {pct(now)} + {before !== null && ( + + {now === before ? "unchanged from" : "from"} {pct(before)} + {compareDate && ` at ${compareDate.slice(0, 7)}`} + + )} + +
    + {grain.series.length > 1 && ( + p.value)} + mark={markIndex( + grain.series.map((p) => p.date), + compareDate, + )} + width={96} + height={28} + color="var(--muted-foreground)" + label={`${summary.name}: share of links against the main dependency direction at each snapshot`} + /> + )} +
    + )} ); } diff --git a/web/src/routes/MapPage.tsx b/web/src/routes/MapPage.tsx index 037d32cf..62646cf7 100644 --- a/web/src/routes/MapPage.tsx +++ b/web/src/routes/MapPage.tsx @@ -1,5 +1,7 @@ +import { ArrowRight } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; -import { useLocation, useNavigate } from "react-router"; +import { Link, useLocation, useNavigate } from "react-router"; +import { FOCUS, cn } from "../components/cx/cn"; import { GRID_ORDER_NOTE, GridNumbers, @@ -16,9 +18,8 @@ import { topFindingCells, } from "../components/cx/map-model"; import { type Cell, Matrix } from "../components/cx/matrix"; -import { Eyebrow } from "../components/cx/primitives"; import { useTitle } from "../components/cx/use-page"; -import { type MapState, type MapView, readMapState, withMapState } from "../cx/address"; +import { type MapState, type MapView, readMapState, repoPath, withMapState } from "../cx/address"; import { fmt } from "../cx/meta"; import { useRepo } from "./RepoLayout"; import { CellPanel } from "./map/CellPanel"; @@ -63,12 +64,17 @@ export function MapPage() { return out; }, [highlighted, index, n]); + // Modules that exist only at the before date are listed only in the Before view. + const listsBeforeOnly = !trying && view === "before"; + const pickedShown = + picked !== null && (listsBeforeOnly || repo.modules[picked]?.presentAtEnd) ? picked : null; + const selected: Cell | null = state.cell ? [index.get(state.cell[0])!, index.get(state.cell[1])!] : null; const select = (cell: Cell | null) => { if (cell && cell[0] === cell[1]) { - setPicked(picked === cell[0] ? null : cell[0]); + setPicked(pickedShown === cell[0] ? null : cell[0]); update({ cell: null }); return; } @@ -99,18 +105,26 @@ export function MapPage() { return (
    - - Map · {fmt(present)} {present === 1 ? "module" : "modules"} - {beforeOnly > 0 && ` · ${fmt(beforeOnly)} more only at the before date`} -

    - Modules ordered foundation-last. Anything below the diagonal points against the grain. + Which module uses which

    - Each row uses the columns it has links into. Switch between the code at the before date, - now, and now with the simulated fix batch; the layout stays the same and only the colours - change. + Every square is one of the {fmt(present)} modules using another. Above the diagonal, blue + squares point the normal way, from features down to the shared code they build on. Below + it, orange squares point backwards. Click a square to see the code behind it. + {listsBeforeOnly && + beforeOnly > 0 && + ` ${fmt(beforeOnly)} more ${beforeOnly === 1 ? "module" : "modules"} existed only at the before date.`}

    + + Lines of code by module and file +
    {highlighted && ( @@ -162,7 +176,7 @@ export function MapPage() { changeSource={changeSource} selected={selected} onSelect={select} - picked={picked} + picked={pickedShown} label={gridLabel} footer={ select(null)} /> ) : ( - + )}
    diff --git a/web/src/routes/Overview.tsx b/web/src/routes/Overview.tsx index 782f3ade..4b394927 100644 --- a/web/src/routes/Overview.tsx +++ b/web/src/routes/Overview.tsx @@ -1,23 +1,20 @@ import { ArrowRight } from "lucide-react"; import { Fragment, type ReactNode } from "react"; import { Link } from "react-router"; -import { ComputedMark, NotMeasured } from "../components/cx/badges"; +import { JourneyPreview } from "../components/cx/journeys"; import { FOCUS, cn } from "../components/cx/cn"; -import { FindingRow } from "../components/cx/finding-row"; -import { Eyebrow, Panel, SectionHead, StatusDot, StatusPill } from "../components/cx/primitives"; -import { Sparkline, markIndex } from "../components/cx/sparkline"; +import { SectionHead, StatusDot } from "../components/cx/primitives"; import { useTitle } from "../components/cx/use-page"; import { repoPath } from "../cx/address"; -import { BATCH_LOOPS_NOTE, STATUS, STATUS_ORDER, fmt, pct, statusCounts } from "../cx/meta"; -import type { Batch, RepoBundle, Status, Yardstick } from "../cx/types"; -import { Structure } from "./overview/Structure"; +import { STATUS, STATUS_ORDER, statusCounts } from "../cx/meta"; +import type { JourneyBundle } from "../data/journeys"; +import type { RepoBundle, Status } from "../cx/types"; +import { BeforeAfter } from "./overview/BeforeAfter"; +import { FixFirst } from "./overview/FixFirst"; +import { MainModules } from "./overview/Structure"; import { TrustStrip } from "./overview/TrustStrip"; -import { useRepo } from "./RepoLayout"; +import { useJourneys, useRepo } from "./RepoLayout"; -/** How many "got right" cards the overview shows before linking to all decisions. */ -const HEALTHY_SHOWN = 3; -/** How many decisions the overview lists before linking to the Decisions tab. */ -const DECISIONS_SHOWN = 8; /** The statuses that count as not holding in the verdict sentence, worst first. */ const NOT_HOLDING: Status[] = ["broken", "slipping", "spreading"]; @@ -28,45 +25,17 @@ const linkCls = cn( export function Overview() { const repo = useRepo(); + const journeys = useJourneys(); useTitle(`Overview · ${repo.name}`); const compareDate = repo.sponsorDate ?? repo.beforeDate; return (
    -
    - - -
    - -
    - - All {repo.findings.length} findings - - } - /> - {repo.findings.length === 0 ? ( -

    No finding was ranked in this run.

    - ) : ( -
      - {repo.findings.slice(0, 5).map((f) => ( - - ))} -
    - )} -
    - - - - - - - - + + + + +
    ); } @@ -124,348 +93,104 @@ export function VerdictSentence({ ); } -/** Formats a yardstick value; both values of one yardstick share the number of decimals. */ -function formatter(y: Yardstick): (v: number) => string { - if (y.unit === "share") return (v) => pct(v); - if (y.unit === "pairs" || y.unit === "links" || y.unit === "decisions") return (v) => fmt(v); - const values = [y.now, y.before].filter((v): v is number => v !== null); - const decimals = values.some((v) => v !== 0 && Math.abs(v) < 0.1) ? 3 : 2; - return (v) => v.toFixed(decimals); -} +// ---- decisions --------------------------------------------------------------------------- -function YardstickRow({ - label, - hint, - y, - compareDate, -}: { - label: string; - hint: string; - y: Yardstick; - compareDate: string; -}) { - const f = formatter(y); - const change = - y.now === null || y.before === null - ? null - : y.now > y.before - ? "up" - : y.now < y.before - ? "down" - : "same"; - const values = y.series.map((p) => p.value); +/** The status bar and its legend, from the decisions' statuses at the end snapshot. */ +function StatusBar({ counts, total }: { counts: Record; total: number }) { return ( -
    -
    -
    {label}
    -

    {hint}

    -
    -
    - p.date), - compareDate, - )} - width={84} - height={22} - color={change === "up" ? "var(--accent)" : "var(--primary)"} - label={`${label} at each snapshot, ${y.series[0]?.date ?? ""} to ${y.series.at(-1)?.date ?? ""}`} - /> - {y.now === null ? ( - - ) : ( - {f(y.now)} +
    +
    `${counts[s]} ${STATUS[s].label.toLowerCase()}`).join( + ", ", )} - {y.before === null ? ( - - no value at {compareDate.slice(0, 7)} - - ) : ( - - {change === "up" ? "▲ " : change === "down" ? "▼ " : ""} - {change === "same" ? "unchanged from" : "from"} {f(y.before)} - + > + {STATUS_ORDER.map( + (s) => + counts[s] > 0 && ( +
    + ), )} -
    +
    +
      + {STATUS_ORDER.map((s) => ( +
    • + + {STATUS[s].label} {counts[s]} +
    • + ))} +
    ); } -function VerdictBand({ repo, compareDate }: { repo: RepoBundle; compareDate: string }) { +/** The verdict and the status bar; the decisions themselves are one click away. */ +function DecisionList({ repo }: { repo: RepoBundle }) { const counts = statusCounts(repo.decisions); const total = repo.decisions.length; - const y = repo.yardsticks; - return ( -
    -
    - - Verdict · {total} {total === 1 ? "decision" : "decisions"} checked - -

    - -

    - {total > 0 && ( -
    -
    `${counts[s]} ${STATUS[s].label.toLowerCase()}`, - ).join(", ")} - > - {STATUS_ORDER.map( - (s) => - counts[s] > 0 && ( -
    - ), - )} -
    -
      - {STATUS_ORDER.map((s) => ( -
    • - - {STATUS[s].label}{" "} - {counts[s]} -
    • - ))} -
    -
    - )} -

    - {repo.adoptionDate ? ( - <> - The team adopted AI coding tools around{" "} - {repo.adoptionDate.slice(0, 7)} - .{" "} - - ) : ( - <>No adoption date of AI coding tools was detected in this run. - )} - Everything below compares the code before and after{" "} - {compareDate.slice(0, 7)}. -

    -
    - -
    - - - -
    -
    - ); -} - -// ---- decisions -------------------------------------------------------------------------- - -function DecisionList({ repo, compareDate }: { repo: RepoBundle; compareDate: string }) { - const ordered = [...repo.decisions].sort( - (a, b) => - STATUS[a.status].order - STATUS[b.status].order || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0), - ); - const shown = ordered.slice(0, DECISIONS_SHOWN); - const total = ordered.length; return (
    shown.length - ? `Decisions · ${shown.length} of ${total}, not holding first` - : "Decisions · not holding first" - } - title="Rules the code is meant to keep" + title="Decisions the code is meant to keep" id="overview-decisions" aside={ - - All {total} {total === 1 ? "decision" : "decisions"}{" "} - - + total > 0 && ( + + All {total} {total === 1 ? "decision" : "decisions"}{" "} + + + ) } /> - {total === 0 ? ( -

    No decision could be checked in this run.

    - ) : ( -
      - {shown.map((d) => { - const values = d.series.map((s) => s.conformance); - const lo = Math.min(0.75, ...values); - return ( -
    • - - - -

      - {d.statement} -

      - - s.date), - compareDate, - )} - width={72} - height={20} - color={STATUS[d.status].color} - domain={[lo, 1]} - label={`Conformance at each snapshot for ${d.id}`} - /> - {values.length < 2 && ( - - {values.length === 1 ? "one snapshot" : "no series"} - - )} - - - {pct(d.conformance)} - -
    • - ); - })} -
    - )} +

    + +

    + {total > 0 && }
    ); } -// ---- simulated fix batch ---------------------------------------------------------------- - -function BatchBand({ batch }: { batch: Batch | null }) { - return ( -
    - -
    -

    - Simulated fix batch -

    - {batch ? ( - <> -

    - Apply the {fmt(batch.fixesApplied)} simulated{" "} - {batch.fixesApplied === 1 ? "fix" : "fixes"} and module loops{" "} - {batch.loopsAfter === batch.loopsBefore - ? `stay at ${fmt(batch.loopsBefore)}` - : `go from ${fmt(batch.loopsBefore)} to ${fmt(batch.loopsAfter)}`} - . -

    -

    - Every cheap-loop fix whose own simulation succeeded with no new exception is applied - together, on a copy of the module map. Nothing is applied to the code. - {batch.fixesSkipped > 0 && - ` ${fmt(batch.fixesSkipped)} ${batch.fixesSkipped === 1 ? "fix was" : "fixes were"} left out.`} - {batch.newExceptions.length > 0 && - ` The batch creates ${fmt(batch.newExceptions.length)} new ${batch.newExceptions.length === 1 ? "exception" : "exceptions"}.`}{" "} - {BATCH_LOOPS_NOTE} -

    - - ) : ( -

    - Not simulated in this run. -

    - )} -
    - {batch && ( -
    - {( - [ - ["loops", `${fmt(batch.loopsBefore)}→${fmt(batch.loopsAfter)}`], - ["links cut", fmt(batch.linksRemoved)], - ["links added", fmt(batch.linksAdded)], - ["applied", fmt(batch.fixesApplied)], - ["skipped", fmt(batch.fixesSkipped)], - ] as const - ).map(([k, v]) => ( -
    -
    {k}
    -
    {v}
    -
    - ))} -
    - )} -
    -
    - ); -} - -// ---- healthy ---------------------------------------------------------------------------- - -function Healthy({ repo }: { repo: RepoBundle }) { - if (repo.healthy.length === 0) return null; - const shown = repo.healthy.slice(0, HEALTHY_SHOWN); +/** Understandability: the main modules, then one request followed through them. */ +function HowItFits({ repo, journeys }: { repo: RepoBundle; journeys: JourneyBundle | null }) { + const first = journeys?.journeys[0]; return ( -
    +
    shown.length && ( - - All {repo.healthy.length} holding decisions{" "} - - - ) + + Open the full map + } /> -
      - {shown.map((h) => { - const d = repo.decisions.find((x) => x.id === h.decisionId); - return ( -
    • -
      - {d && } - {d && ( - - {pct(d.conformance)} - - )} -
      -

      {d?.statement ?? h.decisionId}

      -

      - {h.evidence} -

      -
    • - ); - })} -
    + + {journeys && first && ( +
    +
    +

    How they work together: {first.name.toLowerCase()}

    + + Play the {journeys.journeys.length} journeys{" "} + + +
    + + + +
    + )}
    ); } diff --git a/web/src/routes/RepoLayout.tsx b/web/src/routes/RepoLayout.tsx index f3864af0..5aa4bf22 100644 --- a/web/src/routes/RepoLayout.tsx +++ b/web/src/routes/RepoLayout.tsx @@ -3,13 +3,16 @@ import { type RepoTab, repoPath } from "../cx/address"; import { fmt } from "../cx/meta"; import type { RepoBundle } from "../cx/types"; import { FOCUS, cn } from "../components/cx/cn"; +import { allFindings } from "../components/cx/finding-fix"; import { SiteFooter, SiteHeader } from "../components/cx/site-header"; import { useLoaded, useTitle } from "../components/cx/use-page"; +import { type JourneyBundle, loadJourneys } from "../data/journeys"; import { loadRepo, loadRepoList } from "../data/repo"; import { NotFound } from "./NotFound"; interface RepoContext { repo: RepoBundle; + journeys: JourneyBundle | null; } /** @@ -20,28 +23,38 @@ export function useRepo(): RepoBundle { return useOutletContext().repo; } -const TABS: { tab?: RepoTab; label: string }[] = [ - { label: "Overview" }, +/** The repository's journeys, or null when its bundle folder holds none. */ +export function useJourneys(): JourneyBundle | null { + return useOutletContext().journeys; +} + +/** + * The tab row. `also` lists the screens that are reached from a tab's page rather than from + * the row; while one of them is open, that tab is marked as current. + */ +const TABS: { tab?: RepoTab; label: string; also?: RepoTab[] }[] = [ + { label: "Report", also: ["decisions"] }, + { tab: "journeys", label: "Journeys" }, { tab: "findings", label: "Findings" }, - { tab: "decisions", label: "Decisions" }, - { tab: "map", label: "Map" }, - { tab: "size", label: "Size" }, - { tab: "change", label: "Change" }, - { tab: "trust", label: "Trust" }, + { tab: "map", label: "Map", also: ["size"] }, + { tab: "change", label: "Before and after" }, + { tab: "trust", label: "Approach" }, ]; -type Load = { state: "missing" } | { state: "found"; repo: RepoBundle }; +type Load = + { state: "missing" } | { state: "found"; repo: RepoBundle; journeys: JourneyBundle | null }; export function RepoLayout() { const id = useParams().repo ?? ""; const loaded = useLoaded(async () => { const list = await loadRepoList(); if (!list.some((b) => b.repo_id === id)) return { state: "missing" }; - return { state: "found", repo: await loadRepo(id) }; + const [repo, journeys] = await Promise.all([loadRepo(id), loadJourneys(id)]); + return { state: "found", repo, journeys }; }, id); - const repo = - loaded.state === "ready" && loaded.value.state === "found" ? loaded.value.repo : null; + const found = loaded.state === "ready" && loaded.value.state === "found" ? loaded.value : null; + const repo = found ? found.repo : null; // Once the repository is loaded, each screen sets its own title. useTitle( loaded.state === "ready" && loaded.value.state === "missing" @@ -58,7 +71,7 @@ export function RepoLayout() {
    - Deterministic numbers, cited AI. Same commit, same report. +
    ); } @@ -84,12 +97,12 @@ export function RepoLayout() { )} - {repo && } + {found && } ); } -function RepoBody({ repo }: { repo: RepoBundle }) { +function RepoBody({ repo, journeys }: { repo: RepoBundle; journeys: JourneyBundle | null }) { const modules = repo.modules.filter((m) => m.presentAtEnd).length; // Two names and a count keep the line short; the full list is the line's tooltip. const langs = @@ -102,7 +115,7 @@ function RepoBody({ repo }: { repo: RepoBundle }) { `${fmt(repo.prodLoc)} production lines`, `${fmt(modules)} ${modules === 1 ? "module" : "modules"}`, ].filter(Boolean); - const context: RepoContext = { repo }; + const context: RepoContext = { repo, journeys }; return ( <>
    @@ -135,20 +148,6 @@ function RepoBody({ repo }: { repo: RepoBundle }) { {repo.endSha.slice(0, 10)}
    -
    -
    params
    -
    - {repo.paramsHash.slice(0, 8)} -
    -
    - {repo.rulesHash && ( -
    -
    rules
    -
    - {repo.rulesHash.slice(0, 8)} -
    -
    - )} {repo.synthetic && ( @@ -165,7 +164,8 @@ function RepoBody({ repo }: { repo: RepoBundle }) { )} @@ -174,22 +174,36 @@ function RepoBody({ repo }: { repo: RepoBundle }) { Every number on this page comes from a stored result for commit{" "} - {repo.endSha.slice(0, 7)}. AI text is cited and checked. + {repo.endSha.slice(0, 7)}. Text marked AI is checked + against those results. ); } -function RepoNav({ repoId, counts }: { repoId: string; counts: Record }) { +function RepoNav({ + repoId, + counts, + hide, +}: { + repoId: string; + counts: Partial>; + hide: RepoTab[]; +}) { const path = useLocation().pathname; const base = repoPath(repoId); + const under = (tab: RepoTab) => { + const href = repoPath(repoId, tab); + return path === href || path.startsWith(`${href}/`); + }; return (