Skip to content

fix: make GIT_AUTOCOMMIT work in the Docker image - #26

Merged
thecodacus merged 3 commits into
mainfrom
fix/git-autocommit
Oct 12, 2026
Merged

thecodacus merged 3 commits into
mainfrom
fix/git-autocommit

Conversation

@thecodacus

Copy link
Copy Markdown
Owner

Closes #21

@REASON-labs's diagnosis was exactly right, all three layers of it — no binary, no identity, dubious ownership — each silently masked by the best-effort catch while the README promised history. Their point about why it matters lands hardest: git history is the only undo for a memory that supersedes contradictions in place and dreams autonomously.

Image layer (their suggested fix, applied): apk add git plus system-level committer identity and safe.directory in the runtime stage.

Loudness layer (the startup check they suggested considering): ensureGitReady() runs at startup on both entry points when GIT_AUTOCOMMIT=true —

  • missing binary → clear error and exit 1 (no more silent divergence between requested and actual behavior)
  • bundle not a repo → auto-git init with an --allow-empty first commit (which doubles as a committer-identity probe)
  • ownership problems surface via an early rev-parse instead of on the first mutation

The per-mutation catch stays as a backstop for transient failures, but hard misconfiguration is now impossible to miss.

Verified live both ways: a stripped-PATH server exits with the friendly message; with git present it inits, logs git autocommit: enabled, and git log shows the init commit plus one commit per mutation. 2 new tests (60 total).

The image shipped no git binary, so GIT_AUTOCOMMIT=true silently
committed nothing while mutations kept reporting success — and git
history is the only undo for a memory that dreams autonomously.

- Dockerfile: install git, set a system-level committer identity and
  safe.directory for bind-mounted bundles (the three stacked failures
  from the report, covered at the image layer)
- KnowledgeBase.ensureGitReady(): startup readiness check — friendly
  error when the binary is missing (simple-git reports installed:false
  rather than throwing), auto-init of non-repo bundles with an
  --allow-empty first commit (also proves committer identity works,
  independent of staging quirks), and an early rev-parse to surface
  ownership problems before the first mutation
- server + stdio entry points fail loudly at startup instead of
  discovering the problem commit by commit
- 2 new tests (60 total)
Fresh containers and CI runners have no git identity, so the init
commit failed there. When user.email doesn't resolve, set a
repo-local understory identity — same as the image does at system
scope. Verified with GIT_CONFIG_GLOBAL/SYSTEM nulled.
@coderabbitai

coderabbitai Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c401a4ec-3f50-4d48-831c-6967d47fcced

📥 Commits

Reviewing files that changed from the base of the PR and between f6c3423 and ad2ece0.


📒 Files selected for processing (6)
  • .env.example
  • Dockerfile
  • packages/core/src/okf/knowledge-base.ts
  • packages/core/test/okf.test.ts
  • packages/server/src/index.ts
  • packages/server/src/mcp/stdio.ts

 _______________________________
< When in doubt, review it out. >
 -------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@alphaecho35

Copy link
Copy Markdown

Confirmed on the published image. Our deployment (Unraid, ghcr.io-style node:22-alpine runtime) logged git autocommit failed: Error: spawn git ENOENT on every librarian mutation for days — bundle writes landed but nothing ever committed, and understory_add callers had no signal.

Workaround we used: built a derived image (FROM node:22-alpine + apk add --no-cache git). Mutation + autocommit verified working immediately (git log shows librarian commits again). +1 for baking apk add git into the runtime stage — happy to test PR #26 if useful.

@thecodacus
thecodacus merged commit 0a5885f into main Oct 12, 2026
2 of 3 checks passed
@thecodacus
thecodacus deleted the fix/git-autocommit branch October 12, 2026 20:35
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.

'GIT_AUTOCOMMIT=true' silently does nothing in the Docker image — no git binary

2 participants