Skip to content

feat: improvements batch 1 — doctor command, conflict-ahead status, better API errors, auto-stash pull-merge, version fix#48

Merged
rgonek merged 6 commits intomainfrom
feature/improvements-batch-1
Mar 1, 2026
Merged

feat: improvements batch 1 — doctor command, conflict-ahead status, better API errors, auto-stash pull-merge, version fix#48
rgonek merged 6 commits intomainfrom
feature/improvements-batch-1

Conversation

@rgonek
Copy link
Owner

@rgonek rgonek commented Feb 27, 2026

Summary

Five targeted improvements to conf CLI reliability and observability:

1. Auto-Stash for pull-merge (cmd/push.go)

When push --on-conflict=pull-merge triggers an automatic pull, flagPullDiscardLocal is temporarily set to true so remote deletions are applied cleanly instead of being skipped with a warning.

2. Version Fix After Stash Restore (cmd/pull.go)

After a pull that stashed local changes, if the stash restore reintroduces an old version frontmatter value, fixPulledVersionsAfterStashRestore() patches each affected file on disk to match the version that was committed by the pull (read from git show HEAD:<path>). This prevents a stale version from causing an immediate conflict on the next push.

3. ConflictAhead in conf status (cmd/status.go)

StatusReport now includes a ConflictAhead []string field — pages that are both locally modified and ahead on the remote. These are the highest-priority conflicts. Printed as a dedicated Conflict ahead section in conf status output.

4. conf doctor command (cmd/doctor.go)

New command for consistency checking between .confluence-state.json, the actual filesystem, and page id frontmatter.

Detects:

  • Files in state that no longer exist on disk
  • State entries with empty page IDs
  • id frontmatter that doesn't match the state index
  • Git conflict markers (<<<<<<<) in file bodies
  • Files with an id in frontmatter that are not tracked in state

--repair flag auto-fixes: removes stale/empty state entries, adds untracked IDs to state. Non-repairable issues (id-mismatch, conflict markers) are listed for manual resolution.

5. Better API Error Messages (internal/confluence/client.go)

  • confluenceStatusHint(code int) — actionable hints for 401, 403, 409, 422, 429, 503, 413
  • mapConfluenceErrorCode(code string) — enriches known Confluence error codes (INVALID_IMAGE, MACRO_NOT_FOUND, TITLE_ALREADY_EXISTS, PERMISSION_DENIED, CONTENT_STALE, PARENT_PAGE_NOT_FOUND, INVALID_REQUEST_PARAMETER)
  • APIError.Error() falls back to confluenceStatusHint before the generic http.StatusText
  • decodeAPIErrorMessage checks code/errorKey/status fields and runs message strings through the mapper

Tests

  • cmd/doctor_test.go — 11 new tests covering all detection and repair cases
  • cmd/status_test.go — 5 new TestComputeConflictAhead sub-cases
  • cmd/pull_test.go — 2 new tests for fixPulledVersionsAfterStashRestore
  • internal/confluence/client_test.go — 5 new tests for error hint/mapping functions

All tests pass (go test ./...), linter clean (go vet ./...).

…uto-stash pull-merge, and version fix after stash restore

- push: auto-set flagPullDiscardLocal=true during pull-merge conflict path so remote deletions apply cleanly
- pull: fix version frontmatter after stash restore to reflect remote-pulled version, not pre-pull local version
- status: add ConflictAhead field and section for pages that are both locally modified and remote-ahead
- doctor: new command to check state/filesystem/frontmatter consistency with --repair flag
- confluence client: add confluenceStatusHint() and mapConfluenceErrorCode() for richer API error messages
- Introduced `PushRemote` interface defining required operations for push orchestration.
- Implemented `fakeFolderPushRemote` and `rollbackPushRemote` for testing purposes.
- Added methods for managing pages, folders, content statuses, and labels in the fake implementations.
- Created `push_types.go` to encapsulate push-related types and constants.
- Defined structures for push options, commit plans, diagnostics, and rollback tracking.
- Implemented error handling for remote-ahead conflicts with `PushConflictError`.
Split `internal/sync/pull.go`, `cmd/pull.go`, `cmd/push.go`, and their corresponding test files to adhere to a max-size of 800 lines per file. All extracted logic retains original package structure and boundaries with strictly zero behavior changes.
Extracted into smaller focused files like stash management, state/context processing, asset mapping, and conflict policy.
1. Split remaining files nearing the 800-line mark:
  - split `internal/sync/push_test.go`
  - split `cmd/diff.go`
  - split `internal/confluence/client_pages.go`
2. Implemented test coverage extension plan (agents/plans/test_coverage_extension.md):
  - Increased `internal/git` coverage to >70%
  - Increased `cmd` coverage to >75% by heavily extending CLI test suites for `clean`, `prune`, `doctor`, `validate`, `automation`, `progress`, and `dry_run_remote`.
  - Updated CI gates in `tools/coveragecheck` to lock in the new >70% and >75% test coverage requirements.
@rgonek rgonek merged commit be31918 into main Mar 1, 2026
2 checks 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