fix(zfc): remove strings.Contains conflict detection from Go code
hq-hcil1: Remove deprecated HasConflict/HasAuthFailure/IsNotARepo/HasRebaseConflict methods that violated ZFC by having Go code decide error types based on stderr parsing. Changes: - Remove deprecated helper methods from GitError and SwarmGitError - Export GetConflictingFiles() which uses git porcelain output (diff --diff-filter=U) - Update CheckConflicts(), engineer.go, and integration.go to use GetConflictingFiles() - Update tests to verify raw stderr is available for agent observation ZFC principle: Go code transports raw output to agents; agents observe and decide. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
131dac91c8
commit
f7d497ba07
@@ -31,14 +31,6 @@ func (e *SwarmGitError) Error() string {
|
||||
return fmt.Sprintf("%s: %v", e.Command, e.Err)
|
||||
}
|
||||
|
||||
// HasConflict returns true if the error output indicates a merge conflict.
|
||||
// Deprecated: Agents should observe Stderr directly (ZFC principle).
|
||||
func (e *SwarmGitError) HasConflict() bool {
|
||||
return strings.Contains(e.Stderr, "CONFLICT") ||
|
||||
strings.Contains(e.Stderr, "Merge conflict") ||
|
||||
strings.Contains(e.Stdout, "CONFLICT")
|
||||
}
|
||||
|
||||
// CreateIntegrationBranch creates the integration branch for a swarm.
|
||||
// The branch is created from the swarm's BaseCommit and pushed to origin.
|
||||
func (m *Manager) CreateIntegrationBranch(swarmID string) error {
|
||||
@@ -92,9 +84,11 @@ func (m *Manager) MergeToIntegration(swarmID, workerBranch string) error {
|
||||
fmt.Sprintf("Merge %s into %s", workerBranch, swarm.Integration),
|
||||
workerBranch)
|
||||
if err != nil {
|
||||
// ZFC: Check for conflict via SwarmGitError method
|
||||
if gitErr, ok := err.(*SwarmGitError); ok && gitErr.HasConflict() {
|
||||
return gitErr // Return the error with raw output for observation
|
||||
// ZFC: Use git's porcelain output to detect conflicts instead of parsing stderr.
|
||||
conflicts, conflictErr := m.getConflictingFiles()
|
||||
if conflictErr == nil && len(conflicts) > 0 {
|
||||
// Return the original error with raw output for observation
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("merging: %w", err)
|
||||
}
|
||||
@@ -127,9 +121,11 @@ func (m *Manager) LandToMain(swarmID string) error {
|
||||
fmt.Sprintf("Land swarm %s", swarmID),
|
||||
swarm.Integration)
|
||||
if err != nil {
|
||||
// ZFC: Check for conflict via SwarmGitError method
|
||||
if gitErr, ok := err.(*SwarmGitError); ok && gitErr.HasConflict() {
|
||||
return gitErr // Return the error with raw output for observation
|
||||
// ZFC: Use git's porcelain output to detect conflicts instead of parsing stderr.
|
||||
conflicts, conflictErr := m.getConflictingFiles()
|
||||
if conflictErr == nil && len(conflicts) > 0 {
|
||||
// Return the original error with raw output for observation
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("merging to %s: %w", swarm.TargetBranch, err)
|
||||
}
|
||||
@@ -207,6 +203,34 @@ func (m *Manager) getCurrentBranch() (string, error) {
|
||||
return strings.TrimSpace(stdout.String()), nil
|
||||
}
|
||||
|
||||
// getConflictingFiles returns the list of files with merge conflicts.
|
||||
// ZFC: Uses git's porcelain output (diff --diff-filter=U) instead of parsing stderr.
|
||||
func (m *Manager) getConflictingFiles() ([]string, error) {
|
||||
cmd := exec.Command("git", "diff", "--name-only", "--diff-filter=U")
|
||||
cmd.Dir = m.gitDir
|
||||
|
||||
var stdout bytes.Buffer
|
||||
cmd.Stdout = &stdout
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := strings.TrimSpace(stdout.String())
|
||||
if out == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
files := strings.Split(out, "\n")
|
||||
var result []string
|
||||
for _, f := range files {
|
||||
if f != "" {
|
||||
result = append(result, f)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// gitRun executes a git command.
|
||||
// ZFC: Returns SwarmGitError with raw output for agent observation.
|
||||
func (m *Manager) gitRun(args ...string) error {
|
||||
|
||||
Reference in New Issue
Block a user