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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
147 changes: 110 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,123 @@ CodeXray reads a large codebase and answers one question:
> Are the architecture decisions of this project being kept, and where are they not?

It is our entry for the CHECK24 track of hackaTUM 2026, "Visualise and judge a codebase".
The full specification is [spec.md](spec.md). Read §1 to §4 before writing code.
The full specification is [spec.md](spec.md).

## Status
Detection, counting and ranking are done by ordinary code from the Git history and the
source files. Every finding cites the commit, file and lines behind it.

The repository is scaffolded. The shared parts work and are tested; the pipeline stages
and the screens are stubs waiting for their owners.
## Status

| Part | State |
|---|---|
| Shared records, run layout, database tables, settings | Working, tested |
| `codexray` command with all subcommands | Working; each stage reports "not built yet" |
| Stages 1, 2, 3, 5, 6, 7 and the per-change check | Stubs with a brief each |
| Web app shell, routing, bundle loader | Working against a synthetic fixture |
| The six screens | Decisions lists the fixture; the other five are placeholders |
| Results for the three repositories | None yet |

## Set up

You need [uv](https://docs.astral.sh/uv/), Node 22.12 or newer, and git.
| Stage 1, `ingest`: history, snapshots, line origin, pull requests | Works on all three repositories |
| Stage 2, `parse`: reading and linking files | Works on all three repositories |
| 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: Decisions, Structure grid, Close-up, Code, Before and after, Size, Report | Works on the three bundles in `web/public/bundles/` |
| Stage 6, `judge`: AI text for the shown findings | Not built on this branch; prints "not built yet" |
| `decisions propose`: rules proposed from written decision documents | Not built on this branch; prints "not built yet" |
| `check <base>..<head>`: decisions a change breaks | Not built on this branch; prints "not built yet" |
| Stability table (spec.md §11.3) and the emerging-hotspots list | Not filled yet; the Report screen shows "Not measured in this run." |

Because `judge` is not built, the finding text is the fixed sentences built from the
facts, and no AI call was made for the results in this repository.

## Prerequisites

- [uv](https://docs.astral.sh/uv/). It installs Python 3.12 (`.python-version`) and the
Python packages.
- Node 22.12 or newer, the minimum the web build tool (Vite) states.
- git.
- Disk: per repository, a clone of 0.2 to 0.6 GB in `repos/` and a run folder of 0.6 to
1.1 GB in `runs/`; about 4 GB for all three.
- Time: a whole run took 4.7 minutes on Artemis, 9.2 on Shopware and 4.7 on Graylog on a
10-core laptop, with the clone already in `repos/`. Downloading the clone comes on top
and was not measured.

```sh
make setup # installs the Python and web dependencies
make setup # uv sync, then npm ci in web/
make check # lint, Python tests, web typecheck, web tests, web build
```

## Run
## Reproduce one repository from scratch

Artemis:

```sh
uv run codexray --help
make web # the web app at http://localhost:5173, showing the synthetic fixture
uv run codexray ingest https://github.com/ls1intum/Artemis.git --id artemis
uv run codexray parse --repo artemis
uv run codexray model --repo artemis
uv run codexray analyze --repo artemis
uv run codexray report --repo artemis
make bundle REPO=artemis # copy the run's bundle into web/public/bundles/artemis
make web # the web app at http://localhost:5173
```

The pipeline is one command per step. Every step is safe to re-run.
The other two take the same commands with their own URL and id:

| Command | Does | Stage |
|---|---|---|
| `codexray ingest <repo-url>` | Clone, pin, mine history, list files at every snapshot date | 1 |
| `codexray parse --repo <id>` | Read every unique file once; link files per snapshot | 2 |
| `codexray model --repo <id>` | Build the nested map per snapshot | 3 |
| `codexray decisions propose --repo <id>` | Collect decision sources; write a rules file for review | 6, job A |
| `codexray analyze --repo <id>` | Check decisions, find pressure points, compute drift | 5 |
| `codexray judge --repo <id>` | AI text for the findings that will be shown | 6 |
| `codexray report --repo <id>` | Rank, write `findings.json`, build the web bundle | 7 |
| `codexray check <base>..<head> --repo <id>` | Which decisions does this change break? | |

Output goes to `runs/<repo_id>/<END_SHA>/<params_hash>/` (spec.md §4.3). `runs/` is not
committed.

The AI steps read the gateway key from the `LLM_API_KEY` environment variable. Copy
`.env.example` to `.env`; never put the key in a file that is committed.
| id | URL |
|---|---|
| `shopware` | `https://github.com/shopware/shopware.git` |
| `graylog` | `https://github.com/Graylog2/graylog2-server.git` |

- `ingest` clones into `repos/<id>/` and pins the repository to the commit in
[repos.yaml](repos.yaml). Every later step uses that commit, never the newest one.
- Output goes to `runs/<id>/<END_SHA>/<params_hash>/` (spec.md §4.3). `runs/` and
`repos/` are not committed.
- A second run with the same commit and settings writes the same bytes. Compare two run
folders with `shasum -a 256`.
- Pull-request descriptions are fetched from GitHub only with a token in the
`GITHUB_TOKEN` environment variable (named in `src/codexray/settings/repository.yaml`).
Without it the run is complete, the `prs` table is empty, and `manifest.json` differs in
its `coverage.prs` part.
- `uv run codexray --help` lists every command. Every step is safe to re-run.

## Where the results are

- [`results/<id>/`](results/): `findings.json`, `manifest.json` and `decisions.yaml` of
each run, copied byte for byte. [results/README.md](results/README.md) says what each
file is.
- `web/public/bundles/<id>/`: the files the web app loads for each repository. Run
`make web` to browse them.

| Repository | Pinned commit | Whole run | Findings at END | Decisions | Bundle on disk |
|---|---|---|---|---|---|
| ls1intum/Artemis | `d8fc451` | 4.7 min | 219 | 16 | 37 MB |
| shopware/shopware | `ec8b714` | 9.2 min | 179 | 1 | 31 MB |
| Graylog2/graylog2-server | `4912933` | 4.7 min | 189 | 1 | 27 MB |

Each repository has 10 findings in the list to fix first.

## Token usage per analysis

| Repository | AI calls | Tokens in | Tokens out | Cost |
|---|---|---|---|---|
| ls1intum/Artemis | 0 | 0 | 0 | $0 |
| shopware/shopware | 0 | 0 | 0 | $0 |
| Graylog2/graylog2-server | 0 | 0 | 0 | $0 |

No AI call was made: the AI jobs (`judge` and `decisions propose`) are not built on this
branch, and the report is complete without AI text.

## Limits

- Shopware and Graylog have one decision each, the built-in "production code does not
depend on test code": no folder role met the settings for a measured habit there
(`habit` in `src/codexray/settings/analyze.yaml`), and decisions from written documents
need `decisions propose`, which is not built.
- The before-and-after view describes what changed. With three repositories and no
comparison group it does not show cause.
- AI markers are a minimum: tools can be set to leave none. Code without an explicit
marker is "no AI signal".
- Line origin is the last change to touch a line, which is not always the change that
first wrote it.
- Linking accuracy is agreement with separate comparison linkers, not with a compiler.
Links made while the program runs (computed paths, settings files, reflection) are not
seen.
- Thresholds and ranking weights are judgements, kept in `src/codexray/settings/`.
- Every run writes its own limits into `manifest.json` and the Report screen.

## Layout

Expand All @@ -66,21 +133,27 @@ src/codexray/
contracts.py the records that cross lane boundaries
schema/*.sql database tables, one file per stage
runs.py db.py settings.py
settings/*.yaml every starting value the spec marks "(initial)"
settings/*.yaml every threshold and weight, starting from the spec's "(initial)" values
repository/ parse/ model/ decisions/ analyze/ judge/ report/ check/
one package per lane; each __init__.py is that lane's brief
cli.py the command line
tests/ Python tests; conftest.py builds a small repository to test on
schemas/ JSON Schema generated from contracts.py
rules/ reviewed decisions per analysed repository
repos.yaml the three repositories and their pinned commits
results/ findings, manifest and decisions of each repository's run
web/ the static web app (React, Vite, TypeScript)
public/bundles/ the bundles it loads: the three repositories and two synthetic fixtures
probes/ measurement scripts behind the spec's numbers; kept as measured
docs/research/ the team's research documents and starter kits
docs/sponsor/ the sponsor deck and judging hints
```

The AI steps, once built, read the gateway key from the `LLM_API_KEY` environment
variable. Copy `.env.example` to `.env`; never put the key in a file that is committed.

## Working in parallel

[CONTRIBUTING.md](CONTRIBUTING.md) lists the lanes, what each one reads and writes, and
the rule for changing something another lane depends on.
the rule for changing something another lane depends on. [TEAM_RULES.md](TEAM_RULES.md)
holds the team's working rules.
50 changes: 50 additions & 0 deletions results/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Results

The output of one full run of CodeXray on each of the three repositories, copied byte for
byte from the run folder `runs/<id>/<END_SHA>/<params_hash>/`. The web app's copy of each
run is in [`web/public/bundles/<id>/`](../web/public/bundles/).

| Folder | Repository | Pinned commit (`repos.yaml`) |
|---|---|---|
| `artemis/` | ls1intum/Artemis | `d8fc4519563de28366e80edd77d2020a2c7a5157` |
| `shopware/` | shopware/shopware | `ec8b7141762457f03741e59f85cb1eeb852b062d` |
| `graylog/` | Graylog2/graylog2-server | `4912933127e13ba7e84d74daef36f5c182af1320` |

## What each file is

| File | Holds |
|---|---|
| `findings.json` | Every finding at the pinned commit, ranked, with its evidence (commit, file and lines) and its priority. The first ten are the list to fix first. |
| `manifest.json` | The pinned commit, `params_hash`, tool and grammar versions, the settings in effect, what was read and what was not, and the limits of the run. |
| `decisions.yaml` | The decisions that were checked: measured habits and the built-in ones, with their source. |

## How to reproduce

From the repository root, for Artemis (the other two take their URL and id from
`repos.yaml`):

```sh
uv run codexray ingest https://github.com/ls1intum/Artemis.git --id artemis
uv run codexray parse --repo artemis
uv run codexray model --repo artemis
uv run codexray analyze --repo artemis
uv run codexray report --repo artemis
```

`ingest` pins the repository to the commit in `repos.yaml`. The three files then sit in
`runs/artemis/<END_SHA>/<params_hash>/` and can be compared with the ones here
(`shasum -a 256`).

These runs fetched pull-request descriptions with a token in `GITHUB_TOKEN` (the variable
named in `src/codexray/settings/repository.yaml`). Without it the run is still complete,
the `prs` table is empty, and `manifest.json` differs in its `coverage.prs` part.

## What is not here yet, and why

- **`usage.json`** (the AI usage ledger): no AI call was made for these results. The AI
jobs (`codexray judge`, `codexray decisions propose`) are not built on this branch, so
calls, tokens and cost are 0 for each repository and the finding text is the fixed
sentences built from the facts. A hand-written ledger would be an invented result.
- **`robustness.json`** (the stability table): the stability stage is not merged yet.
- **`judgements/`**: there are no AI responses to cache.
- **`codexray.duckdb`**: 0.6 to 1.1 GB per repository. It is rebuilt by the commands above.
Loading