← Back to Pull requests

TAL-2646: Read a branch's committed changes through git status and diff scope #2156

Open
unknown opened this pull request with 481 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 22, 2026 19:24 UTC
Author

Linked work

TAL-2646 (server part; App adoption is TAL-2008)

What changed

After an agent commits its work, the Git status read a clean tree and the server had no way to read what the branch committed.

  • git.status and git.diff take scope: 'uncommitted' | 'branch'. Omitting it (or uncommitted) runs today's read unchanged, cache included.

  • branch (GitRunner.branchStatus) finds the first ref that exists of origin/HEAD, origin/main, origin/master, main, master in one for-each-ref, takes its merge base with HEAD, and lists base...HEAD file by file (--name-status + --numstat, renames detected). Each file has its status, change_kind, line counts and diff_kind: 'branch'; the response adds base_ref (origin/HEAD is named by the branch it points at) and detached. With no base, or no shared history, it answers base_ref: null and no files.

  • git.diff with scope=branch (or kind=branch) returns the merge-base-to-HEAD diff for the file, empty without a base.

  • The file sort and totals now come from one summarizeFiles helper shared by both reads.

  • Contract: GitScopeSchema, optional detached/base_ref on GitStatusSchema, diff_kind gains branch. contracts/web-api.openapi.json regenerated; new shared fixture contracts/fixtures/git-branch-status.json is pinned by the server test that produces it (App tests in TAL-2008 read it).
  • How it was tested

  • npx vitest run src/workspace/git.test.ts (server): 41 passed, including the 4 new branch scope (TAL-2646) tests on disposable repos: two branch commits equal the fixture (base_ref: origin/main via a symbolic origin/HEAD) while the default scope on the same clean tree still returns no files and no base_ref/detached; branch diff of a committed file; detached HEAD; no candidate base gives base_ref: null and empty files.

  • session-visibility.test.ts and worktrees.test.ts: 76 passed.

  • Contracts vitest passed; npm run typecheck (contracts, server, frontend) and npm run lint (contracts, server, frontend) pass.

  • scripts/changed-components.py --base origin/main --head HEAD --merge-base selects contracts, web_server, web_frontend, web_sidecar; no App, Relay or Docker suite.

  • No UI change, so no screenshots.
  • Regression proof

  • Baseline: 4f4fe37f63e8740d57bf90cee3aeca7a2fa0bc84 with only the new tests and fixture applied.

  • Command: cd web/packages/server && npx vitest run src/workspace/git.test.ts -t 'branch scope'

  • Red: 4 failed at their assertions. For example, lists what a clean branch committed…: expected { is_git: true, …(8) } to deeply equal { is_git: true, …(6) } with - "base_ref": "origin/main", - "files": [ { "path": "feature.txt", … "diff_kind": "branch" … (the server returned the clean-tree status); diffs a committed file…: - "additions": 1 / + "additions": 0, - "kind": "branch" / + "kind": "unstaged"; reports a detached HEAD: - "detached": true, - "changed": 2 / + "changed": 0; answers no base…: - "base_ref": null.

  • Green: same command after the change, 4 passed (full file 41 passed).
  • Release notes

    changelog.d/TAL-2646.json: Added, components ["web"], announce: false (server API only; the visible Git sheet change ships with TAL-2008).

    Checklist

  • Release fragments validate (python3 app/ci/release_notes.py validate --base origin/main after staging)

  • Affected component checks pass locally (typecheck, lint, focused server and contracts tests)

  • New/changed Codable models decode tolerantly (no App model change; new fields are optional)

  • No new third-party dependencies without approval

  • No invented API endpoints or JSON shapes (defined in web/packages/contracts)
  • Risk: low. The uncommitted path only moved its sort and totals into a shared helper. Rollback: revert the commit.

    Diff: 481 lines (+360 / -121) across 6 files Reviewer: chatgpt-codex-connector[bot] Review duration: 3m
    All Vouch review confidence checks passed
    Residual risk 0.35 = Change Risk (0.47) × (1 − Review Confidence (0.25)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 481 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 32% · Reviewer familiarity: 35%
    25%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.370
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2156"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 25.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 25.2% · Lower = rushed or shallow review
    25.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 35.4% · Moderate risk
    35.4%