Repository navigation
Description
Two cleanups found while reviewing #72 (--source A,B for --architecture). Neither changes any output.
- One code path for one source and for many. A single
--sourcestill has its own branch incli.go: its own snapshot and SCIP reads, marker suffix, alt-text notes, and its own way of working out whether codegraph and--pathare used. A list goes throughloadSourcesandRunMultiArchitectureMode. The read errors and the undrawn-edge-kinds warning exist twice, so a change to source handling has to be made in both places. Treating one source as a list of one would remove the duplication, provided single-source output stays byte-identical (marker ids, image names, warnings without a label prefix). (inferred, from readingcli.goandsources.goat da8780b) - Run the sources concurrently.
RunMultiArchitectureModeruns each source's pipeline one after another. With--source codegraph,scip, codegraph's symbol enumeration (CLI subprocesses plus an SQLite read) finishes before the in-memory SCIP work starts. Running them in parallel, with results stored by index so the order stays deterministic, would bring wall time down to roughly the slowest source. Warnings would need buffering per source to keep their order. (inferred; not measured)
Edit (2026-11-18), from the second review round:
-
Build codegraph's source in one place.
loadSourcesleaves the codegraph entry's source nil andcli.gofills in aCodegraphSourcelater. A new caller that uses the loaded source directly would pass nil into the multi-source run. In list modecli.goalso builds a single-sourcesrcit never uses. (inferred) -
Locate the codegraph index once. A multi-source run with codegraph walks up for
.codegraph/once to work out the path prefix and again to read the index. (inferred) -
Read each source's symbols once. For a snapshot or SCIP source in a list, the vote on whether its paths start at
--pathor at codegraph's index root callsSymbols()(list and sort every node), and the edge collection calls it again. That is negligible below a few hundred thousand nodes (about 0.9s per call at 500k). (inferred, timing from the review) -
Set a group edge's weight once.
RollupFileEdgessums the weights and then, for multi-source edges, overwrites the sum with the highest per-source total in a second loop. (inferred) -
One path-containment helper.
fileSourcePrefixrepeats thefilepath.Relcontainment checkEmbedPathSuffixdoes, and the "is a regular file" stat check now exists in three places.fileSourcePrefixdeliberately skipsEvalSymlinksso it matches how the codegraph index is found; a shared helper has to keep that difference. (inferred)
Edit (2026-11-18), from the #76 review:
- Look up SARIF lines only for the violating pairs.
codegraph.ReadSiteLinesruns aGROUP BYover every callee edge in the index, and repeatsReadIndexRows' retry and placeholder code, when only a few violating pairs need a line. It runs only with--sarifand at least one violation. (inferred) - One SCIP edge rule.
scipindex.RefLinesrestatesFileEdges' rule (definitions, imports, locals, namespaces, cross-file only). The pairs agree today (153 on codeshot's own index), but a change to one would leave the other behind; one pass returning edges with their first line would remove the copy. (verified agreement; drift inferred)
Edit (2026-11-18), from the #77 review:
- Decide blankness from the drawn graph.
IsBlankDotnow matches both DOT and Mermaid node lines with one regex; a new format or id scheme would need another case or--embedrefuses every diagram. The drawn file list (archDrawn) already knows. (inferred) - One embed/check tail for both formats.
finishMermaidrepeatsFinishOutput's doc read,ApplyEmbed, blank refusal, stale messages and write. Separating "produce the bytes and the markdown" from one shared embed/check tail would remove about 40 duplicated lines. (inferred)
Activity
feat: --architecture draws one diagram from several sources (#72)
feat: --sarif writes architecture rule violations as SARIF 2.1.0 (#76)
feat: --format mermaid draws --architecture as a Mermaid flowchart (#77)