Skip to content

feat(gitops): pull task-skills on server startup#87

Merged
mhersson merged 2 commits into
mainfrom
ctxmax-479/git-pull-task-skills-on-server-startup
May 12, 2026
Merged

feat(gitops): pull task-skills on server startup#87
mhersson merged 2 commits into
mainfrom
ctxmax-479/git-pull-task-skills-on-server-startup

Conversation

@contextmatrix-runner
Copy link
Copy Markdown
Contributor

Summary

  • Add gitops.Manager.PullFastForward(ctx)git pull --ff-only origin with the existing GitHub-auth env injection and post-pull reloadRepo.
  • Wire a one-shot startup pull for the task-skills repo in cmd/contextmatrix/main.go: if task_skills.dir already had a .git entry before NewManager opened it AND task_skills.git_remote_url is 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.
  • Update docs/remote-execution.md with 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/... — new TestPullFastForward_* cases pass (no-remote, fetches-new-commits, non-fast-forward returns error).
  • go test ./cmd/contextmatrix/... — new TestDirHasGit_* and TestStartupPullTaskSkills_* cases pass.
  • make test — full suite clean.
  • make lint — golangci-lint clean (0 issues).
  • make build — single-binary build with embedded frontend succeeds.
  • Manual smoke (operator): start the server with a .git-backed task_skills.dir and a configured task_skills.git_remote_url; observe task-skills startup pull: ok log line. Fail-open verified by pointing at an unreachable remote — server starts and logs task-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 / _SkipsWhenRemoteEmpty pass mgr=nil and 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(), dirHasGit error classification, .git-as-file test case, file:/// URL for the swallows-error test).

ContextMatrix Runner 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.
@mhersson mhersson merged commit 390fd7f into main May 12, 2026
3 checks passed
@mhersson mhersson deleted the ctxmax-479/git-pull-task-skills-on-server-startup branch May 12, 2026 22:43
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