Skip to content

Add line origin, origin shares and the labelled before and after changes - #68

Merged
Pranav-Mathad merged 3 commits into
mainfrom
issue-10-bonus-before-after
Nov 28, 2026
Merged

Pranav-Mathad merged 3 commits into
mainfrom
issue-10-bonus-before-after

Conversation

@Pranav-Mathad

Copy link
Copy Markdown
Owner

Closes #10

What this changes

Repository and report lanes, spec.md §5.6, §5.7 and §12. codexray ingest now fills line_origin and prs; codexray report fills the origin shares of every finding and map node from them, and builds before_after.json with every module at either date and a labelled list of structural changes.

  • Line origin (repository/origin.py): every production file at END is blamed with the run's ignore-revs file. Each line range is credited to its landed change: a line last touched on a side branch goes to the first-parent commit that brought it in, so every commit_sha is a row in commits. Era and AI label come from that commit.
  • Pull requests: fetched only for the commits in structural_events (one pull request costs three or more host requests, and these repositories have 6,000 to 13,600 landed changes with a number). Cached in pr-cache/ in the run folder. The token is read from the environment variable named in settings/repository.yaml; without it, on another host or offline, the run is still complete and the manifest says how many are missing.
  • Origin shares (report/line_shares.py): Finding.origin is taken over the distinct evidence lines that have a recorded origin. The AI-marked share counts strong explicit markers only; lines with only a weak marker are kept apart and named in the note. NodeStats.share_after_2025_03 is measured for production files; a run made before line origin existed reports 0 and says it was not measured.
  • Drift (analyze/drift.py, a library with no table writes): the newer snapshot measured again with the older snapshot's modules. A layout change is a reorganisation when at least half of its change in exceptions per 1,000 lines, or in links between modules, disappears under the older layout.
  • Before and after (report/before_after.py): one shared module_order from both dates, cells for every pair with links at either date, and changes of five kinds (layout change per snapshot interval, each structural-event commit, module added, module removed, link added, link removed). Labels follow §12.3 in order: same code under the old layout, a restructuring commit flagged by Stage 1, a dated decision document that names the module's full folder path; otherwise "no stated intent". Thresholds are in the new before_after: block of settings/report.yaml.
  • check_bundle in scripts/make_fixture_bundle.py now accepts modules that exist only at the earlier date in before_after.json. The fixture bundle is unchanged.

What was run and what came out

All on real repositories, in a scratch runs folder.

Ingest, Artemis, twice from scratch (codexray ingest ... --runs-dir <scratch>, 3 min 20 s and 3 min 37 s): core.db.fingerprint identical over all tables, manifest.json byte-identical, a third call says "already complete".

  • Blame alone, 8,954 production files and 1,029,656 lines on a 10-core machine: 104 s with 8 workers, 164 s with 4.
  • line_origin: 244,357 ranges covering exactly the 1,029,656 lines in snapshot_files; no gaps or overlaps; 764,060 lines after 2025-03-01 and 265,596 before; 92,743 lines with an explicit AI marker, the rest no AI signal. 62 of 6,258 blamed commits were side-branch commits, all credited to their landed change; none left out.
  • prs: 37 asked for, 37 stored. Without the token: run completes, 0 stored, limit says 37 are missing.
  • Followed by hand: three line_origin rows against git blame and git show (one side-branch row, one after the date with a co-author marker, one before), and two prs rows against gh pr view.

Report, Artemis, twice: 2,727 files under web/ plus findings.json, identical hashes. Every file loads through its contract model; check_bundle reports 0 errors on Artemis, Shopware and Graylog (the last two on copies of older runs).

  • Findings: 299; 282 with a non-zero share of lines after 2025-03-01 (median 0.79); 98 with a non-zero AI-marked share. Two findings and one file node recomputed from git blame by hand match exactly.
  • before_after.json: cells after-counts equal the map.json edges; module_order holds every module of both dates once (89, 149, 110).
Changes listed Artemis Shopware Graylog
Total 134 87 65
Planned, same code under the old layout 85 17 4
Planned, restructuring commit 7 0 2
Planned, decision document 0 3 0
No stated intent 42 67 59
  • Links between module pairs, all of them (the view lists the 25 largest per kind; the totals are in the report limits): Artemis 603 first links, 277 expected and found, 326 found but not expected; 187 lost, 144 of them renamed by a change of layout.
  • Followed by hand: a new module labelled planned (98 renames into it between the two snapshot commits), a restructuring commit, a link labelled planned and one labelled no stated intent (its file does not exist at the earlier commit), and the Shopware decision document.
  • Screen: the Artemis bundle was installed, served with vite and dumped with headless Chrome. The before-and-after screen shows the 134 changes and a grid of 89 modules. The installed bundle was removed afterwards.

make check passes.

Not reproduced, not done

  • The issue's Artemis figure is not reproduced. Across the May 2026 split (2026-04-01 to 2026-07-01), exceptions per 1,000 lines fall 8.3% under the new layout and 7.1% under the old one, with today's 16 computed decisions; the issue expected a rise of about 59% against 5%. The interval is still classified as a reorganisation, through links between modules: +16.2% under the new layout, +4.4% under the old one.
  • The pull-request-goal basis is not evaluated: it needs job B (AI jobs B and C: packets, voting, cache, simulation wiring (codexray judge) #8). A report limit says a change labelled no stated intent may still have a stated goal in its pull request.
  • No new test files. The issue lists tests/analyze/test_drift.py and tests/report/test_before_after.py; TEAM_RULES.md rule 3 replaces them with the runs above.
  • The grid's canvas cells were not inspected, only the page's DOM.
  • Shopware and Graylog were not ingested again here, so their line origin has not been run; that happens in Run all three repositories, calibrate, commit results, submission #12.

For reviewers

  • line_origin.commit_sha is the landed first-parent change, not the raw blamed commit.
  • A run made without the token is complete, so a later run with the token does not fetch the missing pull requests. Set the token on every ingest.
  • A module that exists only at the earlier date is shown in the grid by its full path (web/src/screens/BeforeAfter.tsx); the web app does not show origin.note.

Checks

  • make check passes
  • Every new fact carries its evidence: commit, file and lines, or the commits (spec.md §4.4)
  • Output is sorted and has no clock time, so a second run gives the same bytes
  • No language or project name in engine code; new starting values are in settings/
  • Does not touch core/contracts.py, core/schema/ or core/runs.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bonus: snapshot series, before and after, planned or no stated intent, line origin

1 participant