Skip to content

fix: workspace sync changes LF files when Git autocrlf is enabled - #140683

Merged
steipete merged 1 commit into
mainfrom
steipete/workspace-patch-bytes-split-132180
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/workspace-patch-bytes-split-132180

Conversation

@steipete

@steipete steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Related: #132180 — first independent replacement from the node-session completion series. The original remains open until the remaining parts are landed or otherwise accounted for.

What Problem This Solves

Fixes an issue where users synchronizing worker workspace results would receive LF files rewritten as CRLF when inherited Git configuration enables core.autocrlf. That changes the worker's bytes even though workspace reconciliation is meant to preserve them exactly.

Why This Change Was Made

Disable newline conversion only for the shared Git patch-application command used by forward sync and recovery. --no-index plus disabled repository discovery already excludes repository attributes and filters, but does not prevent inherited Git newline conversion.

This two-file slice preserves conflict handling, publication outcomes, journal representation, bounds, and user/global Git configuration. It does not include node approval/publication, process lifetime, finalization batching, or other work from the original PR.

User Impact

LF and CRLF content now retain their exact bytes through workspace application and journal recovery, regardless of inherited core.autocrlf=true, input, or false. No new configuration, schema, public protocol, or enablement step is introduced.

Evidence

  • Failing before the fix: against current-main production at ae2f990dccb7ef7cfd289fd117afc728cc6d078a, the six-row real-Git matrix failed for autocrlf=true with LF: the observed worker\n bytes gained a carriage return. The other five rows passed. This was a test-only patch before the production change.
  • Passing after the fix: all 10 tests in workspace-reconcile-publication.test.ts passed, including LF/CRLF application and recovery, definitive/indeterminate publication failures, and current-main scratch-cleanup behavior.
  • Commands: node scripts/run-vitest.mjs src/gateway/worker-environments/workspace-reconcile-publication.test.ts -t 'raw bytes' before the production fix; then the same file without a filter. node scripts/check-changed.mjs -- src/gateway/worker-environments/workspace-reconcile-recovery.ts src/gateway/worker-environments/workspace-reconcile-publication.test.ts passed.
  • Git contract: GIT_CONFIG_COUNT settings override configuration files but are themselves overridden by command-local git -c options. The regression exercises the actual Git process rather than mocking its conversion.
  • Independent review: fresh isolated Codex review passed with no accepted/actionable P0 findings. This review covered only this two-file split, not the original monolithic PR.

Production LOC: +4/−1 (net +3). Tests: +78/−58. The production growth is the necessary command-local override and a comment explaining why --no-index alone was insufficient. The existing indeterminate-publication test became the six-row matrix; no test-only production seam was added.

Provenance: the current patch-application module's affected lines are blamed to the workspace-divergence repair, #111244, authored and merged by @steipete on July 19, 2026 (commit). The same omission is present in stable tag v2026.9.2. This identifies the current module's provenance, not an independently established earlier introduction date.

Disable newline conversion at the shared Git apply owner without changing user configuration, journal representation, or publication behavior. Preserve LF and CRLF bytes through forward application and recovery.

The real-Git matrix reproduces LF-to-CRLF conversion on pre-fix main. All ten publication/recovery tests pass with the fix; changed checks and fresh isolated P0 review pass.

Split from #132180.
@clawsweeper

clawsweeper Bot commented Sep 7, 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 7, 2026
@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 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 11:08 PM ET / September 7, 2026, 03:08 UTC.

ClawSweeper review

What this changes

Preserves worker workspace file bytes during synchronization and recovery by disabling Git newline conversion for patch application and extending LF/CRLF regression coverage.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on inspected main, and no actionable patch defect was found. The prior review’s draft-only blocker is resolved; the broader source PR remains separately open.

Priority: P2
Reviewed head: 9bf661e4d3aaf43cf226568776bffe7b6bcf3267

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level fix with meaningful real-Git regression coverage and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored exemption applies, with no material authority change. Supplemental evidence exercises the real shared Git apply owner and filesystem recovery under six newline configurations; the body reports the failing-before and passing-after outcomes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored exemption applies, with no material authority change. Supplemental evidence exercises the real shared Git apply owner and filesystem recovery under six newline configurations; the body reports the failing-before and passing-after outcomes.
Evidence reviewed 8 items Introduced repair: The pinned introduction adds a command-local core.autocrlf=false override to the existing shared patch owner. Repository discovery isolation, binary application, whitespace handling, and cleanup remain intact.
Still necessary on main: Inspected fetched main still invokes Git apply without the newline-conversion override. The stable-tag inspection could not retrieve its unavailable blob, so the PR body’s v2026.9.2 claim was not independently verified.
Forward and recovery boundary: Forward reconciliation calls the changed owner at line 236; recovery calls the same owner at line 622 of workspace-reconcile-recovery.ts. Snapshot creation already writes raw bytes through Git fast-import. This repair depends on Git behavior, without a Codex runtime or protocol dependency.
Findings None None.
Security None None.

How this fits together

The Gateway reconciles worker-produced files into the local workspace while preserving local conflicts. Its shared Git patch command applies accepted changes and restores journal snapshots during recovery.

flowchart TD
  A[Worker result files] --> B[Workspace reconciliation]
  C[Local files and base manifest] --> B
  B --> D[Raw Git patch]
  D --> E[Apply without newline conversion]
  E --> F[Updated local workspace]
  G[Recovery journal] --> D
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +20. Total +23 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 78 58 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 82 59 +23

Review metrics

None.

Technical review

Best possible solution:

Keep byte preservation in the shared patch owner, with command-local Git settings and regression coverage for both application and recovery.

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

Yes: applying LF worker files with inherited core.autocrlf=true reaches Git’s newline conversion on inspected main; the PR reports a failing-before/passing-after real-Git matrix. This review verified the source path without executing it.

Is this the best way to solve the issue?

Yes: the command-local override repairs both apply and recovery at their shared owner while preserving user Git configuration, journal format, and conflict policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs a bounded workspace byte-preservation defect triggered by inherited Git newline settings.
  • 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 maintainer-authored exemption applies, with no material authority change. Supplemental evidence exercises the real shared Git apply owner and filesystem recovery under six newline configurations; the body reports the failing-before and passing-after outcomes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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-07T03:01:42.130Z sha 9bf661e :: needs changes before merge. :: none

@steipete
steipete marked this pull request as ready for review September 7, 2026 03:04
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready at 9bf661e4d3aaf43cf226568776bffe7b6bcf3267.

The real-Git pre-fix matrix reproduced LF-to-CRLF conversion under core.autocrlf=true. With the command-local fix, all 10 tests in workspace-reconcile-publication.test.ts pass, including byte-exact forward application and recovery. The two-file changed checks and fresh independent P0 review also pass.

Commands: node scripts/run-vitest.mjs src/gateway/worker-environments/workspace-reconcile-publication.test.ts -t 'raw bytes' before the fix; the same file without a filter afterward; node scripts/check-changed.mjs -- src/gateway/worker-environments/workspace-reconcile-recovery.ts src/gateway/worker-environments/workspace-reconcile-publication.test.ts.

Exact-head CI is green. Native review artifacts validated and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 140683 completed using hosted exact-head gates without another push. The latest ClawSweeper review has no findings or pre-merge requirements.

Production +4/−1; tests +78/−58. No permission, schema, journal-format, or user Git configuration changes. This lands only the byte-preservation slice; the original node-session PR remains open for the rest of the split series.

@steipete
steipete merged commit eebd2b0 into main Sep 7, 2026
249 checks passed
@steipete
steipete deleted the steipete/workspace-patch-bytes-split-132180 branch September 7, 2026 03:37
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…aw#140683)

Disable newline conversion at the shared Git apply owner without changing user configuration, journal representation, or publication behavior. Preserve LF and CRLF bytes through forward application and recovery.

The real-Git matrix reproduces LF-to-CRLF conversion on pre-fix main. All ten publication/recovery tests pass with the fix; changed checks and fresh isolated P0 review pass.

Split from openclaw#132180.
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