feat(gitops): pull task-skills on server startup#87
Merged
mhersson merged 2 commits intoMay 12, 2026
Conversation
added 2 commits
May 12, 2026 22:28
- Add `Manager.PullFastForward(ctx)`: runs `git pull --ff-only origin`, reloads go-git in-memory state on success, returns error on divergent history. - Add `dirHasGit(dir)` helper: reports whether `<dir>/.git` exists before NewManager can PlainInit an empty directory. - Add `startupPullTaskSkills(hadGit, remoteURL, mgr)`: best-effort startup pull; logs warn on error, never propagates to the caller. - Wire startup pull into main.go after task-skills git manager init. - Tests: TestPullFastForward_NoRemote/FetchesNewCommits/NonFastForwardReturnsError in manager_test.go; TestDirHasGit_PresentAbsent and TestStartupPullTaskSkills_* in cmd/contextmatrix/main_test.go.
- Add "Server startup pull" section to docs/remote-execution.md cross- referencing the existing "On-trigger pull" runner behaviour. - Note fail-open semantics: warnings logged, startup not blocked. - Clarify the two log lines operators should watch for. - Update README config table: task_skills.git_remote_url now also governs the startup pull, not only clone-on-empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gitops.Manager.PullFastForward(ctx)—git pull --ff-only originwith the existing GitHub-auth env injection and post-pullreloadRepo.cmd/contextmatrix/main.go: iftask_skills.diralready had a.gitentry beforeNewManageropened it ANDtask_skills.git_remote_urlis configured, run the fast-forward pull (60s timeout, fail-open warn log). This brings the server side to startup-parity with the runner, which already pulls before every/trigger.docs/remote-execution.mdwith a "Server startup pull" section and the README task-skills row to note the dual behaviour.Out of scope (deferred to CTXMAX-444): periodic poll, webhook-triggered refresh, on-demand REST refresh.
Test plan
go test ./internal/gitops/...— newTestPullFastForward_*cases pass (no-remote, fetches-new-commits, non-fast-forward returns error).go test ./cmd/contextmatrix/...— newTestDirHasGit_*andTestStartupPullTaskSkills_*cases pass.make test— full suite clean.make lint— golangci-lint clean (0 issues).make build— single-binary build with embedded frontend succeeds..git-backedtask_skills.dirand a configuredtask_skills.git_remote_url; observetask-skills startup pull: oklog line. Fail-open verified by pointing at an unreachable remote — server starts and logstask-skills startup pull failed; serving cached copy.Review notes (recorded in card body)
One Important test-fidelity nit was raised in autonomous review:
TestStartupPullTaskSkills_SkipsWhenGitMissing/_SkipsWhenRemoteEmptypassmgr=niland only assert "no panic," so they don't independently prove each skip guard. The plan called for a real manager wired to a bogus remote so the test would fail loudly if the guard regressed. Acceptable to ship as-is; consider tightening in a follow-up.A few Minor items also recorded (parity warn log when
!hasRemote(),dirHasGiterror classification,.git-as-file test case,file:///URL for the swallows-error test).