Skip to content

major major code refactor - #69

Merged
Asifdotexe merged 14 commits into
mainfrom
68-refactor-architecture
Jul 26, 2026
Merged

Asifdotexe merged 14 commits into
mainfrom
68-refactor-architecture

Conversation

@Asifdotexe

@Asifdotexe Asifdotexe commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a benchmarking tool that reports throughput and storage efficiency across full and incremental snapshots.
    • Updated the pipeline to persist analysis using an append-only history format plus a separate per-repo fossils file and a latest-state snapshot.
  • Tests

    • Added automated tests for saving/loading history snapshots and latest-state recovery, including behavior when state is missing.
  • Documentation

    • Expanded the journal with timestamped notes covering the refactoring workflow and benchmark results.
    • Added/updated cleanup and refactoring plan notes to reflect the new persistence approach.

@Asifdotexe Asifdotexe self-assigned this Jul 25, 2026
@Asifdotexe Asifdotexe added the enhancement New feature or request label Jul 25, 2026
@Asifdotexe Asifdotexe linked an issue Jul 25, 2026 that may be closed by this pull request
11 tasks
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Asifdotexe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a07a51a-80b0-45c5-aba5-b79d26e7bb80

📥 Commits

Reviewing files that changed from the base of the PR and between 783ef57 and e2ed8a3.

⛔ Files ignored due to path filters (1)
  • engine/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • .github/workflows/theseus-engine.yml
  • .github/workflows/unit-tests.yml
  • build_engine.bat
  • engine/Cargo.toml
  • engine/src/main.rs
  • journal.md
  • python-to-rust.md
  • run_engine.bat
  • scripts/_data_io.py
  • scripts/_utils.py
  • scripts/analyse_repository.py
  • scripts/benchmark_pipeline.py
  • tests/test_analyse_repository.py
📝 Walkthrough

Walkthrough

The changes replace bundled snapshot JSON storage with separate JSONL history, fossil JSON, and incremental-state files. Analysis, fossil generation, cleanup, graph generation, pipeline orchestration, benchmarking, fixtures, and journal records are updated for the new persistence workflow.

Changes

JSONL Pipeline Refactor

Layer / File(s) Summary
History, fossil, and state persistence contracts
scripts/_data_io.py
Adds JSONL history, fossil JSON, and latest-state loaders and writers, including atomic replacement and tolerant handling of missing or corrupted inputs.
Incremental analysis state integration
scripts/analyse_repository.py, data/raw/langchain_history.jsonl, data/state/langchain_state.json
Separates history entries from file compositions, uses persisted latest state for incremental baselines, and stores the updated history and state payloads.
Fossil and cleanup pipeline migration
scripts/add_fossils.py, scripts/cleanup_data.py, scripts/run_pipeline.py
Moves fossil persistence to dedicated files and updates cleanup, graph generation, and Stage 3 orchestration to process history JSONL inputs.
Benchmarking, validation, and refactoring records
scripts/benchmark_pipeline.py, scripts/test_data_io.py, journal.md
Adds full-versus-incremental benchmarking, records the persistence refactoring workflow, and adds data I/O tests alongside legacy snapshot-helper references.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is very generic and doesn't identify the main refactor area or user-visible change. Replace it with a specific title that names the core change, such as the new history/state persistence refactor or cleanup pipeline update.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 68-refactor-architecture

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Asifdotexe
Asifdotexe marked this pull request as ready for review July 26, 2026 07:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/_data_io.py`:
- Around line 101-116: The load_latest_state function must validate decoded JSON
is a mapping before calling get, and handle UnicodeDecodeError and OSError from
reading the state file. Treat any such invalid or unreadable state as absent by
logging appropriately and returning (None, None), while preserving successful
mapping-based state loading.

In `@scripts/benchmark_pipeline.py`:
- Line 38: Remove the unnecessary f-string prefixes from the placeholder-free
string assignments at the referenced locations, including temp_repo_path and the
corresponding second occurrence, while preserving their string values.
- Around line 5-7: Move the repository-root path setup in benchmark_pipeline.py
above the scripts.analyse_repository import, ensuring Path is imported before it
is used. Keep the existing analyze_single_snapshot, ensure_repo_ready, and
get_snapshot_periods imports unchanged after sys.path is initialized.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5185ccce-8333-41d1-b7dd-95e3eb7dca55

📥 Commits

Reviewing files that changed from the base of the PR and between a6525fa and 551fe9f.

📒 Files selected for processing (4)
  • journal.md
  • scripts/_data_io.py
  • scripts/benchmark_pipeline.py
  • scripts/test_data_io.py

Comment thread scripts/_data_io.py
Comment thread scripts/benchmark_pipeline.py Outdated
Comment thread scripts/benchmark_pipeline.py Outdated
"""
repo_slug = "anthropics/claude-code"
repo_name = "claude-code"
temp_repo_path = f"../temp_workdir_benchmark"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the unnecessary f-string prefixes.

These strings have no placeholders, so Ruff F541 fails linting.

Proposed fix
-    temp_repo_path = f"../temp_workdir_benchmark"
+    temp_repo_path = "../temp_workdir_benchmark"
...
-        print(f"  Data Storage:")
+        print("  Data Storage:")

Also applies to: 77-77

🧰 Tools
🪛 Ruff (0.15.21)

[error] 38-38: f-string without any placeholders

Remove extraneous f prefix

(F541)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/benchmark_pipeline.py` at line 38, Remove the unnecessary f-string
prefixes from the placeholder-free string assignments at the referenced
locations, including temp_repo_path and the corresponding second occurrence,
while preserving their string values.

Source: Linters/SAST tools

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
journal.md (1)

96-193: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the duplicated journal history.

Lines 96–185 repeat the existing entries from lines 1–90, and lines 187–193 repeat the architectural-audit entry. Keep one canonical copy and append only the new entries; otherwise the journal chronology and duplicate-heading lint check remain misleading.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@journal.md` around lines 96 - 193, Remove the duplicated journal entries in
the shown section, preserving one canonical copy of each existing history item,
including the architectural-audit entry. Keep the journal chronology intact and
retain only genuinely new entries after the surviving canonical history.

Source: Linters/SAST tools

🧹 Nitpick comments (1)
scripts/_data_io.py (1)

38-84: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove or wire in the unconnected history helpers.

get_last_history_snapshot and append_history_snapshot are not imported or called from the pipeline scripts. Leaving them in _data_io.py also invites future code to rely on their drawbacks:

  • get_last_history_snapshot scans the whole file to satisfy “last snapshot” — the docstring’s memory/O(n) claim doesn’t match this implementation; appending with an immutable log tail can still make this efficient without reading from EOF.
  • append_history_snapshot uses plain append mode, so a crash mid-write can leave a truncated JSONL line that load_history may swallow silently.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/_data_io.py` around lines 38 - 84, The history helpers
get_last_history_snapshot and append_history_snapshot are unused and contain
unsafe or misleading behavior. Remove both unconnected functions from
_data_io.py, along with any imports or supporting code used exclusively by them,
unless the pipeline is updated to use them with robust EOF-based reading and
crash-safe appending.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@journal.md`:
- Around line 215-219: The JSONL migration description overstates memory
efficiency because analyse_repository.py still materializes the full history
through load_history(). Reword the journal entry and rationale to describe
incremental appends and reduced full-file rewriting/I/O, removing claims of
memory efficiency unless load_history() consumers are changed to stream records.

In `@scripts/analyse_repository.py`:
- Around line 268-295: Update _find_baseline to verify that the commit returned
by load_latest_state matches the commit associated with last_historical_snapshot
before returning the incremental baseline. If the hashes do not match, return
None so processing falls back to a full blame; preserve the existing checks for
missing history, historical reprocessing, and invalid state.

---

Outside diff comments:
In `@journal.md`:
- Around line 96-193: Remove the duplicated journal entries in the shown
section, preserving one canonical copy of each existing history item, including
the architectural-audit entry. Keep the journal chronology intact and retain
only genuinely new entries after the surviving canonical history.

---

Nitpick comments:
In `@scripts/_data_io.py`:
- Around line 38-84: The history helpers get_last_history_snapshot and
append_history_snapshot are unused and contain unsafe or misleading behavior.
Remove both unconnected functions from _data_io.py, along with any imports or
supporting code used exclusively by them, unless the pipeline is updated to use
them with robust EOF-based reading and crash-safe appending.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c18a169-aa8e-477d-90e1-2570e10df2e1

📥 Commits

Reviewing files that changed from the base of the PR and between 551fe9f and 783ef57.

📒 Files selected for processing (14)
  • data/raw/claude-code_data.json
  • data/raw/langchain_data.json
  • data/raw/langchain_history.jsonl
  • data/raw/numpy_data.json
  • data/raw/react_data.json
  • data/raw/zed_data.json
  • data/state/langchain_state.json
  • journal.md
  • scripts/_data_io.py
  • scripts/add_fossils.py
  • scripts/analyse_repository.py
  • scripts/cleanup_data.py
  • scripts/run_pipeline.py
  • scripts/test_data_io.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/test_data_io.py

Comment thread journal.md
Comment thread scripts/analyse_repository.py
Asifdotexe and others added 5 commits July 26, 2026 16:32
…ld scripts

- Fix reprocess inputs and bash arrays in theseus-engine.yml

- Pin rust-cache actions to verified commit

- Refactor engine main.rs to use map_init for git2 thread-safety

- Persist incremental state inside period processing loop

- Rewrite JSONL when appending to deduplicate reprocessed rows

- Avoid cargo run inside analyse_repository for non-Windows

- Use checked pushd in bat scripts with preserved exit code
@Asifdotexe
Asifdotexe merged commit e818f74 into main Jul 26, 2026
2 checks passed
@Asifdotexe
Asifdotexe deleted the 68-refactor-architecture branch July 26, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor architecture

1 participant