Skip to content

[sync] go-git: 2 commits from Forge#1

Merged
Snider merged 8 commits intomainfrom
dev
Mar 17, 2026
Merged

[sync] go-git: 2 commits from Forge#1
Snider merged 8 commits intomainfrom
dev

Conversation

@Snider
Copy link
Contributor

@Snider Snider commented Mar 17, 2026

Forge → GitHub Sync

Commits: 2
Files changed: 4

Automated sync from Forge (forge.lthn.ai) to GitHub mirror.


Co-Authored-By: Virgil virgil@lethean.io

Summary by CodeRabbit

  • Refactor

    • Improved and standardised error reporting across the system for clearer, more consistent messages.
  • Bug Fixes

    • Stricter path validation now surfaces clearer errors for relative or out-of-scope paths.
  • Tests

    • Added comprehensive unit tests covering path validation and request handling.
  • Documentation

    • Minor wording clarification in test conventions.
  • Chores

    • Updated project dependencies and build configuration.

Snider and others added 6 commits March 15, 2026 15:36
… interface checks

- Replace all fmt.Errorf calls in git.go and service.go with coreerr.E()
  from forge.lthn.ai/core/go-log for structured error context
- Alias stdlib "io" as goio in git.go (consistent with go-io convention)
- Add compile-time interface checks: var _ error = (*GitError)(nil) and
  var _ core.Startable = (*Service)(nil)
- Add forge.lthn.ai/core/go-log v0.0.4 as direct dependency

Co-Authored-By: Virgil <virgil@lethean.io>
Coverage improved from 90.4% to 96.4%. Key areas now at 100%:
validatePath, handleQuery, handleTask.

DX audit results:
- CLAUDE.md: accurate, no changes needed
- Error handling: all errors already use coreerr.E()
- File I/O: no os.ReadFile/WriteFile in production code

Co-Authored-By: Virgil <virgil@lethean.io>
…LAUDE.md — update any outdate...' (#1) from agent/dx-audit-and-fix--1--review-claude-md into main
…LAUDE.md

Coverage improved from 90.4% to 96.4%. Key functions now at 100%:
validatePath, handleQuery, handleTask. Added tests for WorkDir
boundary enforcement, relative path rejection, and path validation
in all query/task handlers.

Co-Authored-By: Virgil <virgil@lethean.io>
…LAUDE.md — update any outdate...' (#2) from agent/dx-audit-and-fix--1--review-claude-md into main
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 80af6849-f529-4bbf-930c-fc921bdc60f0

📥 Commits

Reviewing files that changed from the base of the PR and between 9866ad3 and 876119c.

📒 Files selected for processing (4)
  • CLAUDE.md
  • git.go
  • git_test.go
  • service_extra_test.go
✅ Files skipped from review due to trivial changes (1)
  • CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • git.go

📝 Walkthrough

Walkthrough

Refactors internal error handling to use the core error wrapper (coreerr.E), adds compile-time interface conformance checks, updates dependencies (core/go and core/go-log), expands unit tests for path validation, and adds .core/ to .gitignore. No public API signatures changed.

Changes

Cohort / File(s) Summary
Error handling & interface checks
git.go, service.go
Replaced direct error construction with coreerr.E wrappers; added compile-time interface conformance checks (GitError, core.Startable). Adjusted imports (added core/go-log alias coreerr, introduced goio alias for io in git.go).
Tests — path validation and request handling
git_test.go, service_extra_test.go
Added tests enforcing absolute-path requirement and WorkDir containment across getStatus, validatePath, handleQuery, handleTask and task-related flows. New test TestGetStatus_Bad_RelativePath and many validatePath/handle* cases.
Dependencies
go.mod
Bumped forge.lthn.ai/core/go to v0.3.1; added indirect forge.lthn.ai/core/go-log v0.0.4; replaced github.com/kr/pretty with github.com/kr/text; removed some indirect testing/internal deps.
Repo config & docs
.gitignore, CLAUDE.md
Added .core/ to .gitignore. Minor wording edit in CLAUDE.md test conventions.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[sync] go-git: 2 commits from Forge' directly describes the pull request as an automated sync of 2 commits from Forge, which aligns with the PR objectives stating 'Automated sync from Forge (forge.lthn.ai) to GitHub mirror' and 'Commits: 2'. The title accurately reflects the main purpose of this changeset.

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

📝 Coding Plan
  • Generate coding plan for human review comments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.3)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@Snider
Copy link
Contributor Author

Snider commented Mar 17, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

✅ Actions performed

Review triggered.

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.

@Snider
Copy link
Contributor Author

Snider commented Mar 17, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

✅ Actions performed

Review triggered.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
git.go (1)

288-296: Unusual error construction pattern.

The Error() method creates coreerr.E errors only to immediately call .Error() on them, discarding the structured error object. This adds overhead and provides no benefit over direct string formatting.

Additionally, passing an empty string "" as the first argument (context) defeats the purpose of structured errors. On line 295, the wrapped error e.Err is passed but then immediately converted to a string, losing the error chain.

Consider either:

  1. Returning the coreerr.E error directly from the functions that create GitError, or
  2. Using simple fmt.Sprintf for string formatting here.
♻️ Proposed fix using simple formatting
 func (e *GitError) Error() string {
 	cmd := "git " + strings.Join(e.Args, " ")
 	stderr := strings.TrimSpace(e.Stderr)

 	if stderr != "" {
-		return coreerr.E("", fmt.Sprintf("git command %q failed: %s", cmd, stderr), nil).Error()
+		return fmt.Sprintf("git command %q failed: %s", cmd, stderr)
 	}
-	return coreerr.E("", fmt.Sprintf("git command %q failed", cmd), e.Err).Error()
+	if e.Err != nil {
+		return fmt.Sprintf("git command %q failed: %v", cmd, e.Err)
+	}
+	return fmt.Sprintf("git command %q failed", cmd)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@git.go` around lines 288 - 296, The GitError.Error method currently
constructs coreerr.E and immediately calls .Error(), which is unnecessary and
drops structured context; modify GitError.Error to build and return a plain
formatted string using fmt.Sprintf instead of coreerr.E: construct cmd from
e.Args, trim e.Stderr, and if stderr is non-empty return a string like "git
command %q failed: %s" with cmd and stderr, otherwise return "git command %q
failed: %v" including cmd and e.Err (so the original error text is preserved in
the message); use the GitError fields Args, Stderr, and Err to implement this
change and remove the coreerr.E construction and the empty-string context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@git.go`:
- Line 8: Remove the unnecessary alias import "goio" and update references
accordingly: in the import block replace the aliased import with the standard
"io" package, and change any usage of goio.MultiWriter to io.MultiWriter (the
occurrence in the function that constructs the writer). Ensure no other
references to goio remain and run gofmt/go vet to verify imports are clean.

---

Nitpick comments:
In `@git.go`:
- Around line 288-296: The GitError.Error method currently constructs coreerr.E
and immediately calls .Error(), which is unnecessary and drops structured
context; modify GitError.Error to build and return a plain formatted string
using fmt.Sprintf instead of coreerr.E: construct cmd from e.Args, trim
e.Stderr, and if stderr is non-empty return a string like "git command %q
failed: %s" with cmd and stderr, otherwise return "git command %q failed: %v"
including cmd and e.Err (so the original error text is preserved in the
message); use the GitError fields Args, Stderr, and Err to implement this change
and remove the coreerr.E construction and the empty-string context.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 65244ea3-fbdd-4190-bc98-d010c23ef44b

📥 Commits

Reviewing files that changed from the base of the PR and between 92d6683 and 9866ad3.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • .gitignore
  • git.go
  • go.mod
  • service.go

"context"
"fmt"
"io"
goio "io"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there's a naming conflict requiring the io alias
rg -n '\bio\b' git.go | head -20

Repository: dAppCore/go-git

Length of output: 71


🏁 Script executed:

# View the imports section of git.go to see the full context
head -30 git.go

Repository: dAppCore/go-git

Length of output: 551


🏁 Script executed:

# Check if there are any local definitions or variables named 'io' that would conflict
rg -i 'var\s+io\b|type\s+io\b|const\s+io\b|\bio\s*:=' git.go

Repository: dAppCore/go-git

Length of output: 41


🏁 Script executed:

# Check the actual usage at line 205 where goio is reportedly used
sed -n '200,210p' git.go

Repository: dAppCore/go-git

Length of output: 331


🏁 Script executed:

# Search for any custom 'io' package or type definitions
rg -i 'package\s+io\b|type\s+io\b|const\s+io\b' --type-list

Repository: dAppCore/go-git

Length of output: 448


🏁 Script executed:

# Check if other files use the goio alias
rg 'goio\s+"io"' --type go

Repository: dAppCore/go-git

Length of output: 76


🏁 Script executed:

# Look for any reference to local 'io' that might conflict
fd --type f --extension go | xargs grep -l '\bio\s*\.' | head -10

Repository: dAppCore/go-git

Length of output: 41


🏁 Script executed:

# Search for custom io package or type definitions
find . -name "*.go" -type f | xargs grep -l 'type io\b\|package io\b' | grep -v vendor

Repository: dAppCore/go-git

Length of output: 41


🏁 Script executed:

# Check if there are any comments or context explaining why io alias is needed
rg -B5 'goio\s+"io"' git.go

Repository: dAppCore/go-git

Length of output: 106


🏁 Script executed:

# List all Go files to understand repository structure
git ls-files '*.go' | head -20

Repository: dAppCore/go-git

Length of output: 126


🏁 Script executed:

# Check service.go to see if there's a pattern with aliases
head -30 service.go

Repository: dAppCore/go-git

Length of output: 569


🏁 Script executed:

# Search for any 'io' usage in service.go that might explain the pattern
rg -n '\bio\.' service.go | head -10

Repository: dAppCore/go-git

Length of output: 41


Remove the unnecessary io alias.

The goio alias for the standard io package is not required. There is no naming conflict in the file or codebase that would justify it. Replace goio.MultiWriter with io.MultiWriter at line 205 and remove the alias import.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@git.go` at line 8, Remove the unnecessary alias import "goio" and update
references accordingly: in the import block replace the aliased import with the
standard "io" package, and change any usage of goio.MultiWriter to
io.MultiWriter (the occurrence in the function that constructs the writer).
Ensure no other references to goio remain and run gofmt/go vet to verify imports
are clean.

Snider and others added 2 commits March 17, 2026 13:53
…Error()

GitError.Error() was constructing a coreerr.E error only to immediately
call .Error() on it for the string. Format the string directly instead.

Co-Authored-By: Virgil <virgil@lethean.io>
…fy each against current code, f...' (#3) from agent/fix-coderabbit-findings--verify-each-aga into main
@Snider
Copy link
Contributor Author

Snider commented Mar 17, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

✅ Actions performed

Review triggered.

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.

@Snider Snider merged commit ec61352 into main Mar 17, 2026
1 check passed
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.

1 participant