Skip to content

improve: reduce Git work when loading session diffs - #150018

Merged
steipete merged 1 commit into
mainfrom
codex/team-session-diff-inventory-20260916
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/team-session-diff-inventory-20260916

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening or refreshing a session diff repeats Git inventory work for the same tracked changes.

User Impact

Successful nonempty tracked diffs use one fewer Git process while preserving filenames, line counts, previews, and freshness between completed requests.

Why This Change Was Made

Read file status and line counts together with git diff --raw --numstat -z, using the existing parsing rules. Keep patch collection separate so large diffs still stop at the existing preview budget, and retain filename-only results when statistics cannot be collected.

Evidence

  • 70 focused tests across session diff, baseline, and revision behavior passed, including binary files, unusual filenames, preview limits, filesystem protections, and failed statistics collection.
  • A real-Git regression through loadSessionDiff preserves complete stats-only output but fails on the original code because it launches two tracked-diff processes. The candidate passes the one-process bound.
  • A synthetic Git fixture produced byte-identical status and count inventories for edits, additions, deletions, renames, binary/type changes, and unusual filenames.
  • Selected changed checks and independent P2 review passed. The measured resource reduction covers synthetic session-diff requests; whole-Gateway CPU improvement remains unmeasured.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 11:49
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 8:11 AM ET / 12:11 UTC (Revision 2).

ClawSweeper review

What this changes

Combine tracked-file status and line-count collection into one Git command when loading session diffs, preserving separate previews and failure fallback.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful on current main, and no introduced correctness or security defect was found. The previous review's whole-Gateway performance caveat does not justify a blocker for the narrower process-count claim.

Priority: P2
Reviewed head: fc455cdb366cf76f22b2a8ff810d793936c13370

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful regression coverage and no actionable defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported real-Git coverage exercises loadSessionDiff and the changed collector; whole-Gateway performance is explicitly unmeasured.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported real-Git coverage exercises loadSessionDiff and the changed collector; whole-Gateway performance is explicitly unmeasured.
Evidence reviewed 8 items Introduced scope and merge result: The verified test merge has the pinned base followed by the exact PR head as parents; its difference from that base contains only the three declared session-diff files. The introduced diff passes whitespace checking, and the checkout remains clean.
Current main still performs separate inventory reads: The current-main collector invokes --name-status and --numstat separately before applying the unchanged preview budget. Existing in-flight request sharing does not eliminate those two operations within a request.
Parser and fallback contract: The combined parser consumes raw records with one or two pathname tokens, then delegates counts to the existing numstat parser. Failed combined collection retains separate filename and count reads; patch budgets and filesystem safeguards remain unchanged.
Findings None None.
Security None None.

How this fits together

The session diff service reads a session's Git checkout and supplies file changes, counts, and bounded previews to the Control UI. Existing session resolution, Git execution, and freshness owners surround the changed inventory parser.

flowchart TD
  A[Session diff request] --> B[Resolve checkout and revisions]
  B --> C[Combined Git inventory]
  C --> D{Inventory succeeded?}
  D -->|Yes| E[Parse filenames and counts]
  D -->|No| F[Separate inventory fallback]
  F --> E
  E --> G[Apply preview limits and file safeguards]
  G --> H[Return session diff]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +43, Tests +91. Total +134 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 53 10 +43
Tests 1 91 0 +91
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 144 10 +134

Review metrics

Metric Value Why it matters
Tracked inventory subprocesses 2 → 1 on successful nonempty inventory reads This is the bounded operational improvement supported by the implementation and reported regression coverage.

Technical review

Best possible solution:

Keep inventory collection within the existing diff owner, with separate bounded previews and unchanged request freshness.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a functional bug: current source confirms repeated inventory commands, and the PR supplies a focused real-Git process-count regression.

Is this the best way to solve the issue?

Yes. Combining Git's compatible inventory outputs removes one process without adding a cache, changing public contracts, or bypassing existing preview safeguards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cf6f6d926fd8.

Labels

Label justifications:

  • P2: A focused session-diff efficiency improvement with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported real-Git coverage exercises loadSessionDiff and the changed collector; whole-Gateway performance is explicitly unmeasured.

Evidence

What I checked:

  • Introduced scope and merge result: The verified test merge has the pinned base followed by the exact PR head as parents; its difference from that base contains only the three declared session-diff files. The introduced diff passes whitespace checking, and the checkout remains clean. (9eec956505d0)
  • Current main still performs separate inventory reads: The current-main collector invokes --name-status and --numstat separately before applying the unchanged preview budget. Existing in-flight request sharing does not eliminate those two operations within a request. (src/sessions/session-diff.runtime.ts:219, cf6f6d926fd8)
  • Parser and fallback contract: The combined parser consumes raw records with one or two pathname tokens, then delegates counts to the existing numstat parser. Failed combined collection retains separate filename and count reads; patch budgets and filesystem safeguards remain unchanged. (src/sessions/session-diff-parser.ts:79, fc455cdb366c)
  • Focused regression coverage: The complete test file covers real Git repositories, tracked binary files, unusual filenames, stats-only previews, and failed count collection. The added large-diff case checks complete output while bounding tracked-diff subprocesses to one. The captured PR body reports 70 focused tests passing; this read-only review did not execute them. (src/gateway/server-methods/sessions-diff.test.ts:363, fc455cdb366c)
  • Existing optimization is complementary: GitHub verifies fix: reduce repeated Git work during repository requests #146273 as merged. Its worker and in-flight cache optimization shares concurrent requests while preserving freshness; it does not replace the separate per-request inventory commands still present on main. (src/infra/git-read-cache.ts:129, f0fafba02efd)
  • Prior merged parser work: Current-main history and GitHub commit metadata identify steipete's prior quoted-filename parser repair. Some local historical blobs were unavailable, so GitHub's commit patch supplied the narrower routing evidence. (src/sessions/session-diff-parser.ts:139, e4d413e39505)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-16T11:48:56.773Z sha fc455cd :: blocked before merge. :: none

@steipete
steipete merged commit 3916ace into main Sep 16, 2026
219 checks passed
@steipete
steipete deleted the codex/team-session-diff-inventory-20260916 branch September 16, 2026 12:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant