Skip to content

fix(engine): include uncommitted working-tree changes in base-ref change detection#409

Merged
rhuanbarreto merged 4 commits into
mainfrom
fix/review-context-uncommitted-changes
Jun 11, 2026
Merged

fix(engine): include uncommitted working-tree changes in base-ref change detection#409
rhuanbarreto merged 4 commits into
mainfrom
fix/review-context-uncommitted-changes

Conversation

@rhuanbarreto

@rhuanbarreto rhuanbarreto commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #403archgate review-context (and archgate check --base via ctx.changedFiles) silently omitted uncommitted work whenever a base ref was detected, which is almost always. During a typical AI-agent dev session (files written via editor tools, nothing committed), the reviewer validated the wrong file set.

Changes

  • src/engine/git-files.tsgetFilesChangedSinceRef now unions three concurrent git queries:

    1. git diff base...HEAD (committed branch changes)
    2. staged + unstaged edits to tracked files (getChangedFiles)
    3. untracked non-ignored files (git ls-files --others --exclude-standard)

    Bad-ref / non-repo behavior is unchanged (returns []); --staged is untouched.

  • Tests — 3 unit regression tests (uncommitted tracked edits, staged-only, untracked + gitignore exclusion) and 1 integration test reproducing the issue's agent-session scenario.

  • Docs (en/nb/pt-br) — updated check.mdx, rule-api.mdx, concepts/rules.mdx, guides/writing-rules.mdx to describe the new semantics. The pt-br check page was missing the entire "Changed files detection" section — added it.

Dogfooding note

The GEN-002 i18n-translation-drift rule flagged the missing pt-br doc updates only after this fix was applied — previously it couldn't see uncommitted edits at all.

Validation

  • bun run validate fully green (1266 tests, 39/39 ADR rules, knip, build check)
  • Verified live: review-context went from allChangedFiles: [] to listing all uncommitted edits in this very session

Summary by CodeRabbit

  • New Features

    • Changed-files detection now includes uncommitted working-tree changes (staged, unstaged, and untracked non-ignored files) in addition to branch diffs.
  • Documentation

    • Updated CLI, API, and guides across English, nb, and pt‑br to explain expanded changed-files semantics and --staged / --base <ref> behavior.
    • Added rule requiring English doc changes be mirrored to nb/ and pt‑br and to verify section parity.
  • Tests

    • Added regression and integration tests validating working-tree detection and base-branch resolution.

…nge detection

getFilesChangedSinceRef only ran 'git diff base...HEAD', which sees
committed changes exclusively. Since a base ref is detected in any
normal repo, review-context and check --base silently omitted the
staged, unstaged, and untracked files actually under review during a
dev session.

The function now unions three concurrent git queries:
- git diff base...HEAD (committed branch changes)
- staged + unstaged edits to tracked files (getChangedFiles)
- untracked non-ignored files (git ls-files --others --exclude-standard)

Bad-ref/non-repo behavior is unchanged (returns []); --staged is
untouched. Docs updated in en/nb/pt-br, including the previously
missing 'Changed files detection' section on the pt-br check page.

Fixes #403

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 19c4e62c-6ed6-4a38-a5d9-8102ad62533d

📥 Commits

Reviewing files that changed from the base of the PR and between e2e244d and 45113da.

📒 Files selected for processing (3)
  • docs/public/llms-full.txt
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/check.mdx

📝 Walkthrough

Walkthrough

This PR expands uncommitted working-tree change detection in archgate by broadening getFilesChangedSinceRef to union committed branch diffs with staged, unstaged, and untracked files, validates the fix with unit and integration tests, and updates API, CLI, and developer documentation across English, Norwegian, and Portuguese-Brazilian locales.

Changes

Changed Files Detection Fix

Layer / File(s) Summary
getFilesChangedSinceRef implementation and unit tests
src/engine/git-files.ts, tests/engine/git-files.test.ts
getFilesChangedSinceRef now unions three sources: committed branch changes (git diff ref...HEAD), staged and unstaged tracked edits, and untracked non-ignored files. Three new unit tests verify inclusion of uncommitted edits, staged files, and untracked (but not ignored) files.
Integration test for review-context with working-tree changes
tests/integration/review-context.test.ts
New integration test verifies that review-context --base includes committed branch changes, uncommitted edits to tracked files, and untracked files in allChangedFiles.
RuleContext.changedFiles API and writing guides
docs/src/content/docs/concepts/rules.mdx, docs/src/content/docs/guides/writing-rules.mdx, docs/src/content/docs/reference/rule-api.mdx, docs/src/content/docs/nb/*, docs/src/content/docs/pt-br/*, docs/public/llms-full.txt
Updated RuleContext documentation across English, Norwegian, and Portuguese to clarify that ctx.changedFiles includes branch diff plus uncommitted working-tree changes (staged, unstaged, untracked), with behavior under --staged and --base <ref>. Revised writing-rules guides to explain incremental checking and file-dependency strategies using the expanded definition.
archgate check CLI changed files detection
docs/src/content/docs/reference/cli/check.mdx, docs/src/content/docs/nb/reference/cli/check.mdx, docs/src/content/docs/pt-br/reference/cli/check.mdx, docs/public/llms-full.txt
Expanded documentation across all locales explaining how archgate check populates ctx.changedFiles with branch diff plus working-tree changes, base-ref resolution priority, and fallback to full-scan mode when detection fails.
Agent memory and documentation maintenance
.claude/agent-memory/archgate-developer/MEMORY.md, docs/public/llms-full.txt
Removed outdated workaround note about review-context omitting uncommitted changes. Added requirement that English doc edits must be applied to both nb/ and pt-br/ locales in the same changeset, with reminder to verify section parity.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A working tree once bare and sparse,
Now blooms with changes staged and untracked!
The diff grows wide, the docs grow clear,
Three tongues sing out: the fix is here. 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing the engine to include uncommitted working-tree changes in base-ref change detection, which is the core objective of the PR.
Linked Issues check ✅ Passed The PR fully addresses issue #403 by modifying getFilesChangedSinceRef to union committed changes, staged/unstaged edits, and untracked files, meeting all coding requirements for the fix.
Out of Scope Changes check ✅ Passed All changes are directly related to the #403 fix: engine implementation, unit/integration tests, and corresponding documentation updates across three locales (en/nb/pt-br) align with the stated objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/review-context-uncommitted-changes

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

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 45113da
Status: ✅  Deploy successful!
Preview URL: https://c14ad44e.archgate-cli.pages.dev
Branch Preview URL: https://fix-review-context-uncommitt.archgate-cli.pages.dev

View logs

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.2% (6798 / 7533)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.1% 2078 / 2359
src/engine/ 93.1% 1384 / 1486
src/formats/ 100.0% 141 / 141
src/helpers/ 90.1% 3195 / 3547

@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: 4

🤖 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 @.claude/agent-memory/archgate-developer/MEMORY.md:
- Line 63: Reword the incident-specific sentence about pt-br check.mdx to a
general illustrative pattern: replace "pt-br `check.mdx` was missing the entire
'Changed files detection' section" with a neutral example such as "e.g., a
'Changed files detection' section might exist in English but be entirely absent
from pt-br" so the MEMORY.md line about locale drift reads as a recurring risk
rather than a past-event; update the sentence in the
.claude/agent-memory/archgate-developer/MEMORY.md entry referencing `check.mdx`,
`docs/src/content/docs/nb/<path>`, and `docs/src/content/docs/pt-br/<path>`
accordingly.

In `@docs/src/content/docs/nb/reference/cli/check.mdx`:
- Around line 106-107: Replace the abbreviated Norwegian phrase "+ arbeidstre"
with the full, consistent term "+ arbeidstre-endringer" in the table rows that
currently read "` .archgate/config.json` `baseBranch` | `git diff
<resolved-ref>...HEAD` + arbeidstre" and "Git-autodeteksjon | `git diff
<detected-ref>...HEAD` + arbeidstre" so all rows match the full wording used in
the sibling row ("+ arbeidstre-endringer").

In `@docs/src/content/docs/pt-br/reference/cli/check.mdx`:
- Around line 98-110: Normalize the Portuguese in this section by replacing the
older compound forms with current-form compounds: change occurrences of
"auto-detecta" and "auto-detecção" to "autodetecta" and "autodetecção"
respectively, and expand the abbreviation "ref" to the full word "referência"
where it appears in the prose; ensure these replacements are applied to the
paragraph describing how archgate check resolves the base branch and the
bullet/priority table so wording remains consistent (e.g., update "git diff
<ref>...HEAD" text descriptions to use "referência" in the human-readable
sentences).

In `@docs/src/content/docs/pt-br/reference/rule-api.mdx`:
- Line 96: Update the Portuguese phrasing in the sentence that begins "Arquivos
que foram modificados de acordo com o git..." by replacing "de acordo com o git"
with "conforme o Git" and "auto-preenchido" with "autopreenchido" (and ensure
"Git" is capitalized), keeping the rest of the sentence unchanged to preserve
the technical meaning.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eafb1dcb-44a1-47d6-ab5b-8138b50c51c8

📥 Commits

Reviewing files that changed from the base of the PR and between cb8d3d6 and e5a7ddc.

📒 Files selected for processing (17)
  • .claude/agent-memory/archgate-developer/MEMORY.md
  • docs/public/llms-full.txt
  • docs/src/content/docs/concepts/rules.mdx
  • docs/src/content/docs/guides/writing-rules.mdx
  • docs/src/content/docs/nb/concepts/rules.mdx
  • docs/src/content/docs/nb/guides/writing-rules.mdx
  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/rule-api.mdx
  • docs/src/content/docs/pt-br/concepts/rules.mdx
  • docs/src/content/docs/pt-br/guides/writing-rules.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/rule-api.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/rule-api.mdx
  • src/engine/git-files.ts
  • tests/engine/git-files.test.ts
  • tests/integration/review-context.test.ts

Comment thread .claude/agent-memory/archgate-developer/MEMORY.md Outdated
Comment thread docs/src/content/docs/nb/reference/cli/check.mdx Outdated
Comment thread docs/src/content/docs/pt-br/reference/cli/check.mdx Outdated
Comment thread docs/src/content/docs/pt-br/reference/rule-api.mdx Outdated
- nb check.mdx: use 'arbeidstre-endringer' consistently in all priority
  table rows
- pt-br check.mdx: current-form compounds (autodetecta, autodetecao) and
  'referencia' instead of 'ref' in prose
- pt-br rule-api.mdx: tighten phrasing (conforme o Git, autopreenchido,
  ex.:, Fica vazio)
- agent memory: reword locale-section-parity note as a general pattern
  instead of an incident report

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@rhuanbarreto

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 1

🤖 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 `@docs/src/content/docs/pt-br/reference/cli/check.mdx`:
- Around line 106-107: Replace the abbreviated phrase "+ árvore de trabalho"
with the full, consistent Portuguese wording "+ alterações da árvore de
trabalho" in the priority table rows containing `.archgate/config.json
baseBranch` and `Autodetecção do git` so all rows match the wording used in the
row with `baseRef` (`+ alterações da árvore de trabalho`) and align with the
Norwegian-version fix.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 55e2fcc1-b873-4535-bd02-7cd99d389dc1

📥 Commits

Reviewing files that changed from the base of the PR and between e5a7ddc and e2e244d.

📒 Files selected for processing (4)
  • .claude/agent-memory/archgate-developer/MEMORY.md
  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/rule-api.mdx

Comment thread docs/src/content/docs/pt-br/reference/cli/check.mdx Outdated
Apply the same consistency fix to the pt-br and English tables that the
previous commit applied to the Norwegian one: rows 3-4 now spell out
'alteracoes da arvore de trabalho' / 'working-tree changes' instead of
the abbreviated form.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@rhuanbarreto rhuanbarreto merged commit ee0b1c1 into main Jun 11, 2026
25 of 28 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/review-context-uncommitted-changes branch June 11, 2026 14:17
@archgatebot archgatebot Bot mentioned this pull request Jun 11, 2026
rhuanbarreto pushed a commit that referenced this pull request Jun 11, 2026
# archgate

## [0.45.3](v0.45.2...v0.45.3)
(2026-06-11)

### Bug Fixes

* **engine:** include uncommitted working-tree changes in base-ref
change detection ([#409](#409))
([ee0b1c1](ee0b1c1)),
closes [#403](#403)

---
This PR was generated with
[simple-release](https://github.com/TrigenSoftware/simple-release).

<details>
<summary>📄 Cheatsheet</summary>
<br>



You can configure the bot's behavior through a pull request comment
using the `!simple-release/set-options` command.

### Command Format

````md
!simple-release/set-options

```json
{
  "bump": {},
  "publish": {}
}
```
````

### Useful Parameters

#### Bump

| Parameter | Type | Description |
|-----------|------|-------------|
| `version` | `string` | Force set specific version |
| `as` | `'major' \| 'minor' \| 'patch' \| 'prerelease'` | Release type
|
| `prerelease` | `string` | Pre-release identifier (e.g., "alpha",
"beta") |
| `firstRelease` | `boolean` | Whether this is the first release |
| `skip` | `boolean` | Skip version bump |
| `byProject` | `Record<string, object>` | Per-project bump options for
monorepos |

#### Publish

| Parameter | Type | Description |
|-----------|------|-------------|
| `skip` | `boolean` | Skip publishing |
| `access` | `'public' \| 'restricted'` | Package access level |
| `tag` | `string` | Tag for npm publication |

### Usage Examples

#### Force specific version

````md
!simple-release/set-options

```json
{
  "bump": {
    "version": "2.0.0"
  }
}
```
````

#### Force major bump

````md
!simple-release/set-options

```json
{
  "bump": {
    "as": "major"
  }
}
```
````

#### Create alpha pre-release

````md
!simple-release/set-options

```json
{
  "bump": {
    "prerelease": "alpha"
  }
}
```
````

#### Publish with specific access and tag

````md
!simple-release/set-options

```json
{
  "bump": {
    "prerelease": "beta"
  },
  "publish": {
    "access": "public",
    "tag": "beta"
  }
}
```
````

### Access Restrictions

The command can only be used by users with permissions:
- repository owner
- organization member
- collaborator

### Notes

- The last comment with `!simple-release/set-options` command takes
priority
- JSON must be valid, otherwise the command will be ignored
- Parameters apply only to the current release execution
- The command can be updated by editing the comment or adding a new one


</details>

<!--
  Please do not edit this comment.
  simple-release-pull-request: true
  simple-release-branch-from: release
  simple-release-branch-to: main
-->

Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

review-context misses uncommitted (working-tree) changes when a base ref is detected

1 participant