From 16a9de9511659f2d3c40989641ed855e79e4b6aa Mon Sep 17 00:00:00 2001 From: "J. Kirby Ross" Date: Sun, 28 Sep 2025 23:28:13 -0700 Subject: [PATCH 1/8] refactor(core): rely on gm oid helpers --- core/src/domain/cache/edge_map.c | 2 - core/src/hooks/augment.c | 2 - core/src/journal/writer.c | 9 +- ...03f4e3539b1d8fc73b641e94b0a420f2e592a14.md | 134 --- ...402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c.md | 987 ------------------ ...add14fcdabafff59a99ea484d691140afdb68c3.md | 337 ------ ...b7b5f565ef23d959b126b0df50e0a3992c52da2.md | 130 --- ...2dab217893b6ee8bb8dcdca2217f9900a06b76f.md | 649 ------------ ...a32c6a810ebf632709cec6c928381c9c47fdee9.md | 490 --------- ...22c22398de39c4ab93e1c747b1122d2241eed22.md | 654 ------------ ...11ee830d5615e5582114d625a52283760d61767.md | 837 --------------- 11 files changed, 6 insertions(+), 4225 deletions(-) delete mode 100644 docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md delete mode 100644 docs/code-reviews/PR172/5402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c.md delete mode 100644 docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md delete mode 100644 docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md delete mode 100644 docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md delete mode 100644 docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md delete mode 100644 docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md delete mode 100644 docs/code-reviews/PR172/d11ee830d5615e5582114d625a52283760d61767.md diff --git a/core/src/domain/cache/edge_map.c b/core/src/domain/cache/edge_map.c index 20794f73..de3ee88a 100644 --- a/core/src/domain/cache/edge_map.c +++ b/core/src/domain/cache/edge_map.c @@ -3,8 +3,6 @@ #include "gitmind/cache/internal/edge_map.h" -#include - #include #include diff --git a/core/src/hooks/augment.c b/core/src/hooks/augment.c index 3c8676eb..772b86b6 100644 --- a/core/src/hooks/augment.c +++ b/core/src/hooks/augment.c @@ -7,8 +7,6 @@ #include #include -#include - #include "gitmind/constants.h" #include "gitmind/constants_internal.h" #include "gitmind/error.h" diff --git a/core/src/journal/writer.c b/core/src/journal/writer.c index 96879d96..cfa679dc 100644 --- a/core/src/journal/writer.c +++ b/core/src/journal/writer.c @@ -11,8 +11,7 @@ #include "gitmind/edge.h" #include "gitmind/edge_attributed.h" #include "gitmind/security/memory.h" - -#include +#include "gitmind/util/oid.h" #include #include @@ -114,7 +113,11 @@ static int collect_parent_tip(const gm_oid_t *commit_oid, void *userdata) { ctx->found = true; ctx->tip.has_target = true; ctx->tip.oid = *commit_oid; - git_oid_tostr(ctx->tip.oid_hex, sizeof(ctx->tip.oid_hex), commit_oid); + if (gm_oid_to_hex(commit_oid, ctx->tip.oid_hex, + sizeof(ctx->tip.oid_hex)) != GM_OK) { + gm_memset_safe(ctx->tip.oid_hex, sizeof(ctx->tip.oid_hex), 0, + sizeof(ctx->tip.oid_hex)); + } } return GM_OK; } diff --git a/docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md b/docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md deleted file mode 100644 index d8a2de7c..00000000 --- a/docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md +++ /dev/null @@ -1,134 +0,0 @@ ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `203f4e3539b1d8fc73b641e94b0a420f2e592a14` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between b0a37d21bfba6f6796d42fb32dcadf668d013ea2 and 203f4e3539b1d8fc73b641e94b0a420f2e592a14. -> ->
-> ->
-> 📒 Files selected for processing (33) -> -> * `AGENTS.md` (1 hunks) -> * `core/include/gitmind/cache.h` (1 hunks) -> * `core/include/gitmind/edge/internal/blob_identity.h` (1 hunks) -> * `core/include/gitmind/util/oid.h` (1 hunks) -> * `core/src/app/cache/cache_rebuild_service.c` (3 hunks) -> * `core/src/cache/query.c` (3 hunks) -> * `core/src/edge/attributed.c` (2 hunks) -> * `core/src/edge/edge.c` (2 hunks) -> * `core/src/edge/internal/blob_identity.c` (1 hunks) -> * `core/src/fs/path_utils.c` (3 hunks) -> * `core/src/util/oid.c` (1 hunks) -> * `core/tests/fakes/git/fake_git_repository_port.c` (2 hunks) -> * `docs/code-reviews/CLAUDE.md` (0 hunks) -> * `docs/code-reviews/PR169/e4f3f906eb454cb103eb8cc6899df8dfbf6e2349.md` (0 hunks) -> * `docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md` (0 hunks) -> * `docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/1d234c5614f96272eca5e9607d84b3655080546b_feat-cli-safety-e2e_166_valgrind-suppression-link.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_angle-includes.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_consumed-length.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_e2e-refactor.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_markdownlint.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_replace-macros-with-literals.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_umbrella-safety-include.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/5965e14_feat-changelog-and-sweep-4_PR169_md-verify-alias.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/5965e14_feat-changelog-and-sweep-4_PR169_phony-ordering.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/5965e14_feat-changelog-and-sweep-4_PR169_pre-push-changelog-variants.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/608bc03_main_cstd-c23-only.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/608bc03_main_deprec-macros-augment.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR164_detached-head-behavior.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR165_move-test-prototypes-private.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR165_reserve-extra-byte.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR166_missing-umbrella-apis.md` (0 hunks) -> * `meson.build` (2 hunks) -> ->
-> -> ```ascii -> ________________________________________________________________________________________________________________________________ -> < Test state coverage, not code coverage. Identify and test significant program states. Just testing lines of code isn't enough. > -> -------------------------------------------------------------------------------------------------------------------------------- -> \ -> \ \ -> \ /\ -> ( ) -> .( o ). -> ``` - - - - - - -
-✨ Finishing touches - -- [ ] 📝 Generate Docstrings -
-🧪 Generate unit tests - -- [ ] Create PR with unit tests -- [ ] Post copyable unit tests in a comment -- [ ] Commit unit tests in branch `chore/code-rabbit-cleanup` - -
- -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -> [!note]- **Accepted** -> Title now matches the H1 and the required `## Table of Contents` section has been added beneath it. diff --git a/docs/code-reviews/PR172/5402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c.md b/docs/code-reviews/PR172/5402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c.md deleted file mode 100644 index 104e8cf9..00000000 --- a/docs/code-reviews/PR172/5402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c.md +++ /dev/null @@ -1,987 +0,0 @@ ---- -title: 5402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c.md -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-29 | CodeRabbit (and reviewers) | `5402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Fix legacy buffer padding description.** - -The implementation zero-fills the legacy SHA buffer only when `GM_OID_RAWSZ` is *smaller* than `GM_SHA1_SIZE`. The doc currently says “exceeds,” so the guidance is inverted. Please update the phrasing so callers understand when padding happens. - -```diff -- * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -- * exceeds `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -+ * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -+ * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - * On success, both the preferred OID (`out_oid`) and the legacy SHA-1 buffer - * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` - * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain - * deterministic contents. Callers must provide non-null pointers. -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/include/gitmind/edge/internal/blob_identity.h around lines 20 to 23, the -comment incorrectly states that the legacy SHA buffer is zero-padded when -GM_OID_RAWSZ "exceeds" GM_SHA1_SIZE; update the phrasing to say that the legacy -buffer is zero-padded when GM_OID_RAWSZ is smaller than GM_SHA1_SIZE (i.e., when -the preferred OID raw size is less than the legacy SHA-1 size), so callers know -padding happens to fill the remainder of the legacy buffer to GM_SHA1_SIZE; -ensure callers still know to provide non-null pointers. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101775 - -{response} - -### core/src/util/oid.c:44 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard against overflow before sizing the hex buffer** - -`required = (len * 2U) + 1U` can overflow `size_t` for large inputs, which lets the length check pass with a wrapped value and we then scribble past `out` while the loop iterates `len` times. Please short-circuit when `len` exceeds the safe range before doing the multiply. - - - -```diff -@@ -- const size_t required = (len * 2U) + 1U; -+ if (len > (SIZE_MAX - 1U) / 2U) { -+ gm_memset_safe(out, out_size, 0, out_size); -+ return GM_ERR_INVALID_ARGUMENT; -+ } -+ -+ const size_t required = (len * 2U) + 1U; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (len > (SIZE_MAX - 1U) / 2U) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_INVALID_ARGUMENT; - } - - const size_t required = (len * 2U) + 1U; - if (out_size < required) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_BUFFER_TOO_SMALL; - } - - for (size_t i = 0; i < len; ++i) { - unsigned byte = bytes[i]; - out[i * 2U] = KHexDigits[(byte >> KNibbleBits) & KNibbleMask]; - out[(i * 2U) + 1U] = KHexDigits[byte & KNibbleMask]; - } - out[len * 2U] = '\0'; -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/util/oid.c around lines 27-38, the computed required = (len * 2U) + -1U can overflow size_t for large len; before performing the multiply, check that -len does not exceed (SIZE_MAX - 1) / 2 (or equivalent safe_max) and if it does, -zero the output buffer via gm_memset_safe and return GM_ERR_BUFFER_TOO_SMALL (or -an appropriate error). After that guard, compute required normally, perform the -existing out_size check and proceed with the hex conversion. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101784 - -{response} - -### docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md:22 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required Table of Contents and title alignment** - -Docs under `docs/**` must include a `## Table of Contents` section and keep the front-matter `title` in sync with the H1. This file omits the TOC and the front-matter title (`203f4e3539b1d8fc73b641e94b0a420f2e592a14.md`) does not match the H1 (`Code Review Feedback`). Please add the missing TOC heading and align the title/H1 pair. As per coding guidelines. - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md lines -1-18, the front-matter title does not match the H1 and the required "## Table of -Contents" section is missing; update the YAML front-matter title to exactly -"Code Review Feedback" to match the H1 and insert a "## Table of Contents" -heading (with any preferred TOC entries or a placeholder) immediately after the -H1 so the document follows the docs/** guidelines. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101790 - -{response} - -### .github/workflows/review-artifact-cleanup.yml:48 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix checkout to track a branch before pushing** - -`actions/checkout` on a `pull_request` event leaves the repo in a detached HEAD at `refs/pull//merge`. The later `git push` step then fails with “You are not currently on a branch,” so the cleanup commit never lands. Check out the base branch (or push `HEAD` explicitly) before removing files. - - -```diff - - name: Checkout repository - uses: actions/checkout@v4 - with: -- fetch-depth: 0 -+ fetch-depth: 0 -+ ref: ${{ github.event.pull_request.base.ref }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.base.ref }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/review-artifact-cleanup.yml lines 18-47: the job checks out -the PR merge ref (detached HEAD) so later git commit/push fails; change the -checkout to track the target branch before making the cleanup commit. Either set -actions/checkout to the pull_request base ref (use ref: ${{ -github.event.pull_request.base.ref }} and fetch-depth: 0) or, immediately after -the existing checkout, fetch from origin and create/checkout a local branch that -tracks the PR base branch (so commits are made on a branch and can be pushed); -ensure the branch is tracking origin/ before the git commit and git push -steps. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144548 - -{response} - -### docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md:27 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix doc front matter/title alignment and add required TOC** - -`docs/**` files must keep the front-matter `title` identical to the H1 and include a `## Table of Contents` section immediately after the H1. This file’s title still uses the SHA filename and the TOC is missing. Update the title to “Code Review Feedback” and add the TOC block so the doc complies with the repo guidelines. - -```diff - --- --title: 5add14fcdabafff59a99ea484d691140afdb68c3.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `5add14fcdabafff59a99ea484d691140afdb68c3` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md around -lines 1 to 16, the front-matter title is the SHA and the document is missing a -required Table of Contents; update the YAML front-matter title value to "Code -Review Feedback" so it matches the H1, and immediately after the H1 insert a "## -Table of Contents" section (with the standard TOC entries used across docs/) so -the file complies with repo guidelines. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144568 - -{response} - -### .github/workflows/coderabbit-status.yml:27 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix: install Python dependency used by the script (requests).** - -The workflow runs a script that imports requests, but there’s no install step. This will fail with ModuleNotFoundError in CI. - -Apply this diff to add an install step: - -```diff - - name: Set up Python - uses: actions/setup-python@v5 - with: -- python-version: '3.x' -+ python-version: '3.x' -+ - name: Install dependencies -+ run: | -+ python -m pip install --upgrade pip -+ python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/coderabbit-status.yml around lines 16 to 23: the CI job sets -up Python but never installs the requests dependency required by the script, -causing ModuleNotFoundError; add a step after "Set up Python" to install the -dependency (e.g., run pip install requests --upgrade or pip3 install requests) -so the script can import requests successfully during the workflow run. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271905 - -{response} - -### docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md:20 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Align title with H1 and add the required TOC** - -Docs under `docs/**` have to mirror the H1 in the front matter `title` and include an explicit `## Table of Contents` immediately after the H1. Please update both so this artifact stays compliant. As per coding guidelines - -```diff - --- --title: 8a32c6a810ebf632709cec6c928381c9c47fdee9.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md lines -2-20, the front-matter title must match the document's H1 and you must insert an -explicit "## Table of Contents" immediately after the H1; update the YAML -front-matter title to exactly match the H1 text and add a "## Table of Contents" -header directly below the H1 (populate with relevant links or placeholders) so -the file conforms to the docs guideline. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271909 - -{response} - -### docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Doc still violates the title/TOC requirement.** - -The YAML `title` must match the H1 and we need a “## Table of Contents” section right after the H1. Please update both to satisfy the repository doc rules. - - -```diff - --- --title: 82dab217893b6ee8bb8dcdca2217f9900a06b76f.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` -As per coding guidelines. - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive ---- - - # Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `82dab217893b6ee8bb8dcdca2217f9900a06b76f` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md around -lines 1 to 23, the YAML front-matter title does not match the H1 and the -document is missing a “## Table of Contents” section immediately after the H1; -update the YAML title to exactly match the H1 text, add a “## Table of Contents” -heading right after the H1 (with any required TOC entries or a placeholder), and -ensure the TOC appears directly below the H1 to conform to repository doc rules. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385399829 - -{response} - -### docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md:16 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required TOC and align title with H1.** - -Docs under `docs/**` must keep the front-matter `title` identical to the H1 and include a `## Table of Contents` immediately after the H1. This file still uses the SHA for `title` and omits the TOC, so it violates the documented style requirements. Please update the title to match the H1 and add the missing TOC block. As per coding guidelines. - -Apply this diff to fix both issues: - -```diff ---- --title: b22c22398de39c4ab93e1c747b1122d2241eed22.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `b22c22398de39c4ab93e1c747b1122d2241eed22` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md around -lines 2 to 16, the front-matter title is set to the SHA and the document is -missing a "## Table of Contents" immediately after the H1; update the YAML -front-matter title to exactly match the file's H1 text and insert a "## Table of -Contents" block directly after the H1 heading so the front-matter title and H1 -are identical and the TOC appears in the required location. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385399838 - -{response} - -### docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md:24 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Doc front matter + headings violate required structure.** The doc rules demand the front‑matter `title` match the H1, and a `## Table of Contents` section is mandatory. Here, the title is the SHA string while the H1 is “Code Review Feedback”, and there’s no TOC. Please align the title with the H1 and add the TOC before the remaining sections. As per coding guidelines - -```diff --title: 7b7b5f565ef23d959b126b0df50e0a3992c52da2.md -+title: Code Review Feedback -@@ --# Code Review Feedback -+# Code Review Feedback -+ -+## Table of Contents -+ -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -+- [General comment — coderabbitai\[\bot\]](#general-comment--coderabbitai-bot) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents - -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -- [General comment — coderabbitai[bot]](#general-comment--coderabbitai-bot) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `7b7b5f565ef23d959b126b0df50e0a3992c52da2` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### General comment — coderabbitai[bot] - -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md lines -1-24, the front-matter title does not match the H1 and the required "## Table of -Contents" section is missing; update the YAML front-matter title to exactly -match the H1 "Code Review Feedback" (remove the SHA string), and insert a "## -Table of Contents" header immediately after the H1 with appropriate links (e.g., -to CODE REVIEW FEEDBACK and any subsections) so the document follows the -required structure. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2386258061 - -{response} - -### docs/code-reviews/PR172/d11ee830d5615e5582114d625a52283760d61767.md:11 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore doc title alignment and required TOC section.** - -Front matter `title` still uses the SHA instead of matching the H1 (`Code Review Feedback`), and the mandatory `## Table of Contents` block after the H1 is missing. Both violate the docs/ guidelines. Please align the title and add the TOC. As per coding guidelines - -```diff - --- --title: d11ee830d5615e5582114d625a52283760d61767.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/d11ee830d5615e5582114d625a52283760d61767.md around -lines 2 to 11, the front-matter title still contains the commit SHA and the -mandatory "## Table of Contents" section is missing; update the front-matter -title to "Code Review Feedback" to match the H1 and add a "## Table of Contents" -heading immediately after the H1 (populate entries if required by guidelines) so -the file conforms to the docs/ guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2386258065 - -{response} - -### General comment — coderabbitai[bot] - -```text - - - -## Walkthrough -Adds OID hex utilities and a blob-identity resolver, integrates them into edge/cache/query paths, hardens path parsing and test fakes, adds new sources to the build, updates worksheet/CI tooling and many review-doc artifacts; exposes two OID hex APIs and one blob-identity helper. - -## Changes -| Cohort / File(s) | Summary | -|---|---| -| **OID hex utilities (new API)**
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | Add `gm_bytes_to_hex` and `gm_oid_to_hex` declarations/implementations with input validation, buffer-size checks, safe zeroing, and NUL termination. | -| **Adopt OID hex helpers**
`core/src/app/cache/cache_rebuild_service.c`, `core/src/cache/query.c` | Replace direct git2 oid-to-hex formatting with `gm_oid_to_hex` / `gm_bytes_to_hex`; add buffer initialization and error handling; include new util header. | -| **Blob identity resolver (new helper) + integration**
`core/include/gitmind/edge/internal/blob_identity.h`, `core/src/edge/internal/blob_identity.c`, `core/src/edge/edge.c`, `core/src/edge/attributed.c` | Add `gm_edge_resolve_blob_identity`; centralize port-backed blob resolution producing `out_oid` and legacy SHA buffer (zero-padded), replace prior in-file resolve logic and propagate port errors. | -| **Filesystem path utils hardening**
`core/src/fs/path_utils.c` | Add dynamic `max_segments` param, update callers, and guard segment emission against output-buffer overruns with explicit path-too-long reporting. | -| **Fake git repo port safety**
`core/tests/fakes/git/fake_git_repository_port.c` | Check `gm_strcpy_safe` return values; clear destinations and return `GM_ERR_BUFFER_TOO_SMALL` when copies exceed buffers. | -| **Cache header comment move**
`core/include/gitmind/cache.h` | Relocated a struct-tail comment; no layout/type/API changes. | -| **Build configuration**
`meson.build` | Add `core/src/edge/internal/blob_identity.c` and `core/src/util/oid.c` to the build sources. | -| **Worksheet checker tweak**
`tools/review/check_worksheets.py` | Treat deleted worksheet files as acceptable by returning an empty problems list on FileNotFoundError. | -| **Coderabbit status tooling**
`tools/review/check_coderabbit_threads.py`, `.github/workflows/coderabbit-status.yml` | Add script to detect unresolved CodeRabbit review threads via GitHub GraphQL and a workflow to run it on PR events. | -| **Review artifact cleanup workflow**
`.github/workflows/review-artifact-cleanup.yml` | New workflow to remove per-PR review-doc artifacts on merged PRs and commit the cleanup if changes exist. | -| **Docs & review artifacts**
`docs/code-reviews/*`, `docs/code-reviews/PR172/*`, `AGENTS.md` | Remove multiple archived/rejected review docs, add PR172 artifacts, and append a 2025-09-28 AGENTS.md entry. | -| **Misc CI workflow metadata**
`.github/workflows/auto-seed-review.yml` | Update commit author metadata and seed commit messages in workflow steps. | - -## Sequence Diagram(s) -```mermaid -sequenceDiagram - autonumber - actor EdgeCreator as Edge Creator - participant BI as gm_edge_resolve_blob_identity - participant Port as Git Repository Port - - EdgeCreator->>BI: resolve_blob_identity(ctx, path, out_oid, legacy_sha) - BI->>Port: gm_git_repository_port_resolve_blob_at_head(path) - Port-->>BI: oid_bytes / error - - alt port success - BI->>BI: copy min(GM_OID_RAWSZ, GM_SHA1_SIZE) → legacy_sha - BI->>BI: zero-pad remainder if copy_len < GM_SHA1_SIZE - BI-->>EdgeCreator: GM_OK (out_oid, legacy_sha) - else port error - BI->>BI: zero legacy_sha - BI-->>EdgeCreator: error (propagate) - end -``` - -## Estimated code review effort -🎯 4 (Complex) | ⏱️ ~50 minutes - -## Possibly related PRs -- neuroglyph/git-mind#165 — Continues the OID-first migration and touches related edge/cache OID handling and helpers referenced by this change. -- neuroglyph/git-mind#169 — Overlaps OID/hex handling and edge/ref construction refactors that this PR integrates or replaces. -- neuroglyph/git-mind#171 — Related to repository-port and blob-resolution changes; likely shares design and port calls with the new resolver. - -## Poem -> I nibble bytes and spin them hex, -> I hop through blobs and mend the specs, -> I guard the paths and tidy docs, -> I patch the tests and hush the clocks, -> A rabbit’s hop, a tiny fix—🐇✨ - - - - - - -## Pre-merge checks and finishing touches -
-❌ Failed checks (3 warnings) - -| Check name | Status | Explanation | Resolution | -| :----------------: | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Title Check | ⚠️ Warning | The title “chore/code rabbit cleanup” is too vague and does not convey the primary objectives of the pull request, which include substantial refactoring across blob identity resolution, OID utilities, filesystem path handling, testing ports, and CI workflows. It fails to summarize the main architectural changes or key new public APIs and instead uses generic “chore” language that obscures scope. | Rewrite the title to clearly reflect the primary architectural changes, for example “refactor: add repository port blob identity resolver and OID hex utilities”. Make sure it concisely conveys the high-level scope of the refactor rather than generic chores. Use imperative, title-case phrasing that highlights the main change. | -| Description Check | ⚠️ Warning | The pull request description does not follow the repository’s required template and instead lists individual commits without providing the structured Summary, Change Areas, Risk, or Code Review Guidance sections. As a result, reviewers cannot quickly understand the high-level purpose, affected areas, risk level, or guidance as expected by the template. | Restructure the description to follow the required template by adding a “## Summary” section that briefly explains the motivation and key changes. Then mark the affected areas under “## Change Areas” with the relevant checkboxes and specify the level of risk under “## Risk”. Finally, include a “## Code Review Guidance” section with top risks, proposed fix-it blocks, and pattern references as outlined in the template. | -| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run `@coderabbitai generate docstrings` to improve docstring coverage. | - -
- - - - - -
-✨ Finishing touches - -- [ ] 📝 Generate Docstrings -
-🧪 Generate unit tests - -- [ ] Create PR with unit tests -- [ ] Post copyable unit tests in a comment -- [ ] Commit unit tests in branch `chore/code-rabbit-cleanup` - -
- -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - - - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -{response} - diff --git a/docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md b/docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md deleted file mode 100644 index f244598c..00000000 --- a/docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md +++ /dev/null @@ -1,337 +0,0 @@ ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `5add14fcdabafff59a99ea484d691140afdb68c3` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -> [!WARNING] -> **Baroque Blockers Detected.** The maestro reports this branch currently clashes with `main`. Before the next rehearsal, fetch the latest score and resolve the merge dissonance so BunBun can keep the CI metronome steady. - -## Overture from P.R. PhiedBach - -Guten abend, dear contributor. I, P.R. PhiedBach — quill in hand, vape haze swirling, Daft Punk on loop — have prepared this worksheet so our ensemble may keep time together. Think of the comments that follow as movements in a fugue: CodeRabbit’s precision on first chair, my quill scribbling counterpoint. Address each motif, reply in kind, and together we shall arrive at a triumphant LGTM. - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Fix legacy buffer padding description.** - -The implementation zero-fills the legacy SHA buffer only when `GM_OID_RAWSZ` is *smaller* than `GM_SHA1_SIZE`. The doc currently says “exceeds,” so the guidance is inverted. Please update the phrasing so callers understand when padding happens. - -```diff -- * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -- * exceeds `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -+ * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -+ * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - * On success, both the preferred OID (`out_oid`) and the legacy SHA-1 buffer - * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` - * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain - * deterministic contents. Callers must provide non-null pointers. -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/include/gitmind/edge/internal/blob_identity.h around lines 20 to 23, the -comment incorrectly states that the legacy SHA buffer is zero-padded when -GM_OID_RAWSZ "exceeds" GM_SHA1_SIZE; update the phrasing to say that the legacy -buffer is zero-padded when GM_OID_RAWSZ is smaller than GM_SHA1_SIZE (i.e., when -the preferred OID raw size is less than the legacy SHA-1 size), so callers know -padding happens to fill the remainder of the legacy buffer to GM_SHA1_SIZE; -ensure callers still know to provide non-null pointers. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101775 - -> [!note]- **Accepted** -> Added the overflow guard in `gm_bytes_to_hex`, matching the recommended bounds check before computing `required`. - -### core/src/util/oid.c:38 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard against overflow before sizing the hex buffer** - -`required = (len * 2U) + 1U` can overflow `size_t` for large inputs, which lets the length check pass with a wrapped value and we then scribble past `out` while the loop iterates `len` times. Please short-circuit when `len` exceeds the safe range before doing the multiply. - - - -```diff -@@ -- const size_t required = (len * 2U) + 1U; -+ if (len > (SIZE_MAX - 1U) / 2U) { -+ gm_memset_safe(out, out_size, 0, out_size); -+ return GM_ERR_INVALID_ARGUMENT; -+ } -+ -+ const size_t required = (len * 2U) + 1U; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (len > (SIZE_MAX - 1U) / 2U) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_INVALID_ARGUMENT; - } - - const size_t required = (len * 2U) + 1U; - if (out_size < required) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_BUFFER_TOO_SMALL; - } - - for (size_t i = 0; i < len; ++i) { - unsigned byte = bytes[i]; - out[i * 2U] = KHexDigits[(byte >> KNibbleBits) & KNibbleMask]; - out[(i * 2U) + 1U] = KHexDigits[byte & KNibbleMask]; - } - out[len * 2U] = '\0'; -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/util/oid.c around lines 27-38, the computed required = (len * 2U) + -1U can overflow size_t for large len; before performing the multiply, check that -len does not exceed (SIZE_MAX - 1) / 2 (or equivalent safe_max) and if it does, -zero the output buffer via gm_memset_safe and return GM_ERR_BUFFER_TOO_SMALL (or -an appropriate error). After that guard, compute required normally, perform the -existing out_size check and proceed with the hex conversion. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101784 - -> [!note]- **Accepted** -> Updated the seeded doc so its title mirrors the H1 and inserted the required table of contents section. - -### docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md:18 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required Table of Contents and title alignment** - -Docs under `docs/**` must include a `## Table of Contents` section and keep the front-matter `title` in sync with the H1. This file omits the TOC and the front-matter title (`203f4e3539b1d8fc73b641e94b0a420f2e592a14.md`) does not match the H1 (`Code Review Feedback`). Please add the missing TOC heading and align the title/H1 pair. As per coding guidelines. - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md lines -1-18, the front-matter title does not match the H1 and the required "## Table of -Contents" section is missing; update the YAML front-matter title to exactly -"Code Review Feedback" to match the H1 and insert a "## Table of Contents" -heading (with any preferred TOC entries or a placeholder) immediately after the -H1 so the document follows the docs/** guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101790 - -> [!note]- **Accepted** -> Copy that — waiting for CodeRabbit to finish processing the refreshed score. - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between 608627593945ba63068a540a18cd67af8242a3d3 and 5add14fcdabafff59a99ea484d691140afdb68c3. -> ->
-> ->
-> 📒 Files selected for processing (1) -> -> * `.github/workflows/review-artifact-cleanup.yml` (1 hunks) -> ->
-> -> ```ascii -> ______________________________________________ -> < Preventing the Y2K bug from happening again. > -> ---------------------------------------------- -> \ -> \ (\__/) -> (•ㅅ•) -> /   づ -> ``` - - - - - -## Walkthrough -Adds OID hex utilities and integrates them into cache and query code; introduces a new blob-identity resolver and routes edge creation through it; tightens path parsing and emit bounds; adds buffer-length checks to fake git port helpers; updates build files to include new sources; moves a cache struct comment and removes/adds several docs and AGENTS.md entries. - -## Changes -| Cohort / File(s) | Summary | -|---|---| -| **OID hex utilities (new API)**
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | Adds `gm_bytes_to_hex` and `gm_oid_to_hex` with input validation, buffer-size checks, safe zeroing, and NUL termination. | -| **Adopt OID hex helpers**
`core/src/app/cache/cache_rebuild_service.c`, `core/src/cache/query.c` | Replaces inline/git2 hex formatting with `gm_oid_to_hex`/`gm_bytes_to_hex`; adds buffer checks and error paths; updates includes. | -| **Blob identity resolver (new helper) + integration**
`core/include/gitmind/edge/internal/blob_identity.h`, `core/src/edge/internal/blob_identity.c`, `core/src/edge/edge.c`, `core/src/edge/attributed.c` | Adds `gm_edge_resolve_blob_identity` and replaces local resolve logic in edge creation to delegate to the new helper; handles legacy SHA padding and port error cases. | -| **Filesystem path utils hardening**
`core/src/fs/path_utils.c` | Adds `max_segments` parameter to parsing, bounds segment parsing by dynamic limit, and guards emission against buffer overruns returning path-too-long. | -| **Fake git repo port safety**
`core/tests/fakes/git/fake_git_repository_port.c` | Checks `gm_strcpy_safe` return values; clears destinations and returns `GM_ERR_BUFFER_TOO_SMALL` on overflow. | -| **Cache header comment move**
`core/include/gitmind/cache.h` | Relocates a struct-tail comment without changing field order or ABI. | -| **Build configuration**
`meson.build` | Adds new source files: `core/src/edge/internal/blob_identity.c` and `core/src/util/oid.c`. | -| **Docs: removals and additions**
`docs/code-reviews/*` (multiple removals), `docs/code-reviews/PR172/*`, `AGENTS.md` | Removes many archived/rejected review artifacts, adds new PR172 review artifacts, and appends a 2025-09-28 entry to `AGENTS.md`. | -| **Worksheet checker tweak**
`tools/review/check_worksheets.py` | Treats deleted worksheet files as acceptable by returning empty problem list on FileNotFoundError. | - -## Sequence Diagram(s) -```mermaid -sequenceDiagram - autonumber - actor Caller as Edge Creator - participant BI as gm_edge_resolve_blob_identity - participant Port as Git Repository Port - - Caller->>BI: resolve(path, out_oid, legacy_sha) - BI->>Port: gm_git_repository_port_resolve_blob_at_head(path) - Port-->>BI: oid_raw_bytes or error - - alt success - BI->>BI: copy min(GM_OID_RAWSZ, GM_SHA1_SIZE) → legacy_sha - BI->>BI: zero-pad remainder if needed - BI-->>Caller: GM_OK (out_oid, legacy_sha) - else error - BI->>BI: zero legacy_sha - BI-->>Caller: error - end -``` - -## Estimated code review effort -🎯 3 (Moderate) | ⏱️ ~25 minutes - -## Possibly related PRs -- neuroglyph/git-mind#158: Modifies `gm_edge_attributed_create` and related edge creation paths; likely overlaps with switching to `gm_edge_resolve_blob_identity`. - -## Poem -> A rabbit taps its keys with cheer, -> Bytes turn bright and hex appears, -> Blobs resolved by careful paws, -> Edges hop through tightened laws. -> Docs trimmed, buffers guarded—hooray! 🐇✨ - - - - - -## Pre-merge checks and finishing touches -
-❌ Failed checks (3 warnings) - -| Check name | Status | Explanation | Resolution | -| :----------------: | :--------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Title Check | ⚠️ Warning | The title “chore/code rabbit cleanup” is vague and does not clearly summarize the main changes in this pull request, such as the introduction of the gm_git_repository_port abstraction and related core refactoring; it reads like a generic housekeeping label rather than highlighting the primary technical change. | Please update the title to a concise sentence that reflects the core refactor—for example, “refactor(core): introduce Git repository port abstraction and decouple legacy git_ops”—so that readers immediately understand the primary change. | -| Description Check | ⚠️ Warning | The pull request description consists of a long list of individual commit-like entries and omitted all of the required template sections: there is no “## Summary” explaining the change, no “## Change Areas” checklist, no “## Risk” section, and no “## Code Review Guidance” section as specified by the repository template. This makes it hard to see an overarching summary, categorize the affected areas, or assess risk and review guidance. | Restructure the description to follow the provided template by adding a “## Summary” that succinctly describes what and why, filling out the “## Change Areas” checkbox list, completing the “## Risk” checklist to indicate behavior or API changes, and supplying a “## Code Review Guidance” section with top risks and fix-it suggestions. | -| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run `@coderabbitai generate docstrings` to improve docstring coverage. | - -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - - - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -> [!note]- **Accepted** -> Awaiting CodeRabbit's re-run on the latest changes. diff --git a/docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md b/docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md deleted file mode 100644 index 7ffd6e62..00000000 --- a/docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -title: 7b7b5f565ef23d959b126b0df50e0a3992c52da2.md -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `7b7b5f565ef23d959b126b0df50e0a3992c52da2` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between b0a37d21bfba6f6796d42fb32dcadf668d013ea2 and 5d58351452d6e51c73571b39e682c24f0bfabbc6. -> ->
-> ->
-> 📒 Files selected for processing (34) -> -> * `AGENTS.md` (1 hunks) -> * `core/include/gitmind/cache.h` (1 hunks) -> * `core/include/gitmind/edge/internal/blob_identity.h` (1 hunks) -> * `core/include/gitmind/util/oid.h` (1 hunks) -> * `core/src/app/cache/cache_rebuild_service.c` (3 hunks) -> * `core/src/cache/query.c` (3 hunks) -> * `core/src/edge/attributed.c` (2 hunks) -> * `core/src/edge/edge.c` (2 hunks) -> * `core/src/edge/internal/blob_identity.c` (1 hunks) -> * `core/src/fs/path_utils.c` (3 hunks) -> * `core/src/util/oid.c` (1 hunks) -> * `core/tests/fakes/git/fake_git_repository_port.c` (2 hunks) -> * `docs/code-reviews/CLAUDE.md` (0 hunks) -> * `docs/code-reviews/PR169/e4f3f906eb454cb103eb8cc6899df8dfbf6e2349.md` (0 hunks) -> * `docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md` (0 hunks) -> * `docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md` (0 hunks) -> * `docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md` (1 hunks) -> * `docs/code-reviews/rejected-suggestions/1d234c5614f96272eca5e9607d84b3655080546b_feat-cli-safety-e2e_166_valgrind-suppression-link.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_angle-includes.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_consumed-length.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_e2e-refactor.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_markdownlint.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_replace-macros-with-literals.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/4d28721c4b98c6dd29f475d5a1974c2fd2d95a1a_feat-cli-safety-e2e_166_umbrella-safety-include.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/5965e14_feat-changelog-and-sweep-4_PR169_md-verify-alias.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/5965e14_feat-changelog-and-sweep-4_PR169_phony-ordering.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/5965e14_feat-changelog-and-sweep-4_PR169_pre-push-changelog-variants.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/608bc03_main_cstd-c23-only.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/608bc03_main_deprec-macros-augment.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR164_detached-head-behavior.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR165_move-test-prototypes-private.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR165_reserve-extra-byte.md` (0 hunks) -> * `docs/code-reviews/rejected-suggestions/ef52094_migration-finish-core-cleanup_PR166_missing-umbrella-apis.md` (0 hunks) -> * `meson.build` (2 hunks) -> ->
-> -> ```ascii -> ____________________________________________________________________________________________________________________________________________________________________________ -> < Good code is its own best documentation. As you're about to add a comment, ask yourself, 'How can I improve the code so that this comment isn't needed?' - Steve McConnell > -> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -> \ -> \ (\__/) -> (•ㅅ•) -> /   づ -> ``` - - - - - - -
-✨ Finishing touches - -- [ ] 📝 Generate Docstrings -
-🧪 Generate unit tests - -- [ ] Create PR with unit tests -- [ ] Post copyable unit tests in a comment -- [ ] Commit unit tests in branch `chore/code-rabbit-cleanup` - -
- -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -> [!note]- **Accepted** -> Understood — we’ll wait for CodeRabbit’s next cue. diff --git a/docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md b/docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md deleted file mode 100644 index 6add9861..00000000 --- a/docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md +++ /dev/null @@ -1,649 +0,0 @@ ---- -title: 82dab217893b6ee8bb8dcdca2217f9900a06b76f.md -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `82dab217893b6ee8bb8dcdca2217f9900a06b76f` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Fix legacy buffer padding description.** - -The implementation zero-fills the legacy SHA buffer only when `GM_OID_RAWSZ` is *smaller* than `GM_SHA1_SIZE`. The doc currently says “exceeds,” so the guidance is inverted. Please update the phrasing so callers understand when padding happens. - -```diff -- * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -- * exceeds `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -+ * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -+ * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - * On success, both the preferred OID (`out_oid`) and the legacy SHA-1 buffer - * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` - * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain - * deterministic contents. Callers must provide non-null pointers. -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/include/gitmind/edge/internal/blob_identity.h around lines 20 to 23, the -comment incorrectly states that the legacy SHA buffer is zero-padded when -GM_OID_RAWSZ "exceeds" GM_SHA1_SIZE; update the phrasing to say that the legacy -buffer is zero-padded when GM_OID_RAWSZ is smaller than GM_SHA1_SIZE (i.e., when -the preferred OID raw size is less than the legacy SHA-1 size), so callers know -padding happens to fill the remainder of the legacy buffer to GM_SHA1_SIZE; -ensure callers still know to provide non-null pointers. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101775 - -> [!note]- **Accepted** -> Added a pre-check in `gm_bytes_to_hex` that guards against `(len * 2U) + 1U` overflowing, zeroing the buffer and returning `GM_ERR_INVALID_ARGUMENT` when the input would exceed safe bounds. - -### core/src/util/oid.c:38 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard against overflow before sizing the hex buffer** - -`required = (len * 2U) + 1U` can overflow `size_t` for large inputs, which lets the length check pass with a wrapped value and we then scribble past `out` while the loop iterates `len` times. Please short-circuit when `len` exceeds the safe range before doing the multiply. - - - -```diff -@@ -- const size_t required = (len * 2U) + 1U; -+ if (len > (SIZE_MAX - 1U) / 2U) { -+ gm_memset_safe(out, out_size, 0, out_size); -+ return GM_ERR_INVALID_ARGUMENT; -+ } -+ -+ const size_t required = (len * 2U) + 1U; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (len > (SIZE_MAX - 1U) / 2U) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_INVALID_ARGUMENT; - } - - const size_t required = (len * 2U) + 1U; - if (out_size < required) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_BUFFER_TOO_SMALL; - } - - for (size_t i = 0; i < len; ++i) { - unsigned byte = bytes[i]; - out[i * 2U] = KHexDigits[(byte >> KNibbleBits) & KNibbleMask]; - out[(i * 2U) + 1U] = KHexDigits[byte & KNibbleMask]; - } - out[len * 2U] = '\0'; -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/util/oid.c around lines 27-38, the computed required = (len * 2U) + -1U can overflow size_t for large len; before performing the multiply, check that -len does not exceed (SIZE_MAX - 1) / 2 (or equivalent safe_max) and if it does, -zero the output buffer via gm_memset_safe and return GM_ERR_BUFFER_TOO_SMALL (or -an appropriate error). After that guard, compute required normally, perform the -existing out_size check and proceed with the hex conversion. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101784 - -> [!note]- **Accepted** -> Updated `docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md` so the front-matter title matches the H1 and added the required `## Table of Contents` block immediately after the heading. - -### docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md:18 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required Table of Contents and title alignment** - -Docs under `docs/**` must include a `## Table of Contents` section and keep the front-matter `title` in sync with the H1. This file omits the TOC and the front-matter title (`203f4e3539b1d8fc73b641e94b0a420f2e592a14.md`) does not match the H1 (`Code Review Feedback`). Please add the missing TOC heading and align the title/H1 pair. As per coding guidelines. - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md lines -1-18, the front-matter title does not match the H1 and the required "## Table of -Contents" section is missing; update the YAML front-matter title to exactly -"Code Review Feedback" to match the H1 and insert a "## Table of Contents" -heading (with any preferred TOC entries or a placeholder) immediately after the -H1 so the document follows the docs/** guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101790 - -> [!note]- **Accepted** -> The cleanup workflow now checks out `${{ github.event.pull_request.base.ref }}` so we commit and push on the branch instead of a detached merge ref. - -### .github/workflows/review-artifact-cleanup.yml:47 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix checkout to track a branch before pushing** - -`actions/checkout` on a `pull_request` event leaves the repo in a detached HEAD at `refs/pull//merge`. The later `git push` step then fails with “You are not currently on a branch,” so the cleanup commit never lands. Check out the base branch (or push `HEAD` explicitly) before removing files. - - -```diff - - name: Checkout repository - uses: actions/checkout@v4 - with: -- fetch-depth: 0 -+ fetch-depth: 0 -+ ref: ${{ github.event.pull_request.base.ref }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.base.ref }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/review-artifact-cleanup.yml lines 18-47: the job checks out -the PR merge ref (detached HEAD) so later git commit/push fails; change the -checkout to track the target branch before making the cleanup commit. Either set -actions/checkout to the pull_request base ref (use ref: ${{ -github.event.pull_request.base.ref }} and fetch-depth: 0) or, immediately after -the existing checkout, fetch from origin and create/checkout a local branch that -tracks the PR base branch (so commits are made on a branch and can be pushed); -ensure the branch is tracking origin/ before the git commit and git push -steps. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144548 - -> [!note]- **Accepted** -> Aligned the front matter/title in `docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md` and inserted the mandatory table-of-contents section. - -### docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix doc front matter/title alignment and add required TOC** - -`docs/**` files must keep the front-matter `title` identical to the H1 and include a `## Table of Contents` section immediately after the H1. This file’s title still uses the SHA filename and the TOC is missing. Update the title to “Code Review Feedback” and add the TOC block so the doc complies with the repo guidelines. - -```diff - --- --title: 5add14fcdabafff59a99ea484d691140afdb68c3.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `5add14fcdabafff59a99ea484d691140afdb68c3` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md around -lines 1 to 16, the front-matter title is the SHA and the document is missing a -required Table of Contents; update the YAML front-matter title value to "Code -Review Feedback" so it matches the H1, and immediately after the H1 insert a "## -Table of Contents" section (with the standard TOC entries used across docs/) so -the file complies with repo guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144568 - -> [!note]- **Accepted** -> Added a pip install step to `coderabbit-status.yml` so the `requests` dependency is available before running `check_coderabbit_threads.py`. - -### .github/workflows/coderabbit-status.yml:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix: install Python dependency used by the script (requests).** - -The workflow runs a script that imports requests, but there’s no install step. This will fail with ModuleNotFoundError in CI. - -Apply this diff to add an install step: - -```diff - - name: Set up Python - uses: actions/setup-python@v5 - with: -- python-version: '3.x' -+ python-version: '3.x' -+ - name: Install dependencies -+ run: | -+ python -m pip install --upgrade pip -+ python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/coderabbit-status.yml around lines 16 to 23: the CI job sets -up Python but never installs the requests dependency required by the script, -causing ModuleNotFoundError; add a step after "Set up Python" to install the -dependency (e.g., run pip install requests --upgrade or pip3 install requests) -so the script can import requests successfully during the workflow run. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271905 - -> [!note]- **Accepted** -> Harmonized the title and table of contents in `docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md` to match the docs guidelines. - -### docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md:20 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Align title with H1 and add the required TOC** - -Docs under `docs/**` have to mirror the H1 in the front matter `title` and include an explicit `## Table of Contents` immediately after the H1. Please update both so this artifact stays compliant. As per coding guidelines - -```diff - --- --title: 8a32c6a810ebf632709cec6c928381c9c47fdee9.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md lines -2-20, the front-matter title must match the document's H1 and you must insert an -explicit "## Table of Contents" immediately after the H1; update the YAML -front-matter title to exactly match the H1 text and add a "## Table of Contents" -header directly below the H1 (populate with relevant links or placeholders) so -the file conforms to the docs guideline. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271909 - -> [!note]- **Accepted** -> Thanks for the status update — we’ll keep playing until CodeRabbit finishes processing the refreshed score. - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between 093b7cb4bbf8e87b29a1d779b958263c941c616e and 82dab217893b6ee8bb8dcdca2217f9900a06b76f. -> ->
-> ->
-> 📒 Files selected for processing (1) -> -> * `docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md` (1 hunks) -> ->
-> -> ```ascii -> _________________________________________ -> < Making HAL 9000 open the pod bay doors. > -> ----------------------------------------- -> \ -> \ (\__/) -> (•ㅅ•) -> /   づ -> ``` - - - - - -## Walkthrough -Adds OID hex utilities and a blob-identity resolver, wires them into edge/cache/query paths, hardens path parsing and fake-git test copies, updates build list, adjusts worksheet/CI review tooling, and removes/adds assorted review documentation and AGENTS.md entries. No public ABI-breaking removals observed. - -## Changes -| Cohort / File(s) | Summary | -|---|---| -| **OID hex utilities (new API)**
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | New `gm_bytes_to_hex` and `gm_oid_to_hex` implementations and declarations with input validation, buffer-size checks, safe zeroing, and NUL termination. | -| **Adopt OID hex helpers**
`core/src/app/cache/cache_rebuild_service.c`, `core/src/cache/query.c` | Replace direct git2 oid-to-hex formatting with `gm_oid_to_hex` / `gm_bytes_to_hex`; add buffer initialization and error handling; include new util header. | -| **Blob identity resolver (new helper) + integration**
`core/include/gitmind/edge/internal/blob_identity.h`, `core/src/edge/internal/blob_identity.c`, `core/src/edge/edge.c`, `core/src/edge/attributed.c` | Add `gm_edge_resolve_blob_identity`; delegate previous inline blob-resolution logic in edge creation to this helper; handle port availability, legacy SHA padding/zeroing, and error propagation. | -| **Filesystem path utils hardening**
`core/src/fs/path_utils.c` | Parse functions now accept dynamic `max_segments`; emit safeguards against output-buffer overruns and return path-too-long on overflow. | -| **Fake git repo port safety**
`core/tests/fakes/git/fake_git_repository_port.c` | Check `gm_strcpy_safe` return codes; clear destinations and return `GM_ERR_BUFFER_TOO_SMALL` on overflow. | -| **Cache header comment move**
`core/include/gitmind/cache.h` | Relocated a struct-tail comment; no layout/type changes. | -| **Build configuration**
`meson.build` | Add `core/src/edge/internal/blob_identity.c` and `core/src/util/oid.c` to sources. | -| **Docs & review artifacts**
`docs/code-reviews/*`, `docs/code-reviews/PR172/*`, `AGENTS.md` | Remove many archived/rejected review docs, add PR172 artifacts, and append a 2025-09-28 entry to `AGENTS.md`. | -| **Worksheet checker tweak**
`tools/review/check_worksheets.py` | Treat deleted worksheet files as acceptable by returning an empty problems list on FileNotFoundError. | -| **CI workflow: review artifact cleanup**
`.github/workflows/review-artifact-cleanup.yml` | New workflow to remove per-PR review artifacts on merged PRs and commit/push cleanup when changes exist. | -| **Coderabbit status workflow & tooling**
`.github/workflows/coderabbit-status.yml`, `tools/review/check_coderabbit_threads.py` | Add workflow to run `check_coderabbit_threads.py` on PR events; new script queries GitHub GraphQL for unresolved CodeRabbit threads and reports them. | - -## Sequence Diagram(s) -```mermaid -sequenceDiagram - autonumber - actor EdgeCreator as Edge Creator - participant BI as gm_edge_resolve_blob_identity - participant Port as Git Repository Port - - EdgeCreator->>BI: resolve_blob_identity(ctx, path, out_oid, legacy_sha) - BI->>Port: gm_git_repository_port_resolve_blob_at_head(path) - Port-->>BI: oid_bytes / error - - alt port success - BI->>BI: copy min(GM_OID_RAWSZ, GM_SHA1_SIZE) → legacy_sha - BI->>BI: zero-pad remainder if copy_len < GM_SHA1_SIZE - BI-->>EdgeCreator: GM_OK (out_oid, legacy_sha) - else port error - BI->>BI: zero legacy_sha - BI-->>EdgeCreator: error (propagate) - end -``` - -## Estimated code review effort -🎯 4 (Complex) | ⏱️ ~50 minutes - -## Possibly related PRs -- neuroglyph/git-mind#165 — Overlaps OID-first migration and edge/blob identity helpers; likely continued work on same APIs. -- neuroglyph/git-mind#166 — Related changes to edge blob identity and OID/hex utilities integration. -- neuroglyph/git-mind#169 — Touches OID/ref/edge handling and replacement of direct git2 oid logic; strongly related. - -## Poem -> I nibble bytes and spin them hex, -> I hop through blobs and mend the specs, -> I guard the paths and tidy docs, -> I patch the tests and hush the clocks, -> A rabbit’s hop, a tiny fix—🐇✨ - - - - - -## Pre-merge checks and finishing touches -
-❌ Failed checks (2 warnings, 1 inconclusive) - -| Check name | Status | Explanation | Resolution | -| :----------------: | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| Description Check | ⚠️ Warning | The provided description is a long unstructured list of commit-style entries and does not follow the repository’s required template, which mandates distinct sections for Summary, Change Areas, Risk, and Code Review Guidance. Without these headings and checkbox fields, it is unclear what high-level problem is being solved, which areas are impacted, or how reviewers should prioritize risks and feedback. The current format makes it difficult to quickly assess scope, impact, and testing guidance. | Please restructure the PR description to match the repository template by adding a “## Summary” section that concisely describes the change and its rationale, a “## Change Areas” list with checked boxes for Core, CLI/Hooks, Docs, and CI/Tooling as appropriate, a “## Risk” section indicating behavior changes or public API impacts, and a “## Code Review Guidance” section with top-risk notes and suggested fix-it blocks. This will ensure reviewers can quickly understand scope, impact, and guidance. | -| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run `@coderabbitai generate docstrings` to improve docstring coverage. | -| Title Check | ❓ Inconclusive | The title “chore/code rabbit cleanup” is overly generic and does not clearly convey the primary functional changes introduced in this PR, such as the migration to a new git_repository_port abstraction or the addition of OID hex utilities. It does not read as a coherent sentence and omits important context about the core refactoring and feature enhancements. As a result, reviewers scanning the commit history may not quickly grasp the scope or intent of the changes. | Please revise the title to succinctly summarize the main change in a single clear sentence, for example “refactor(core): introduce gm_git_repository_port abstraction and decouple legacy git ops” or “feat(util): add OID hex utilities and integrate in cache and edge modules,” so that it immediately communicates the PR’s core purpose to readers. | - -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - - - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -> [!note]- **Accepted** -> Understood — awaiting CodeRabbit's follow-up. diff --git a/docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md b/docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md deleted file mode 100644 index 8d4dc90a..00000000 --- a/docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md +++ /dev/null @@ -1,490 +0,0 @@ ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `8a32c6a810ebf632709cec6c928381c9c47fdee9` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Fix legacy buffer padding description.** - -The implementation zero-fills the legacy SHA buffer only when `GM_OID_RAWSZ` is *smaller* than `GM_SHA1_SIZE`. The doc currently says “exceeds,” so the guidance is inverted. Please update the phrasing so callers understand when padding happens. - -```diff -- * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -- * exceeds `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -+ * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -+ * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - * On success, both the preferred OID (`out_oid`) and the legacy SHA-1 buffer - * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` - * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain - * deterministic contents. Callers must provide non-null pointers. -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/include/gitmind/edge/internal/blob_identity.h around lines 20 to 23, the -comment incorrectly states that the legacy SHA buffer is zero-padded when -GM_OID_RAWSZ "exceeds" GM_SHA1_SIZE; update the phrasing to say that the legacy -buffer is zero-padded when GM_OID_RAWSZ is smaller than GM_SHA1_SIZE (i.e., when -the preferred OID raw size is less than the legacy SHA-1 size), so callers know -padding happens to fill the remainder of the legacy buffer to GM_SHA1_SIZE; -ensure callers still know to provide non-null pointers. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101775 - -> [!note]- **Accepted** -> Added the size guard in `gm_bytes_to_hex` so we bail out before `(len * 2U) + 1U` can wrap. - -### core/src/util/oid.c:38 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard against overflow before sizing the hex buffer** - -`required = (len * 2U) + 1U` can overflow `size_t` for large inputs, which lets the length check pass with a wrapped value and we then scribble past `out` while the loop iterates `len` times. Please short-circuit when `len` exceeds the safe range before doing the multiply. - - - -```diff -@@ -- const size_t required = (len * 2U) + 1U; -+ if (len > (SIZE_MAX - 1U) / 2U) { -+ gm_memset_safe(out, out_size, 0, out_size); -+ return GM_ERR_INVALID_ARGUMENT; -+ } -+ -+ const size_t required = (len * 2U) + 1U; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (len > (SIZE_MAX - 1U) / 2U) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_INVALID_ARGUMENT; - } - - const size_t required = (len * 2U) + 1U; - if (out_size < required) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_BUFFER_TOO_SMALL; - } - - for (size_t i = 0; i < len; ++i) { - unsigned byte = bytes[i]; - out[i * 2U] = KHexDigits[(byte >> KNibbleBits) & KNibbleMask]; - out[(i * 2U) + 1U] = KHexDigits[byte & KNibbleMask]; - } - out[len * 2U] = '\0'; -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/util/oid.c around lines 27-38, the computed required = (len * 2U) + -1U can overflow size_t for large len; before performing the multiply, check that -len does not exceed (SIZE_MAX - 1) / 2 (or equivalent safe_max) and if it does, -zero the output buffer via gm_memset_safe and return GM_ERR_BUFFER_TOO_SMALL (or -an appropriate error). After that guard, compute required normally, perform the -existing out_size check and proceed with the hex conversion. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101784 - -> [!note]- **Accepted** -> Synced the front matter title with the H1 and restored the `## Table of Contents` block in the referenced doc. - -### docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md:18 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required Table of Contents and title alignment** - -Docs under `docs/**` must include a `## Table of Contents` section and keep the front-matter `title` in sync with the H1. This file omits the TOC and the front-matter title (`203f4e3539b1d8fc73b641e94b0a420f2e592a14.md`) does not match the H1 (`Code Review Feedback`). Please add the missing TOC heading and align the title/H1 pair. As per coding guidelines. - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md lines -1-18, the front-matter title does not match the H1 and the required "## Table of -Contents" section is missing; update the YAML front-matter title to exactly -"Code Review Feedback" to match the H1 and insert a "## Table of Contents" -heading (with any preferred TOC entries or a placeholder) immediately after the -H1 so the document follows the docs/** guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101790 - -> [!note]- **Accepted** -> Adjusted the cleanup workflow checkout to track the base branch before committing. - -### .github/workflows/review-artifact-cleanup.yml:47 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix checkout to track a branch before pushing** - -`actions/checkout` on a `pull_request` event leaves the repo in a detached HEAD at `refs/pull//merge`. The later `git push` step then fails with “You are not currently on a branch,” so the cleanup commit never lands. Check out the base branch (or push `HEAD` explicitly) before removing files. - - -```diff - - name: Checkout repository - uses: actions/checkout@v4 - with: -- fetch-depth: 0 -+ fetch-depth: 0 -+ ref: ${{ github.event.pull_request.base.ref }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.base.ref }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/review-artifact-cleanup.yml lines 18-47: the job checks out -the PR merge ref (detached HEAD) so later git commit/push fails; change the -checkout to track the target branch before making the cleanup commit. Either set -actions/checkout to the pull_request base ref (use ref: ${{ -github.event.pull_request.base.ref }} and fetch-depth: 0) or, immediately after -the existing checkout, fetch from origin and create/checkout a local branch that -tracks the PR base branch (so commits are made on a branch and can be pushed); -ensure the branch is tracking origin/ before the git commit and git push -steps. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144548 - -> [!note]- **Accepted** -> Updated this artifact to use “Code Review Feedback” as the title and inserted the mandatory table of contents. - -### docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md:16 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix doc front matter/title alignment and add required TOC** - -`docs/**` files must keep the front-matter `title` identical to the H1 and include a `## Table of Contents` section immediately after the H1. This file’s title still uses the SHA filename and the TOC is missing. Update the title to “Code Review Feedback” and add the TOC block so the doc complies with the repo guidelines. - -```diff - --- --title: 5add14fcdabafff59a99ea484d691140afdb68c3.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `5add14fcdabafff59a99ea484d691140afdb68c3` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md around -lines 1 to 16, the front-matter title is the SHA and the document is missing a -required Table of Contents; update the YAML front-matter title value to "Code -Review Feedback" so it matches the H1, and immediately after the H1 insert a "## -Table of Contents" section (with the standard TOC entries used across docs/) so -the file complies with repo guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144568 - -> [!note]- **Accepted** -> Ensured `requests` is installed in the CodeRabbit status workflow so the checker script runs cleanly. - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between daca6b803abdebc66e0388e74b2b9eb3d79f816c and 8a32c6a810ebf632709cec6c928381c9c47fdee9. -> ->
-> ->
-> 📒 Files selected for processing (2) -> -> * `.github/workflows/coderabbit-status.yml` (1 hunks) -> * `tools/review/check_coderabbit_threads.py` (1 hunks) -> ->
-> -> ```ascii -> ___________________________________________________________________________________________ -> < I'm the Doctor. Well, a doctor of code, and I'm here to fix the timeline of your project. > -> ------------------------------------------------------------------------------------------- -> \ -> \ (\__/) -> (•ㅅ•) -> /   づ -> ``` - - - - - -## Walkthrough -Adds OID hex utilities, a new blob-identity resolver, and integrates them across cache/query/edge code; tightens path parsing and emit bounds; adds buffer-length checks to fake git port tests; updates build files; and removes/adds multiple documentation artifacts and a CI cleanup workflow. - -## Changes -| Cohort / File(s) | Summary | -|---|---| -| **OID hex utilities (new API)**
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | Introduces `gm_bytes_to_hex` and `gm_oid_to_hex` with input validation, buffer-size checks, safe zeroing, and NUL termination. | -| **Adopt OID hex helpers**
`core/src/app/cache/cache_rebuild_service.c`, `core/src/cache/query.c` | Replaces direct git2 hex formatting with `gm_oid_to_hex`/`gm_bytes_to_hex`; adds buffer initialization, error handling, and updated includes. | -| **Blob identity resolver (new helper) + integration**
`core/include/gitmind/edge/internal/blob_identity.h`, `core/src/edge/internal/blob_identity.c`, `core/src/edge/edge.c`, `core/src/edge/attributed.c` | Adds `gm_edge_resolve_blob_identity` and replaces local resolve logic in edge creation to delegate to it; handles legacy SHA padding, validation, and port error cases. | -| **Filesystem path utils hardening**
`core/src/fs/path_utils.c` | Adds dynamic `max_segments` parameter, bounds parsing by that limit, and guards emit against buffer overruns returning path-too-long. | -| **Fake git repo port safety**
`core/tests/fakes/git/fake_git_repository_port.c` | Checks `gm_strcpy_safe` return codes; clears destinations and returns `GM_ERR_BUFFER_TOO_SMALL` on overflow. | -| **Cache header comment move**
`core/include/gitmind/cache.h` | Relocated a struct-tail comment without changing field order, types, or ABI layout. | -| **Build configuration**
`meson.build` | Adds `core/src/edge/internal/blob_identity.c` and `core/src/util/oid.c` to sources. | -| **Docs & review artifacts**
`docs/code-reviews/*`, `docs/code-reviews/PR172/*`, `AGENTS.md` | Removes many archived/rejected review docs, adds PR172 review artifacts, and appends a 2025-09-28 entry to `AGENTS.md`. | -| **Worksheet checker tweak**
`tools/review/check_worksheets.py` | Treats missing (deleted) worksheet files as acceptable by returning an empty problem list on FileNotFoundError. | -| **CI workflow: review artifact cleanup**
`.github/workflows/review-artifact-cleanup.yml` | New workflow to remove per-PR review artifacts when a PR is merged; commits and pushes cleanup if changes exist. | - -## Sequence Diagram(s) -```mermaid -sequenceDiagram - autonumber - actor EdgeCreator as Edge Creator - participant BI as gm_edge_resolve_blob_identity - participant Port as Git Repository Port - - EdgeCreator->>BI: resolve_blob_identity(ctx, path, out_oid, legacy_sha) - BI->>Port: gm_git_repository_port_resolve_blob_at_head(path) - Port-->>BI: oid_raw_bytes / error - - alt port success - BI->>BI: copy min(GM_OID_RAWSZ, GM_SHA1_SIZE) → legacy_sha - BI->>BI: zero-pad remaining legacy_sha bytes if any - BI-->>EdgeCreator: GM_OK (out_oid, legacy_sha) - else port error - BI->>BI: zero legacy_sha - BI-->>EdgeCreator: error (propagate) - end -``` - -## Estimated code review effort -🎯 4 (Complex) | ⏱️ ~50 minutes - -## Poem -> I nibble bytes and spin them hex, -> I hop through blobs and patch the specs, -> I guard the paths and tidy docs, -> I press the keys and fix the locks. -> A rabbit's small, precise deploy—🐇✨ - - - - - -## Pre-merge checks and finishing touches -
-❌ Failed checks (1 warning, 1 inconclusive) - -| Check name | Status | Explanation | Resolution | -| :---------------: | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Description Check | ⚠️ Warning | The pull request description is a long list of commit‐style bullet points and does not follow the repository’s required template sections (Summary, Change Areas, Risk, and Code Review Guidance), leaving out the explicit context, scope checkboxes, risk assessment, and human review guidance that the template mandates. | Reformat the description to include a top‐level “## Summary” explaining what and why, mark the relevant change areas with checklist boxes, indicate the risk level under “## Risk,” and add a “## Code Review Guidance” section with reviewer instructions as per the repository template. | -| Title Check | ❓ Inconclusive | The pull request title “chore/code rabbit cleanup” is overly generic and does not summarize the primary technical changes such as introducing the gm_git_repository_port abstraction or migrating blob identity resolution; it also uses an internal term (“code rabbit”) that is not self‐explanatory to someone scanning history. | Please rename the title to clearly reflect the most significant change—for example, “refactor(core): introduce gm_git_repository_port abstraction and migrate blob identity resolution”—so that its scope and intent are immediately obvious. | - -
-
-✅ Passed checks (1 passed) - -| Check name | Status | Explanation | -| :----------------: | :------- | :------------------------------------------------------------------- | -| Docstring Coverage | ✅ Passed | No functions found in the changes. Docstring coverage check skipped. | - -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - - - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -> [!note]- **Accepted** -> Mirror update: the sibling worksheet now has matching title + TOC per guidelines. diff --git a/docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md b/docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md deleted file mode 100644 index 3d26214d..00000000 --- a/docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md +++ /dev/null @@ -1,654 +0,0 @@ ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `b22c22398de39c4ab93e1c747b1122d2241eed22` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Fix legacy buffer padding description.** - -The implementation zero-fills the legacy SHA buffer only when `GM_OID_RAWSZ` is *smaller* than `GM_SHA1_SIZE`. The doc currently says “exceeds,” so the guidance is inverted. Please update the phrasing so callers understand when padding happens. - -```diff -- * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -- * exceeds `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -+ * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -+ * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - * On success, both the preferred OID (`out_oid`) and the legacy SHA-1 buffer - * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` - * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain - * deterministic contents. Callers must provide non-null pointers. -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/include/gitmind/edge/internal/blob_identity.h around lines 20 to 23, the -comment incorrectly states that the legacy SHA buffer is zero-padded when -GM_OID_RAWSZ "exceeds" GM_SHA1_SIZE; update the phrasing to say that the legacy -buffer is zero-padded when GM_OID_RAWSZ is smaller than GM_SHA1_SIZE (i.e., when -the preferred OID raw size is less than the legacy SHA-1 size), so callers know -padding happens to fill the remainder of the legacy buffer to GM_SHA1_SIZE; -ensure callers still know to provide non-null pointers. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101775 - -> [!note]- **Accepted** -> Added the overflow guard in `gm_bytes_to_hex` to match this recommendation. - -### core/src/util/oid.c:38 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard against overflow before sizing the hex buffer** - -`required = (len * 2U) + 1U` can overflow `size_t` for large inputs, which lets the length check pass with a wrapped value and we then scribble past `out` while the loop iterates `len` times. Please short-circuit when `len` exceeds the safe range before doing the multiply. - - - -```diff -@@ -- const size_t required = (len * 2U) + 1U; -+ if (len > (SIZE_MAX - 1U) / 2U) { -+ gm_memset_safe(out, out_size, 0, out_size); -+ return GM_ERR_INVALID_ARGUMENT; -+ } -+ -+ const size_t required = (len * 2U) + 1U; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (len > (SIZE_MAX - 1U) / 2U) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_INVALID_ARGUMENT; - } - - const size_t required = (len * 2U) + 1U; - if (out_size < required) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_BUFFER_TOO_SMALL; - } - - for (size_t i = 0; i < len; ++i) { - unsigned byte = bytes[i]; - out[i * 2U] = KHexDigits[(byte >> KNibbleBits) & KNibbleMask]; - out[(i * 2U) + 1U] = KHexDigits[byte & KNibbleMask]; - } - out[len * 2U] = '\0'; -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/util/oid.c around lines 27-38, the computed required = (len * 2U) + -1U can overflow size_t for large len; before performing the multiply, check that -len does not exceed (SIZE_MAX - 1) / 2 (or equivalent safe_max) and if it does, -zero the output buffer via gm_memset_safe and return GM_ERR_BUFFER_TOO_SMALL (or -an appropriate error). After that guard, compute required normally, perform the -existing out_size check and proceed with the hex conversion. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101784 - -> [!note]- **Accepted** -> The `203f4e...` artifact now has a matching title and table of contents. - -### docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md:18 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required Table of Contents and title alignment** - -Docs under `docs/**` must include a `## Table of Contents` section and keep the front-matter `title` in sync with the H1. This file omits the TOC and the front-matter title (`203f4e3539b1d8fc73b641e94b0a420f2e592a14.md`) does not match the H1 (`Code Review Feedback`). Please add the missing TOC heading and align the title/H1 pair. As per coding guidelines. - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md lines -1-18, the front-matter title does not match the H1 and the required "## Table of -Contents" section is missing; update the YAML front-matter title to exactly -"Code Review Feedback" to match the H1 and insert a "## Table of Contents" -heading (with any preferred TOC entries or a placeholder) immediately after the -H1 so the document follows the docs/** guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101790 - -> [!note]- **Accepted** -> The cleanup workflow now checks out the base branch instead of pushing from a detached merge ref. - -### .github/workflows/review-artifact-cleanup.yml:47 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix checkout to track a branch before pushing** - -`actions/checkout` on a `pull_request` event leaves the repo in a detached HEAD at `refs/pull//merge`. The later `git push` step then fails with “You are not currently on a branch,” so the cleanup commit never lands. Check out the base branch (or push `HEAD` explicitly) before removing files. - - -```diff - - name: Checkout repository - uses: actions/checkout@v4 - with: -- fetch-depth: 0 -+ fetch-depth: 0 -+ ref: ${{ github.event.pull_request.base.ref }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.base.ref }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/review-artifact-cleanup.yml lines 18-47: the job checks out -the PR merge ref (detached HEAD) so later git commit/push fails; change the -checkout to track the target branch before making the cleanup commit. Either set -actions/checkout to the pull_request base ref (use ref: ${{ -github.event.pull_request.base.ref }} and fetch-depth: 0) or, immediately after -the existing checkout, fetch from origin and create/checkout a local branch that -tracks the PR base branch (so commits are made on a branch and can be pushed); -ensure the branch is tracking origin/ before the git commit and git push -steps. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144548 - -> [!note]- **Accepted** -> Synced the title and table of contents in the referenced worksheet. - -### docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix doc front matter/title alignment and add required TOC** - -`docs/**` files must keep the front-matter `title` identical to the H1 and include a `## Table of Contents` section immediately after the H1. This file’s title still uses the SHA filename and the TOC is missing. Update the title to “Code Review Feedback” and add the TOC block so the doc complies with the repo guidelines. - -```diff - --- --title: 5add14fcdabafff59a99ea484d691140afdb68c3.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `5add14fcdabafff59a99ea484d691140afdb68c3` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md around -lines 1 to 16, the front-matter title is the SHA and the document is missing a -required Table of Contents; update the YAML front-matter title value to "Code -Review Feedback" so it matches the H1, and immediately after the H1 insert a "## -Table of Contents" section (with the standard TOC entries used across docs/) so -the file complies with repo guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144568 - -> [!note]- **Accepted** -> Installed the `requests` dependency in the CodeRabbit status workflow so the script runs. - -### .github/workflows/coderabbit-status.yml:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix: install Python dependency used by the script (requests).** - -The workflow runs a script that imports requests, but there’s no install step. This will fail with ModuleNotFoundError in CI. - -Apply this diff to add an install step: - -```diff - - name: Set up Python - uses: actions/setup-python@v5 - with: -- python-version: '3.x' -+ python-version: '3.x' -+ - name: Install dependencies -+ run: | -+ python -m pip install --upgrade pip -+ python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/coderabbit-status.yml around lines 16 to 23: the CI job sets -up Python but never installs the requests dependency required by the script, -causing ModuleNotFoundError; add a step after "Set up Python" to install the -dependency (e.g., run pip install requests --upgrade or pip3 install requests) -so the script can import requests successfully during the workflow run. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271905 - -> [!note]- **Accepted** -> Mirrored the title/TOC fix in the companion worksheet. - -### docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md:20 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Align title with H1 and add the required TOC** - -Docs under `docs/**` have to mirror the H1 in the front matter `title` and include an explicit `## Table of Contents` immediately after the H1. Please update both so this artifact stays compliant. As per coding guidelines - -```diff - --- --title: 8a32c6a810ebf632709cec6c928381c9c47fdee9.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md lines -2-20, the front-matter title must match the document's H1 and you must insert an -explicit "## Table of Contents" immediately after the H1; update the YAML -front-matter title to exactly match the H1 text and add a "## Table of Contents" -header directly below the H1 (populate with relevant links or placeholders) so -the file conforms to the docs guideline. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271909 - -> [!note]- **Accepted** -> Request noted — we're waiting on CodeRabbit's processing. - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between 093b7cb4bbf8e87b29a1d779b958263c941c616e and a2804995e2e05f130d6bfbaf4a633329557ff005. -> ->
-> ->
-> 📒 Files selected for processing (2) -> -> * `docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md` (1 hunks) -> * `docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md` (1 hunks) -> ->
-> -> ```ascii -> ___________________________________________________________ -> < Patience, young padawan. The bugs will reveal themselves. > -> ----------------------------------------------------------- -> \ -> \ (\__/) -> (•ㅅ•) -> /   づ -> ``` - - - - - -## Walkthrough -Adds OID hex utilities and a blob-identity resolver, wires them into edge/cache/query paths, hardens path parsing and fake-git test copies, updates build list, adjusts worksheet/CI review tooling, and removes/adds assorted review documentation and AGENTS.md entries. No public ABI-breaking removals observed. - -## Changes -| Cohort / File(s) | Summary | -|---|---| -| **OID hex utilities (new API)**
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | New `gm_bytes_to_hex` and `gm_oid_to_hex` implementations and declarations with input validation, buffer-size checks, safe zeroing, and NUL termination. | -| **Adopt OID hex helpers**
`core/src/app/cache/cache_rebuild_service.c`, `core/src/cache/query.c` | Replace direct git2 oid-to-hex formatting with `gm_oid_to_hex` / `gm_bytes_to_hex`; add buffer initialization and error handling; include new util header. | -| **Blob identity resolver (new helper) + integration**
`core/include/gitmind/edge/internal/blob_identity.h`, `core/src/edge/internal/blob_identity.c`, `core/src/edge/edge.c`, `core/src/edge/attributed.c` | Add `gm_edge_resolve_blob_identity`; delegate previous inline blob-resolution logic in edge creation to this helper; handle port availability, legacy SHA padding/zeroing, and error propagation. | -| **Filesystem path utils hardening**
`core/src/fs/path_utils.c` | Parse functions now accept dynamic `max_segments`; emit safeguards against output-buffer overruns and return path-too-long on overflow. | -| **Fake git repo port safety**
`core/tests/fakes/git/fake_git_repository_port.c` | Check `gm_strcpy_safe` return codes; clear destinations and return `GM_ERR_BUFFER_TOO_SMALL` on overflow. | -| **Cache header comment move**
`core/include/gitmind/cache.h` | Relocated a struct-tail comment; no layout/type changes. | -| **Build configuration**
`meson.build` | Add `core/src/edge/internal/blob_identity.c` and `core/src/util/oid.c` to sources. | -| **Docs & review artifacts**
`docs/code-reviews/*`, `docs/code-reviews/PR172/*`, `AGENTS.md` | Remove many archived/rejected review docs, add PR172 artifacts, and append a 2025-09-28 entry to `AGENTS.md`. | -| **Worksheet checker tweak**
`tools/review/check_worksheets.py` | Treat deleted worksheet files as acceptable by returning an empty problems list on FileNotFoundError. | -| **CI workflow: review artifact cleanup**
`.github/workflows/review-artifact-cleanup.yml` | New workflow to remove per-PR review artifacts on merged PRs and commit/push cleanup when changes exist. | -| **Coderabbit status workflow & tooling**
`.github/workflows/coderabbit-status.yml`, `tools/review/check_coderabbit_threads.py` | Add workflow to run `check_coderabbit_threads.py` on PR events; new script queries GitHub GraphQL for unresolved CodeRabbit threads and reports them. | - -## Sequence Diagram(s) -```mermaid -sequenceDiagram - autonumber - actor EdgeCreator as Edge Creator - participant BI as gm_edge_resolve_blob_identity - participant Port as Git Repository Port - - EdgeCreator->>BI: resolve_blob_identity(ctx, path, out_oid, legacy_sha) - BI->>Port: gm_git_repository_port_resolve_blob_at_head(path) - Port-->>BI: oid_bytes / error - - alt port success - BI->>BI: copy min(GM_OID_RAWSZ, GM_SHA1_SIZE) → legacy_sha - BI->>BI: zero-pad remainder if copy_len < GM_SHA1_SIZE - BI-->>EdgeCreator: GM_OK (out_oid, legacy_sha) - else port error - BI->>BI: zero legacy_sha - BI-->>EdgeCreator: error (propagate) - end -``` - -## Estimated code review effort -🎯 4 (Complex) | ⏱️ ~50 minutes - -## Possibly related PRs -- neuroglyph/git-mind#165 — Overlaps OID-first migration and edge/blob identity helpers; likely continued work on same APIs. -- neuroglyph/git-mind#166 — Related changes to edge blob identity and OID/hex utilities integration. -- neuroglyph/git-mind#169 — Touches OID/ref/edge handling and replacement of direct git2 oid logic; strongly related. - -## Poem -> I nibble bytes and spin them hex, -> I hop through blobs and mend the specs, -> I guard the paths and tidy docs, -> I patch the tests and hush the clocks, -> A rabbit’s hop, a tiny fix—🐇✨ - - - - - -## Pre-merge checks and finishing touches -
-❌ Failed checks (2 warnings, 1 inconclusive) - -| Check name | Status | Explanation | Resolution | -| :----------------: | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| Description Check | ⚠️ Warning | The provided description is a long unstructured list of commit-style entries and does not follow the repository’s required template, which mandates distinct sections for Summary, Change Areas, Risk, and Code Review Guidance. Without these headings and checkbox fields, it is unclear what high-level problem is being solved, which areas are impacted, or how reviewers should prioritize risks and feedback. The current format makes it difficult to quickly assess scope, impact, and testing guidance. | Please restructure the PR description to match the repository template by adding a “## Summary” section that concisely describes the change and its rationale, a “## Change Areas” list with checked boxes for Core, CLI/Hooks, Docs, and CI/Tooling as appropriate, a “## Risk” section indicating behavior changes or public API impacts, and a “## Code Review Guidance” section with top-risk notes and suggested fix-it blocks. This will ensure reviewers can quickly understand scope, impact, and guidance. | -| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run `@coderabbitai generate docstrings` to improve docstring coverage. | -| Title Check | ❓ Inconclusive | The title “chore/code rabbit cleanup” is overly generic and does not clearly convey the primary functional changes introduced in this PR, such as the migration to a new git_repository_port abstraction or the addition of OID hex utilities. It does not read as a coherent sentence and omits important context about the core refactoring and feature enhancements. As a result, reviewers scanning the commit history may not quickly grasp the scope or intent of the changes. | Please revise the title to succinctly summarize the main change in a single clear sentence, for example “refactor(core): introduce gm_git_repository_port abstraction and decouple legacy git ops” or “feat(util): add OID hex utilities and integrate in cache and edge modules,” so that it immediately communicates the PR’s core purpose to readers. | - -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - - - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -> [!note]- **Accepted** -> Standing by for CodeRabbit's follow-up. diff --git a/docs/code-reviews/PR172/d11ee830d5615e5582114d625a52283760d61767.md b/docs/code-reviews/PR172/d11ee830d5615e5582114d625a52283760d61767.md deleted file mode 100644 index 4d7c077d..00000000 --- a/docs/code-reviews/PR172/d11ee830d5615e5582114d625a52283760d61767.md +++ /dev/null @@ -1,837 +0,0 @@ ---- -title: d11ee830d5615e5582114d625a52283760d61767.md -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `d11ee830d5615e5582114d625a52283760d61767` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Fix legacy buffer padding description.** - -The implementation zero-fills the legacy SHA buffer only when `GM_OID_RAWSZ` is *smaller* than `GM_SHA1_SIZE`. The doc currently says “exceeds,” so the guidance is inverted. Please update the phrasing so callers understand when padding happens. - -```diff -- * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -- * exceeds `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -+ * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` -+ * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - * On success, both the preferred OID (`out_oid`) and the legacy SHA-1 buffer - * (`legacy_sha`, sized to `GM_SHA1_SIZE`) are populated. When `GM_OID_RAWSZ` - * is smaller than `GM_SHA1_SIZE`, the legacy buffer is zero-padded to maintain - * deterministic contents. Callers must provide non-null pointers. -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/include/gitmind/edge/internal/blob_identity.h around lines 20 to 23, the -comment incorrectly states that the legacy SHA buffer is zero-padded when -GM_OID_RAWSZ "exceeds" GM_SHA1_SIZE; update the phrasing to say that the legacy -buffer is zero-padded when GM_OID_RAWSZ is smaller than GM_SHA1_SIZE (i.e., when -the preferred OID raw size is less than the legacy SHA-1 size), so callers know -padding happens to fill the remainder of the legacy buffer to GM_SHA1_SIZE; -ensure callers still know to provide non-null pointers. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101775 - -{response} - -### core/src/util/oid.c:44 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard against overflow before sizing the hex buffer** - -`required = (len * 2U) + 1U` can overflow `size_t` for large inputs, which lets the length check pass with a wrapped value and we then scribble past `out` while the loop iterates `len` times. Please short-circuit when `len` exceeds the safe range before doing the multiply. - - - -```diff -@@ -- const size_t required = (len * 2U) + 1U; -+ if (len > (SIZE_MAX - 1U) / 2U) { -+ gm_memset_safe(out, out_size, 0, out_size); -+ return GM_ERR_INVALID_ARGUMENT; -+ } -+ -+ const size_t required = (len * 2U) + 1U; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (len > (SIZE_MAX - 1U) / 2U) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_INVALID_ARGUMENT; - } - - const size_t required = (len * 2U) + 1U; - if (out_size < required) { - gm_memset_safe(out, out_size, 0, out_size); - return GM_ERR_BUFFER_TOO_SMALL; - } - - for (size_t i = 0; i < len; ++i) { - unsigned byte = bytes[i]; - out[i * 2U] = KHexDigits[(byte >> KNibbleBits) & KNibbleMask]; - out[(i * 2U) + 1U] = KHexDigits[byte & KNibbleMask]; - } - out[len * 2U] = '\0'; -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/util/oid.c around lines 27-38, the computed required = (len * 2U) + -1U can overflow size_t for large len; before performing the multiply, check that -len does not exceed (SIZE_MAX - 1) / 2 (or equivalent safe_max) and if it does, -zero the output buffer via gm_memset_safe and return GM_ERR_BUFFER_TOO_SMALL (or -an appropriate error). After that guard, compute required normally, perform the -existing out_size check and proceed with the hex conversion. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101784 - -{response} - -### docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md:22 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required Table of Contents and title alignment** - -Docs under `docs/**` must include a `## Table of Contents` section and keep the front-matter `title` in sync with the H1. This file omits the TOC and the front-matter title (`203f4e3539b1d8fc73b641e94b0a420f2e592a14.md`) does not match the H1 (`Code Review Feedback`). Please add the missing TOC heading and align the title/H1 pair. As per coding guidelines. - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md lines -1-18, the front-matter title does not match the H1 and the required "## Table of -Contents" section is missing; update the YAML front-matter title to exactly -"Code Review Feedback" to match the H1 and insert a "## Table of Contents" -heading (with any preferred TOC entries or a placeholder) immediately after the -H1 so the document follows the docs/** guidelines. -``` - -
- - - - - -✅ Addressed in commits fecc9d6 to d11ee83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385101790 - -{response} - -### .github/workflows/review-artifact-cleanup.yml:48 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix checkout to track a branch before pushing** - -`actions/checkout` on a `pull_request` event leaves the repo in a detached HEAD at `refs/pull//merge`. The later `git push` step then fails with “You are not currently on a branch,” so the cleanup commit never lands. Check out the base branch (or push `HEAD` explicitly) before removing files. - - -```diff - - name: Checkout repository - uses: actions/checkout@v4 - with: -- fetch-depth: 0 -+ fetch-depth: 0 -+ ref: ${{ github.event.pull_request.base.ref }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.base.ref }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/review-artifact-cleanup.yml lines 18-47: the job checks out -the PR merge ref (detached HEAD) so later git commit/push fails; change the -checkout to track the target branch before making the cleanup commit. Either set -actions/checkout to the pull_request base ref (use ref: ${{ -github.event.pull_request.base.ref }} and fetch-depth: 0) or, immediately after -the existing checkout, fetch from origin and create/checkout a local branch that -tracks the PR base branch (so commits are made on a branch and can be pushed); -ensure the branch is tracking origin/ before the git commit and git push -steps. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144548 - -{response} - -### docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md:27 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix doc front matter/title alignment and add required TOC** - -`docs/**` files must keep the front-matter `title` identical to the H1 and include a `## Table of Contents` section immediately after the H1. This file’s title still uses the SHA filename and the TOC is missing. Update the title to “Code Review Feedback” and add the TOC block so the doc complies with the repo guidelines. - -```diff - --- --title: 5add14fcdabafff59a99ea484d691140afdb68c3.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `5add14fcdabafff59a99ea484d691140afdb68c3` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md around -lines 1 to 16, the front-matter title is the SHA and the document is missing a -required Table of Contents; update the YAML front-matter title value to "Code -Review Feedback" so it matches the H1, and immediately after the H1 insert a "## -Table of Contents" section (with the standard TOC entries used across docs/) so -the file complies with repo guidelines. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385144568 - -{response} - -### .github/workflows/coderabbit-status.yml:27 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix: install Python dependency used by the script (requests).** - -The workflow runs a script that imports requests, but there’s no install step. This will fail with ModuleNotFoundError in CI. - -Apply this diff to add an install step: - -```diff - - name: Set up Python - uses: actions/setup-python@v5 - with: -- python-version: '3.x' -+ python-version: '3.x' -+ - name: Install dependencies -+ run: | -+ python -m pip install --upgrade pip -+ python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install requests - - name: Check unresolved CodeRabbit threads - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python3 tools/review/check_coderabbit_threads.py \ - --owner "${GITHUB_REPOSITORY%%/*}" \ - --repo "${GITHUB_REPOSITORY##*/}" \ - --pr ${{ github.event.number }} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -.github/workflows/coderabbit-status.yml around lines 16 to 23: the CI job sets -up Python but never installs the requests dependency required by the script, -causing ModuleNotFoundError; add a step after "Set up Python" to install the -dependency (e.g., run pip install requests --upgrade or pip3 install requests) -so the script can import requests successfully during the workflow run. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271905 - -{response} - -### docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md:20 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Align title with H1 and add the required TOC** - -Docs under `docs/**` have to mirror the H1 in the front matter `title` and include an explicit `## Table of Contents` immediately after the H1. Please update both so this artifact stays compliant. As per coding guidelines - -```diff - --- --title: 8a32c6a810ebf632709cec6c928381c9c47fdee9.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md lines -2-20, the front-matter title must match the document's H1 and you must insert an -explicit "## Table of Contents" immediately after the H1; update the YAML -front-matter title to exactly match the H1 text and add a "## Table of Contents" -header directly below the H1 (populate with relevant links or placeholders) so -the file conforms to the docs guideline. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385271909 - -{response} - -### docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md:23 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Doc still violates the title/TOC requirement.** - -The YAML `title` must match the H1 and we need a “## Table of Contents” section right after the H1. Please update both to satisfy the repository doc rules. - - -```diff - --- --title: 82dab217893b6ee8bb8dcdca2217f9900a06b76f.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` -As per coding guidelines. - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive ---- - - # Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `82dab217893b6ee8bb8dcdca2217f9900a06b76f` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK - -### core/include/gitmind/edge/internal/blob_identity.h:23 — coderabbitai[bot] - -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md around -lines 1 to 23, the YAML front-matter title does not match the H1 and the -document is missing a “## Table of Contents” section immediately after the H1; -update the YAML title to exactly match the H1 text, add a “## Table of Contents” -heading right after the H1 (with any required TOC entries or a placeholder), and -ensure the TOC appears directly below the H1 to conform to repository doc rules. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385399829 - -{response} - -### docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md:16 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required TOC and align title with H1.** - -Docs under `docs/**` must keep the front-matter `title` identical to the H1 and include a `## Table of Contents` immediately after the H1. This file still uses the SHA for `title` and omits the TOC, so it violates the documented style requirements. Please update the title to match the H1 and add the missing TOC block. As per coding guidelines. - -Apply this diff to fix both issues: - -```diff ---- --title: b22c22398de39c4ab93e1c747b1122d2241eed22.md -+title: Code Review Feedback - description: Preserved review artifacts and rationale. - audience: [contributors] - domain: [quality] - tags: [review] - status: archive - --- - - # Code Review Feedback -+ -+## Table of Contents -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `b22c22398de39c4ab93e1c747b1122d2241eed22` | [chore/code-rabbit-cleanup](https://github.com/neuroglyph/git-mind/tree/chore/code-rabbit-cleanup "neuroglyph/git-mind:chore/code-rabbit-cleanup") | [PR#172](https://github.com/neuroglyph/git-mind/pull/172) | - -## CODE REVIEW FEEDBACK -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md around -lines 2 to 16, the front-matter title is set to the SHA and the document is -missing a "## Table of Contents" immediately after the H1; update the YAML -front-matter title to exactly match the file's H1 text and insert a "## Table of -Contents" block directly after the H1 heading so the front-matter title and H1 -are identical and the TOC appears in the required location. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#discussion_r2385399838 - -{response} - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between 208b5f7679362fab107e339f9e41cde665efa409 and d11ee830d5615e5582114d625a52283760d61767. -> ->
-> ->
-> 📒 Files selected for processing (9) -> -> * `.github/workflows/coderabbit-status.yml` (1 hunks) -> * `.github/workflows/review-artifact-cleanup.yml` (1 hunks) -> * `core/src/util/oid.c` (1 hunks) -> * `docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md` (1 hunks) -> * `docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md` (1 hunks) -> * `docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md` (1 hunks) -> * `docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md` (1 hunks) -> * `docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md` (1 hunks) -> * `docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md` (1 hunks) -> ->
-> -> ```ascii -> ___________________________________________________________________________________________ -> < I'm the Doctor. Well, a doctor of code, and I'm here to fix the timeline of your project. > -> ------------------------------------------------------------------------------------------- -> \ -> \ \ -> \ /\ -> ( ) -> .( o ). -> ``` - - - - - -## Walkthrough -Adds two OID-to-hex utilities and a blob-identity resolver, wires them into edge/cache/query code paths, hardens filesystem path parsing and fake-git test copies, adds the new sources to the build, updates review/CI tooling (worksheets checker, review-artifact-cleanup, coderabbit status), and adjusts many review-doc artifacts and AGENTS.md entries. - -## Changes -| Cohort / File(s) | Summary | -|---|---| -| **OID hex utilities (new API)**
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | New `gm_bytes_to_hex` and `gm_oid_to_hex` declarations and implementations with input validation, buffer-size checks, safe zeroing, and NUL termination. | -| **Adopt OID hex helpers**
`core/src/app/cache/cache_rebuild_service.c`, `core/src/cache/query.c` | Replace direct git2 oid-to-hex formatting with `gm_oid_to_hex` / `gm_bytes_to_hex`; add buffer initialization and error handling; include new util header. | -| **Blob identity resolver (new helper) + integration**
`core/include/gitmind/edge/internal/blob_identity.h`, `core/src/edge/internal/blob_identity.c`, `core/src/edge/edge.c`, `core/src/edge/attributed.c` | Add `gm_edge_resolve_blob_identity`; centralize blob resolution via repository port, produce `out_oid` and legacy SHA buffer (with zero-padding), and propagate port/errors; edge creation paths now call the helper. | -| **Filesystem path utils hardening**
`core/src/fs/path_utils.c` | Added dynamic `max_segments` parameter to parsing, updated callers, and guarded segment emission against output-buffer overruns, returning path-too-long on overflow. | -| **Fake git repo port safety**
`core/tests/fakes/git/fake_git_repository_port.c` | Check `gm_strcpy_safe` return values; clear destinations and return `GM_ERR_BUFFER_TOO_SMALL` when copies exceed buffers. | -| **Cache header comment move**
`core/include/gitmind/cache.h` | Relocated a struct-tail comment; no layout/type/API changes. | -| **Build configuration**
`meson.build` | Add `core/src/edge/internal/blob_identity.c` and `core/src/util/oid.c` to source list. | -| **Docs & review artifacts**
`docs/code-reviews/*`, `docs/code-reviews/PR172/*`, `AGENTS.md` | Remove many archived/rejected review docs, add PR172 review artifacts, and append a 2025-09-28 entry to `AGENTS.md`. | -| **Worksheet checker tweak**
`tools/review/check_worksheets.py` | Treat deleted worksheet files as acceptable by returning an empty problems list on FileNotFoundError. | -| **CI workflow: review artifact cleanup**
`.github/workflows/review-artifact-cleanup.yml` | New workflow to delete per-PR review artifacts on merged PRs and commit/push cleanup when changes exist. | -| **Coderabbit status workflow & tooling**
`.github/workflows/coderabbit-status.yml`, `tools/review/check_coderabbit_threads.py` | Add workflow and script to scan PRs for unresolved CodeRabbit threads via GitHub GraphQL and report them. | - -## Sequence Diagram(s) -```mermaid -sequenceDiagram - autonumber - actor EdgeCreator as Edge Creator - participant BI as gm_edge_resolve_blob_identity - participant Port as Git Repository Port - - EdgeCreator->>BI: resolve_blob_identity(ctx, path, out_oid, legacy_sha) - BI->>Port: gm_git_repository_port_resolve_blob_at_head(path) - Port-->>BI: oid_bytes / error - - alt port success - BI->>BI: copy min(GM_OID_RAWSZ, GM_SHA1_SIZE) → legacy_sha - BI->>BI: zero-pad remainder if copy_len < GM_SHA1_SIZE - BI-->>EdgeCreator: GM_OK (out_oid, legacy_sha) - else port error - BI->>BI: zero legacy_sha - BI-->>EdgeCreator: error (propagate) - end -``` - -## Estimated code review effort -🎯 4 (Complex) | ⏱️ ~50 minutes - -## Possibly related PRs -- neuroglyph/git-mind#165 — Continues OID-first migration and edge/blob-identity helper work; overlaps the same APIs and integration points. -- neuroglyph/git-mind#169 — Related refactors touching OID/hex handling and edge/ref construction used by this change. -- neuroglyph/git-mind#171 — Related repository-port and blob-resolution changes; likely shares design/port calls with the new resolver. - -## Poem -> I nibble bytes and spin them hex, -> I hop through blobs and mend the specs, -> I guard the paths and tidy docs, -> I patch the tests and hush the clocks, -> A rabbit’s hop, a tiny fix—🐇✨ - - - - - -## Pre-merge checks and finishing touches -
-❌ Failed checks (2 warnings) - -| Check name | Status | Explanation | Resolution | -| :---------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Title Check | ⚠️ Warning | The pull request title “chore/code rabbit cleanup” is too vague and does not reflect the primary content of the changeset, which is a large-scale refactor introducing a gm_git_repository_port abstraction, new OID hex utilities, blob identity resolution helpers, and related integrations; instead it references the external CodeRabbit tool and suggests a minor cleanup chore rather than the significant architectural and API changes being made. | Please rename the title to clearly summarize the main change, for example “refactor(core): introduce gm_git_repository_port and OID hex utility APIs” or “feat: add blob identity resolver and hex conversion helpers via repository port abstraction,” so that it accurately conveys the scope and intent of the PR. | -| Description Check | ⚠️ Warning | The pull request description does not follow the repository’s required template: it lacks the mandated “## Summary,” “## Change Areas,” “## Risk,” and “## Code Review Guidance” sections with checkboxes and structured detail, and instead consists of a long list of commit message excerpts without contextual explanation or categorization of changes and risks. | Please reformat the description to match the template by adding a concise “## Summary” explaining the change and motivation, a “## Change Areas” checklist indicating impacted subsystems, a “## Risk” checklist for behavior or API changes, and a “## Code Review Guidance” section to highlight top risks and guidance for reviewers. | - -
-
-✅ Passed checks (1 passed) - -| Check name | Status | Explanation | -| :----------------: | :------- | :------------------------------------------------------------------- | -| Docstring Coverage | ✅ Passed | No functions found in the changes. Docstring coverage check skipped. | - -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - - - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/172#issuecomment-3342580469 - -{response} - From b97f3665c068c06b27f76df1727cae63c40f61e4 Mon Sep 17 00:00:00 2001 From: "J. Kirby Ross" Date: Sun, 28 Sep 2025 23:55:02 -0700 Subject: [PATCH 2/8] docs(activity): log worksheet cleanup and drop pr171 artifact --- AGENTS.md | 4 + ...42d2ac051f5ae32ef5b07c44d7765bd392136d5.md | 4878 ----------------- 2 files changed, 4 insertions(+), 4878 deletions(-) delete mode 100644 docs/code-reviews/PR171/542d2ac051f5ae32ef5b07c44d7765bd392136d5.md diff --git a/AGENTS.md b/AGENTS.md index 26350620..abb9d20a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -449,6 +449,10 @@ See archives under `docs/activity/` for older logs. * Sweep for any lingering `fprintf` debug traces before shipping. * Run CodeRabbit worksheet checker again after touching docs to ensure no new “Decision:” gaps. - Today’s continuation: pulled the trigger on that list—extracted `gm_edge_resolve_blob_identity` into `core/src/edge/internal/blob_identity.c`, introduced `gm_bytes_to_hex`/`gm_oid_to_hex`, and refactored cache rebuild/query to drop `git_oid_fmt/tostr`; `make ci-local` is green and `tools/review/check_worksheets.py docs/code-reviews/PR171/*.md` still flags the known undecided sections (see console), so next slot should be worksheet triage + CodeRabbit replies. +- Draft Punks spin-out begun: workflows (`auto-seed-review`, `apply-feedback`, `review-artifact-cleanup`, `coderabbit-status`, `seed-review`) and review scripts copied into `/Users/james/git/draft-punks/`; README drafted in character for future extraction of the review tooling. +- PR #172 merged; local `main` fast-forwarded to `069ff59`. Seeded worksheet artifacts under `docs/code-reviews/PR172/` deleted from the repo (these are post-merge and live only in history now). +- On branch `feat/edge-port-followup`, swapped remaining edge/journal code to rely on `gm_oid_to_hex` instead of `git_oid_tostr`, removed lingering `` from cache/edge modules, and cleaned the tree in preparation for further edge migration. +- Next up: continue the edge/augment migration by auditing `core/src/hooks/augment.c`, `core/src/domain/cache/edge_map.c`, and `core/src/journal/writer.c` for lingering libgit2 helpers (e.g., `git_oid_cmp`, `git_oid_is_zero`, `git_oid_fromraw`) and replace them with gm-level utilities/ports as needed. - Follow-up (same day): cleaned up CodeRabbit’s fake-port feedback—fake commit/update paths now surface `gm_strcpy_safe` truncations, the shared OID helpers carry project-compliant naming/includes, and the deleted worksheet directory is ready for a fresh seed if we decide to log post-merge notes. - Quick-start when you return: rerun `make ci-local` if you touch the cache/journal surface, then tackle the shared blob helper → oid hex helper chain; once that’s in place, prep the PR summary referencing the fast-forward protections. diff --git a/docs/code-reviews/PR171/542d2ac051f5ae32ef5b07c44d7765bd392136d5.md b/docs/code-reviews/PR171/542d2ac051f5ae32ef5b07c44d7765bd392136d5.md deleted file mode 100644 index 9be25957..00000000 --- a/docs/code-reviews/PR171/542d2ac051f5ae32ef5b07c44d7765bd392136d5.md +++ /dev/null @@ -1,4878 +0,0 @@ ---- -title: 542d2ac051f5ae32ef5b07c44d7765bd392136d5.md -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-28 | CodeRabbit (and reviewers) | `542d2ac051f5ae32ef5b07c44d7765bd392136d5` | [chore/more-fixes](https://github.com/neuroglyph/git-mind/tree/chore/more-fixes "neuroglyph/git-mind:chore/more-fixes") | [PR#171](https://github.com/neuroglyph/git-mind/pull/171) | - -## CODE REVIEW FEEDBACK - -### benchmarks/wildebeest_stampede.c:120 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix the gm_cache_query_fanout argument type** - -`gm_cache_query_fanout` takes a `const gm_oid_t *`, but the calls here pass a raw `uint8_t*`. This fails to compile (pointer type mismatch) and bypasses the API contract. Wrap the SHA in a `gm_oid_t` and pass its address. - - - -```diff -- uint8_t mufasa_sha[GM_SHA1_SIZE]; -- generate_wildebeest_sha(mufasa_sha); -+ gm_oid_t mufasa_oid = {0}; -+ generate_wildebeest_sha(mufasa_oid.id); -@@ -- memcpy(beast->tgt_sha, mufasa_sha, GM_SHA1_SIZE); -+ memcpy(beast->tgt_sha, mufasa_oid.id, GM_SHA1_SIZE); -@@ -- memcpy(beast->src_sha, mufasa_sha, GM_SHA1_SIZE); -+ memcpy(beast->src_sha, mufasa_oid.id, GM_SHA1_SIZE); -@@ -- gm_cache_query_fanout(&ctx, branch, mufasa_sha, &scan_result); -+ gm_cache_query_fanout(&ctx, branch, &mufasa_oid, &scan_result); -@@ -- gm_cache_query_fanout(&ctx, branch, mufasa_sha, &cache_result); -+ gm_cache_query_fanout(&ctx, branch, &mufasa_oid, &cache_result); -``` - - -Also applies to: 138-139 - -
-🤖 Prompt for AI Agents - -``` -In benchmarks/wildebeest_stampede.c around lines 119-120 (and similarly at -138-139), the call to gm_cache_query_fanout passes a raw uint8_t* (the SHA) but -the function signature expects a const gm_oid_t*; create a gm_oid_t variable, -copy or assign the SHA bytes into its internal buffer as required by gm_oid_t, -and then call gm_cache_query_fanout(&ctx, branch, &your_gm_oid_var, -&scan_result) to pass the address of the gm_oid_t (ensuring const correctness). -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074004 - -{response} - -### core/src/fs/path_utils.c:93 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Remove the new NOLINT suppression** - -The updated code no longer uses `memcpy`, so the newly added `// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)` is now redundant and violates our C coding guideline: “NEVER use `NOLINT`; fix the underlying issue.” Please drop the suppression. - -```diff -- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling) - if (gm_memcpy_span(output + dst, output_size - dst, segment, seg_len) != 0) { -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (gm_memcpy_span(output + dst, output_size - dst, segment, seg_len) != 0) { - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "normalized path exceeds buffer")); - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/fs/path_utils.c around lines 89 to 93, remove the now-redundant -NOLINT suppression comment (“// -NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling”) -because memcpy is no longer used; simply delete that comment line and ensure the -surrounding code and formatting remain unchanged and no other NOLINT is -introduced for this block. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074006 - -{response} - -### core/src/hooks/augment.c:146 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Detached HEAD lookup regression** - -`gm_git_repository_port_head_branch` returns `GM_ERR_NOT_FOUND` whenever the repo is checked out in a detached HEAD (very common in CI). With the new early return, `gm_hook_get_blob_sha` bubbles that error up, so `gm_hook_process_changed_file` treats every change as “new file” and skips augment edge updates entirely in those environments. Please fall back to walking `HEAD` whenever the symbolic branch lookup fails instead of bailing out. - - - -```diff -- char branch[BUFFER_SIZE_SMALL]; -- gm_result_void_t branch_result = -- gm_git_repository_port_head_branch(repo_port, branch, sizeof(branch)); -- int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); -- if (branch_rc != GM_OK) { -- return branch_rc; -- } -- -- char ref_name[REF_NAME_BUFFER_SIZE]; -- int ref_rc = -- gm_build_ref(ref_name, sizeof(ref_name), REFS_HEADS_PREFIX, branch); -- if (ref_rc != GM_OK) { -- return ref_rc; -- } -- - const size_t required_commits = offset + 1U; - gm_oid_t commit_buffer[GM_AUGMENT_LOOKBACK_LIMIT]; - hook_commit_collect_ctx_t collect_ctx = { - .storage = commit_buffer, - .capacity = required_commits, - .count = 0U, - }; - -- gm_result_void_t walk_result = gm_git_repository_port_walk_commits( -- repo_port, ref_name, collect_commit_oid, &collect_ctx); -+ const char *walk_ref = "HEAD"; -+ char branch[BUFFER_SIZE_SMALL]; -+ char ref_name[REF_NAME_BUFFER_SIZE]; -+ gm_result_void_t branch_result = -+ gm_git_repository_port_head_branch(repo_port, branch, sizeof(branch)); -+ int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); -+ if (branch_rc == GM_OK) { -+ int ref_rc = gm_build_ref(ref_name, sizeof(ref_name), REFS_HEADS_PREFIX, -+ branch); -+ if (ref_rc == GM_OK) { -+ walk_ref = ref_name; -+ } -+ } else if (branch_rc != GM_ERR_NOT_FOUND) { -+ return branch_rc; -+ } -+ -+ gm_result_void_t walk_result = gm_git_repository_port_walk_commits( -+ repo_port, walk_ref, collect_commit_oid, &collect_ctx); -``` - -
-🤖 Prompt for AI Agents - -``` -In core/src/hooks/augment.c around lines 120 to 146, the code returns early when -gm_git_repository_port_head_branch reports GM_ERR_NOT_FOUND (detached HEAD), -which causes augment to skip edge updates; change the control flow so that if -hook_result_to_code(branch_result, ...) yields GM_ERR_NOT_FOUND you do not -return but instead set ref_name to "HEAD" (or otherwise use "HEAD" as the ref to -walk) and proceed to build/walk commits from HEAD; only return on non-not-found -errors, and ensure subsequent logic uses the fallback ref when branch lookup -failed. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074008 - -{response} - -### core/src/hooks/augment.c:358 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Merge detection fails on detached HEAD** - -For the same reason, `gm_hook_is_merge_commit` now returns an error instead of answering if HEAD is detached, even though we can still inspect the current commit. Please keep the branch-based path, but fall back to querying `HEAD` directly when the symbolic branch is missing. - - - -```diff -- char branch[BUFFER_SIZE_SMALL]; -- gm_result_void_t branch_result = -- gm_git_repository_port_head_branch(repo_port, branch, sizeof(branch)); -- int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); -- if (branch_rc != GM_OK) { -- return branch_rc; -- } -- -- char ref_name[REF_NAME_BUFFER_SIZE]; -- int ref_rc = -- gm_build_ref(ref_name, sizeof(ref_name), REFS_HEADS_PREFIX, branch); -- if (ref_rc != GM_OK) { -- return ref_rc; -- } -- - gm_git_reference_tip_t tip; - gm_memset_safe(&tip, sizeof(tip), 0, sizeof(tip)); -- gm_result_void_t tip_result = -- gm_git_repository_port_reference_tip(repo_port, ref_name, &tip); -+ const char *ref_to_query = "HEAD"; -+ char branch[BUFFER_SIZE_SMALL]; -+ char ref_name[REF_NAME_BUFFER_SIZE]; -+ gm_result_void_t branch_result = -+ gm_git_repository_port_head_branch(repo_port, branch, sizeof(branch)); -+ int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); -+ if (branch_rc == GM_OK) { -+ int ref_rc = -+ gm_build_ref(ref_name, sizeof(ref_name), REFS_HEADS_PREFIX, branch); -+ if (ref_rc == GM_OK) { -+ ref_to_query = ref_name; -+ } -+ } else if (branch_rc != GM_ERR_NOT_FOUND) { -+ return branch_rc; -+ } -+ -+ gm_result_void_t tip_result = -+ gm_git_repository_port_reference_tip(repo_port, ref_to_query, &tip); -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - gm_git_reference_tip_t tip; - gm_memset_safe(&tip, sizeof(tip), 0, sizeof(tip)); - - const char *ref_to_query = "HEAD"; - char branch[BUFFER_SIZE_SMALL]; - char ref_name[REF_NAME_BUFFER_SIZE]; - gm_result_void_t branch_result = - gm_git_repository_port_head_branch(repo_port, branch, sizeof(branch)); - int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); - if (branch_rc == GM_OK) { - int ref_rc = - gm_build_ref(ref_name, sizeof(ref_name), REFS_HEADS_PREFIX, branch); - if (ref_rc == GM_OK) { - ref_to_query = ref_name; - } - } else if (branch_rc != GM_ERR_NOT_FOUND) { - return branch_rc; - } - - gm_result_void_t tip_result = - gm_git_repository_port_reference_tip(repo_port, ref_to_query, &tip); - int tip_rc = hook_result_to_code(tip_result, GM_ERR_NOT_FOUND); - if (tip_rc != GM_OK || !tip.has_target) { - *is_merge = false; - return tip_rc; - } - - size_t parent_total = 0U; - gm_result_void_t parent_result = gm_git_repository_port_commit_parent_count( - repo_port, &tip.oid, &parent_total); - int parent_rc = hook_result_to_code(parent_result, GM_ERR_UNKNOWN); - if (parent_rc != GM_OK) { - *is_merge = false; - return parent_rc; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/hooks/augment.c around lines 301 to 333, the current flow returns an -error when the branch lookup fails causing merge detection to abort on detached -HEAD; instead preserve the branch-based path but fall back to querying HEAD -directly: if hook_result_to_code(branch_result, ...) yields GM_ERR_NOT_FOUND, do -not return—set ref_name to "HEAD" (or otherwise skip gm_build_ref and use the -literal "HEAD") and proceed to call -gm_git_repository_port_reference_tip(repo_port, ref_name, &tip); keep the -existing error handling for other branch errors, and ensure subsequent parent -count logic still runs using the tip obtained from HEAD when branch was missing. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074011 - -{response} - -### core/src/journal/writer.c:149 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Abort commit creation when parent walk fails** - -If `gm_git_repository_port_walk_commits` returns an error we currently free the error object but still fall through and create the journal commit without parents. That produces an orphan/root commit and forces the ref update to rewrite history, which is a data-loss bug under real failures. We need to stop immediately and surface the upstream error code. - -```diff -- gm_result_void_t walk_result = gm_git_repository_port_walk_commits( -- jctx->repo_port, jctx->ref_name, collect_parent_tip, &lookup_ctx); -- if (!walk_result.ok && walk_result.u.err != NULL) { -- gm_error_free(walk_result.u.err); -- } -+ gm_result_void_t walk_result = gm_git_repository_port_walk_commits( -+ jctx->repo_port, jctx->ref_name, collect_parent_tip, &lookup_ctx); -+ if (!walk_result.ok) { -+ int walk_code = GM_ERR_UNKNOWN; -+ if (walk_result.u.err != NULL) { -+ walk_code = walk_result.u.err->code; -+ gm_error_free(walk_result.u.err); -+ } -+ return walk_code; -+ } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - gm_result_void_t walk_result = gm_git_repository_port_walk_commits( - jctx->repo_port, jctx->ref_name, collect_parent_tip, &lookup_ctx); - if (!walk_result.ok) { - int walk_code = GM_ERR_UNKNOWN; - if (walk_result.u.err != NULL) { - walk_code = walk_result.u.err->code; - gm_error_free(walk_result.u.err); - } - return walk_code; - } - - char *message = NULL; - int message_rc = encode_cbor_message(cbor_data, cbor_len, &message, NULL); - if (message_rc != GM_OK) { - return message_rc; - } - - const gm_oid_t *parent_list = NULL; - size_t parent_count = 0U; - if (lookup_ctx.found) { - parent_list = &lookup_ctx.tip.oid; - parent_count = 1U; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/journal/writer.c around lines 127 to 144, the code currently frees -the error returned by gm_git_repository_port_walk_commits but continues, -producing an orphan commit; instead, if walk_result.ok is false you must abort: -capture the error return code (e.g. store walk_result.u.err->code into a local -int), free the error object, and immediately return that error code (or a -suitable generic error if u.err is NULL) so commit creation does not proceed on -a failed parent walk. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074015 - -{response} - -### core/tests/fakes/git/fake_git_repository_port.c:566 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Reset cached tree OID to avoid repeating it** - -Once `fake->next_tree_oid` is set (either by tests or by the first auto-generated value) we never clear it, so every subsequent `build_tree_from_directory` call returns the same OID. That diverges from libgit2’s behaviour and breaks scenarios expecting unique tree hashes. Please consume the cached value and clear it before falling back to auto generation. - - -```diff -@@ -- if (out_tree_oid != NULL) { -- if (fake->next_tree_oid.id[0] == 0) { -- fake->counter += 1U; -- memset(out_tree_oid, 0, sizeof(*out_tree_oid)); -- out_tree_oid->id[0] = (unsigned char)(fake->counter & 0xFFU); -- fake->next_tree_oid = *out_tree_oid; -- } else { -- *out_tree_oid = fake->next_tree_oid; -- } -- } -+ if (out_tree_oid == NULL) { -+ return gm_ok_void(); -+ } -+ -+ if (fake->next_tree_oid.id[0] != 0U) { -+ *out_tree_oid = fake->next_tree_oid; -+ gm_memset_safe(&fake->next_tree_oid, sizeof(fake->next_tree_oid), 0, -+ sizeof(fake->next_tree_oid)); -+ return gm_ok_void(); -+ } -+ -+ fake->counter += 1U; -+ gm_memset_safe(out_tree_oid, sizeof(*out_tree_oid), 0, -+ sizeof(*out_tree_oid)); -+ out_tree_oid->id[0] = (unsigned char)(fake->counter & 0xFFU); -``` - -
-🤖 Prompt for AI Agents - -``` -In core/tests/fakes/git/fake_git_repository_port.c around lines 558 to 566, the -code returns fake->next_tree_oid on subsequent calls but never clears it, -causing repeated identical tree OIDs; change the logic so that when out_tree_oid -is set from fake->next_tree_oid you consume it by copying it to out_tree_oid and -then reset fake->next_tree_oid to the zero/empty state (e.g., zero its bytes) so -future calls will fall back to auto-generation, ensuring unique OIDs unless -explicitly preset by tests. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074019 - -{response} - -### core/tests/fakes/git/fake_git_repository_port.c:724 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Consume `next_commit_oid` after use** - -Because `fake->next_commit_oid` is never cleared, every commit after the first reuses the same OID, which makes the fake port lie about unique commits and breaks tests that depend on distinct hashes. Please consume the cached value and reset it before falling back to the auto-generated path. - - -```diff -@@ -- if (out_commit_oid != NULL) { -- if (fake->next_commit_oid.id[0] == 0) { -- fake->counter += 1U; -- memset(out_commit_oid, 0, sizeof(*out_commit_oid)); -- out_commit_oid->id[0] = -- (unsigned char)((fake->counter >> 1U) & 0xFFU); -- fake->next_commit_oid = *out_commit_oid; -- } else { -- *out_commit_oid = fake->next_commit_oid; -- } -- } -+ if (out_commit_oid == NULL) { -+ return gm_ok_void(); -+ } -+ -+ if (fake->next_commit_oid.id[0] != 0U) { -+ *out_commit_oid = fake->next_commit_oid; -+ gm_memset_safe(&fake->next_commit_oid, sizeof(fake->next_commit_oid), 0, -+ sizeof(fake->next_commit_oid)); -+ return gm_ok_void(); -+ } -+ -+ fake->counter += 1U; -+ gm_memset_safe(out_commit_oid, sizeof(*out_commit_oid), 0, -+ sizeof(*out_commit_oid)); -+ out_commit_oid->id[0] = -+ (unsigned char)((fake->counter >> 1U) & 0xFFU); -``` - - -> Committable suggestion skipped: line range outside the PR's diff. - -
-🤖 Prompt for AI Agents - -``` -In core/tests/fakes/git/fake_git_repository_port.c around lines 716 to 724, the -code returns fake->next_commit_oid without clearing it so subsequent commits -reuse the same OID; change the logic so when next_commit_oid is consumed you -copy it into out_commit_oid and then reset fake->next_commit_oid to an all-zero -value (or otherwise mark it unused) before returning, leaving the existing -auto-generate branch to run only when next_commit_oid is not set. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074021 - -{response} - -### core/tests/unit/test_cache_edge_map.c:29 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix inverted assertion in `dispose_error`.** - -Once we return past the success case, `result.ok` is guaranteed false, so `assert(!result.ok)` always passes and we never detect unexpected failures. That masks regressions the helper is supposed to surface. Flip the assertion to check for success instead (after freeing the error) so tests fail fast when a call that should succeed starts erroring. - -```diff - if (result.u.err != NULL) { - gm_error_free(result.u.err); - } -- assert(!result.ok); -+ assert(result.ok && "unexpected gm_result failure"); -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (result.u.err != NULL) { - gm_error_free(result.u.err); - } - assert(result.ok && "unexpected gm_result failure"); -} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/tests/unit/test_cache_edge_map.c around lines 25 to 29, the assertion is -inverted: after handling the error branch the test uses assert(!result.ok) which -always passes and hides failures; move or change the assertion so that after -freeing the error (if result.u.err != NULL) you assert that the call succeeded -by using assert(result.ok) (i.e., flip the condition and place it after any -gm_error_free call) so the test fails fast when an operation that should succeed -returns an error. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074023 - -{response} - -### core/tests/unit/test_journal_mixed_cbor.c:98 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Avoid double-freeing the repository handle** - -`gm_libgit2_repository_port_create` hands back `dispose_repository_port`, and that disposer already releases the underlying `git_repository`. Calling `git_repository_free(repo)` afterward frees the same handle twice, which will crash under ASAN in this test and in real runs. Please fall back to `git_repository_free` only when no disposer is returned. - -Apply this diff: - -```diff -- if (ctx.git_repo_port_dispose != NULL) { -- ctx.git_repo_port_dispose(&ctx.git_repo_port); -- } -- git_repository_free(repo); -+ if (ctx.git_repo_port_dispose != NULL) { -+ ctx.git_repo_port_dispose(&ctx.git_repo_port); -+ } else { -+ git_repository_free(repo); -+ } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (ctx.git_repo_port_dispose != NULL) { - ctx.git_repo_port_dispose(&ctx.git_repo_port); - } else { - git_repository_free(repo); - } - git_libgit2_shutdown(); -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/tests/unit/test_journal_mixed_cbor.c around lines 90 to 94, the test -currently calls the disposer (ctx.git_repo_port_dispose) and then -unconditionally calls git_repository_free(repo), which double-frees the same -repository handle; change the teardown so that if ctx.git_repo_port_dispose is -non-NULL call only ctx.git_repo_port_dispose(&ctx.git_repo_port) and skip -git_repository_free, otherwise call git_repository_free(repo) to release the -repository. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074026 - -{response} - -### docs/architecture/augments-system.md:14 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Add required SPDX/license comments after front matter** - -`docs/**/*.md` requires the SPDX/license comment block immediately following the front matter. Please add it here to stay compliant with the documentation guidelines. As per coding guidelines - -```diff - --- - last_updated: 2025-09-27 - --- -+ -+ -+ -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- - - - - -# AUGMENTS System Architecture -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/architecture/augments-system.md around lines 9 to 11, the file is -missing the required SPDX/license comment block immediately after the front -matter; add the SPDX header block (e.g., SPDX-FileCopyrightText and -SPDX-License-Identifier lines) directly below the front-matter delimiter so the -license comment follows the front matter as required by docs/**/*.md guidelines. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074028 - -{response} - -### docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md:26 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix missing Table of Contents/title mismatch** - -This doc has the same structural issues: the front‑matter title differs from the H1, and the required `## Table of Contents` section is absent. Update both to satisfy the documentation rules before rerunning `make docs-verify`. - -```diff --title: 258c9f05de4f483c8c9a039df4b2307bba72ed97.md -+title: Code Review Feedback -@@ --# Code Review Feedback -+# Code Review Feedback -+ -+## Table of Contents -+ -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -+ - [General comment — coderabbitai\[bot]](#general-comment--coderabbitai-bot) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents - -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - - [General comment — coderabbitai[bot]](#general-comment--coderabbitai-bot) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-27 | CodeRabbit (and reviewers) | `258c9f05de4f483c8c9a039df4b2307bba72ed97` | [chore/more-fixes](https://github.com/neuroglyph/git-mind/tree/chore/more-fixes) | [PR#171](https://github.com/neuroglyph/git-mind/pull/171) | - -## CODE REVIEW FEEDBACK - -### General comment — coderabbitai[bot] - -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md around -lines 1 to 26, the front-matter title does not match the H1 and the required "## -Table of Contents" section is missing; update the YAML front-matter title to -exactly match the H1 header, and insert a "## Table of Contents" section (with -appropriate anchors or a placeholder list) immediately after the H1 so the -document conforms to the docs-verify rules, then run make docs-verify to -confirm. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074029 - -{response} - -### docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md:26 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required Table of Contents and title alignment** - -Per the docs guidelines, each Markdown doc needs a single H1 that matches the front‑matter title and must include a `## Table of Contents` section. This file currently lacks the TOC and the front‑matter title (`7195186ca1374dcef93a846f882a11ebbc7fb861.md`) does not match the `# Code Review Feedback` H1. Please align the title and add the TOC so `make docs-verify` will pass. - -```diff --title: 7195186ca1374dcef93a846f882a11ebbc7fb861.md -+title: Code Review Feedback -@@ --# Code Review Feedback -+# Code Review Feedback -+ -+## Table of Contents -+ -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -+ - [General comment — coderabbitai\[bot]](#general-comment--coderabbitai-bot) -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents - -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) - - [General comment — coderabbitai[bot]](#general-comment--coderabbitai-bot) - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-27 | CodeRabbit (and reviewers) | `7195186ca1374dcef93a846f882a11ebbc7fb861` | [chore/more-fixes](https://github.com/neuroglyph/git-mind/tree/chore/more-fixes "neuroglyph/git-mind:chore/more-fixes") | [PR#171](https://github.com/neuroglyph/git-mind/pull/171) | - -## CODE REVIEW FEEDBACK - -### General comment — coderabbitai[bot] - -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md around -lines 1 to 26, the front-matter title does not match the document H1 and the -file is missing a "## Table of Contents" section required by docs guidelines; -update the YAML front-matter title to exactly match the H1 ("Code Review -Feedback") or change the H1 to match the existing front-matter title, and insert -a "## Table of Contents" section directly below the H1 with links to the main -sections (e.g., General comment, CODE REVIEW FEEDBACK) so the document follows -the repository's docs formatting and passes make docs-verify. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384074032 - -{response} - -### core/src/adapters/git/libgit2_repository_port.c:652 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Remove the banned clang-tidy suppression** - -`/* NOLINTNEXTLINE(misc-no-recursion) */` violates the project rule prohibiting NOLINT in touched `.c` files. Please drop the suppression and rework `tree_size_recursive` into an iterative traversal (or otherwise silence the warning by design) so we stay within the lint policy. As per coding guidelines. - - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082681 - -{response} - -### core/src/adapters/git/libgit2_repository_port.c:718 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Restore first-parent ordering in commit walks** - -`gm_hook_get_blob_sha` now relies on `gm_git_repository_port_walk_commits` to materialize `HEAD~N`. With `git_revwalk_sorting(walk, GIT_SORT_TIME)`, a merge commit whose second parent has a newer timestamp than the first will be returned before the first parent, so `offset == 1` yields the feature-side parent instead of the mainline parent. That gives us the wrong blob for `HEAD~1` and breaks the augment edge reconstruction. Please drop the time-based sorting and enforce first-parent traversal (e.g., keep the default ordering or call `git_revwalk_simplify_first_parent`) so the walk produces a deterministic first-parent chain. - -```diff -- git_revwalk_sorting(walk, GIT_SORT_TIME); -+ git_revwalk_sorting(walk, GIT_SORT_NONE); -+ git_revwalk_simplify_first_parent(walk); -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - git_revwalk_sorting(walk, GIT_SORT_NONE); - git_revwalk_simplify_first_parent(walk); - if (git_revwalk_push_ref(walk, ref_name) != 0) { - git_revwalk_free(walk); - return gm_err_void( - GM_ERROR(GM_ERR_NOT_FOUND, "unable to push ref %s", ref_name)); - } - - git_oid oid; - while (git_revwalk_next(&oid, walk) == 0) { - int cb_result = visit_callback(&oid, userdata); - commit_count++; - if (cb_result != GM_OK) { - git_revwalk_free(walk); - return gm_err_void(GM_ERROR(cb_result, "commit walk callback stop")); - } - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/adapters/git/libgit2_repository_port.c around lines 703-718, the -revwalk uses time-based sorting which can return merge commits in the wrong -parent order; remove the git_revwalk_sorting(walk, GIT_SORT_TIME) call (or avoid -time-based sorting) and enforce first-parent traversal by calling -git_revwalk_simplify_first_parent(walk) after creating the walk and before -pushing the ref (so the walk yields a deterministic first-parent chain for -HEAD~N); keep error handling as-is when pushing the ref and when iterating the -walk. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082682 - -{response} - -### core/src/fs/path_utils.c:93 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Remove NOLINT and rely on the bounded copy; avoid inline suppressions.** - -Per guidelines, we shouldn’t suppress clang-tidy in touched code. The gm_memcpy_span call is already bounds-checked. - -Apply this diff to drop the suppression: - -```diff -- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling) - if (gm_memcpy_span(output + dst, output_size - dst, segment, seg_len) != 0) { - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "normalized path exceeds buffer")); - } -``` - -Optional hardening (outside this hunk): prefer an overflow-safe guard instead of addition: -``` -if (seg_len > output_size - dst - 1) { /* keep 1 for NUL */ ... } -``` -As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (gm_memcpy_span(output + dst, output_size - dst, segment, seg_len) != 0) { - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "normalized path exceeds buffer")); - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/fs/path_utils.c around lines 89 to 93, remove the inline NOLINT -suppression and rely on the existing bounded copy; keep the gm_memcpy_span call -but replace the suppression comment with an explicit overflow-safe pre-check: -verify seg_len does not exceed output_size - dst - 1 (reserving one byte for the -NUL) and return the same GM_ERR_PATH_TOO_LONG error if it does, otherwise call -gm_memcpy_span and handle its non-zero return as before. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082686 - -{response} - -### core/src/fs/path_utils.c:114 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Don’t suppress cognitive-complexity; refactor instead.** - -Remove the NOLINT and split helpers (e.g., trim_trailing_slashes, find_last_sep) to satisfy the check without suppressions. - -Apply this diff to drop the suppression: - -```diff --// NOLINTNEXTLINE(readability-function-cognitive-complexity) - GM_NODISCARD gm_result_void_t gm_fs_path_dirname(const char *input, - char *output, - size_t output_size) { -``` - -I can sketch helper extraction if helpful. As per coding guidelines - - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082687 - -{response} - -### core/src/fs/path_utils.c:164 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Zero output on failure path to avoid partial writes.** - -On error, ensure output is cleared per policy. - -Apply this diff: - -```diff -- if (gm_memcpy_span(output, output_size, normalized, out_len) != 0) { -- return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -- "dirname output exceeds buffer")); -- } -+ if (gm_memcpy_span(output, output_size, normalized, out_len) != 0) { -+ memset(output, 0, output_size); -+ return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -+ "dirname output exceeds buffer")); -+ } -``` - -Replicate this “clear-on-error” pattern for other early returns in this function. As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (gm_memcpy_span(output, output_size, normalized, out_len) != 0) { - memset(output, 0, output_size); - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "dirname output exceeds buffer")); - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/fs/path_utils.c around lines 161-164, the error return after -gm_memcpy_span may leave a partially written output buffer; clear the output -buffer before returning on error (e.g., zero the buffer or set output[0] = '\0' -using the appropriate safe memset/utility) and then return the gm_err_void; -apply the same “clear-on-error” pattern to all other early return/error paths in -this function so no partial data remains in output on failure. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082688 - -{response} - -### core/src/fs/path_utils.c:215 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix partial write risk: avoid mutating base_io until capacity for the whole operation is confirmed.** - -Currently a trailing slash may be appended before verifying space for the leaf; if the leaf check fails, base_io is left mutated. - -Refactor to compute required size up front and only write after passing checks: - -```c -GM_NODISCARD gm_result_void_t gm_fs_path_basename_append( - char *base_io, size_t buffer_size, size_t *inout_len, const char *source_path) { - if (base_io == NULL || inout_len == NULL || source_path == NULL) { - return gm_err_void(GM_ERROR(GM_ERR_INVALID_ARGUMENT, - "basename append requires parameters")); - } - - char normalized[GM_PATH_MAX]; - GM_TRY(gm_fs_path_normalize_logical(source_path, normalized, sizeof(normalized))); - - // Extract leaf - size_t len = strlen(normalized); - size_t idx = len; - while (idx > 0 && normalized[idx - 1] != '/') { idx--; } - const char *leaf = normalized + idx; - if (*leaf == '\0') { return gm_ok_void(); } - - // Validate base length - size_t base_len = *inout_len; - if (base_len > buffer_size) { - return gm_err_void(GM_ERROR(GM_ERR_INVALID_ARGUMENT, - "basename append length exceeds buffer")); - } - - // Plan writes - bool need_sep = (base_len > 0 && base_io[base_len - 1] != '/'); - size_t leaf_len = strlen(leaf); - size_t required = base_len + (need_sep ? 1 : 0) + leaf_len; - - // Keep 1 for NUL; overflow-safe check - if (required >= buffer_size || leaf_len > buffer_size - base_len - (need_sep ? 1 : 0) - 1) { - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "basename append exceeds buffer")); - } - - // Perform writes - if (need_sep) { - base_io[base_len++] = '/'; - } - if (gm_memcpy_span(base_io + base_len, buffer_size - base_len, leaf, leaf_len) != 0) { - // Clear to avoid partial writes - memset(base_io, 0, buffer_size); - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "basename append exceeds buffer")); - } - base_len += leaf_len; - base_io[base_len] = '\0'; - *inout_len = base_len; - return gm_ok_void(); -} -``` - -This prevents partial writes and follows the “zero on error” rule. As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -core/src/fs/path_utils.c around lines 211-215: the current append logic can -mutate base_io (writing a trailing slash) before confirming there is enough -space for the leaf, risking a partial write on error; change the routine to -compute normalized leaf and required size up front, perform bounds/overflow-safe -checks (including NUL) before any writes, only then write the separator (if -needed) and the leaf, NUL-terminate and update *inout_len; if a copy fails, -clear the buffer (memset zero) and return the path-too-long error to avoid -leaving base_io partially modified. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082689 - -{response} - -### core/src/hooks/augment.c:156 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Handle detached HEAD when resolving HEAD~N** - -The new flow requires resolving the current branch name and building `refs/heads/` before walking commits. In a detached HEAD (checkout of a bare commit, bisect, etc.), `gm_git_repository_port_head_branch` returns `GM_ERR_NOT_FOUND`, which now short-circuits the hook. Previously we could resolve `HEAD~1` in detached states; now we silently skip augment edges. Please switch to pushing `HEAD` directly (or otherwise avoid depending on a branch name) so detached HEADs remain supported. - -```diff -- char branch[BUFFER_SIZE_SMALL]; -- gm_result_void_t branch_result = -- gm_git_repository_port_head_branch(repo_port, branch, sizeof(branch)); -- int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); -- if (branch_rc != GM_OK) { -- return branch_rc; -- } -- -- char ref_name[REF_NAME_BUFFER_SIZE]; -- int ref_rc = -- gm_build_ref(ref_name, sizeof(ref_name), REFS_HEADS_PREFIX, branch); -- if (ref_rc != GM_OK) { -- return ref_rc; -- } -- - const size_t required_commits = offset + 1U; - gm_oid_t commit_buffer[GM_AUGMENT_LOOKBACK_LIMIT]; - hook_commit_collect_ctx_t collect_ctx = { - .storage = commit_buffer, - .capacity = required_commits, - .count = 0U, - }; - -- gm_result_void_t walk_result = gm_git_repository_port_walk_commits( -- repo_port, ref_name, collect_commit_oid, &collect_ctx); -+ gm_result_void_t walk_result = gm_git_repository_port_walk_commits( -+ repo_port, "HEAD", collect_commit_oid, &collect_ctx); -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - const size_t required_commits = offset + 1U; - gm_oid_t commit_buffer[GM_AUGMENT_LOOKBACK_LIMIT]; - hook_commit_collect_ctx_t collect_ctx = { - .storage = commit_buffer, - .capacity = required_commits, - .count = 0U, - }; - - gm_result_void_t walk_result = gm_git_repository_port_walk_commits( - repo_port, "HEAD", collect_commit_oid, &collect_ctx); - int walk_rc = hook_result_to_code(walk_result, GM_ERR_NOT_FOUND); - if (walk_rc != GM_OK) { - return walk_rc; - } - - if (collect_ctx.count <= offset) { - return GM_ERR_NOT_FOUND; - } - - gm_result_void_t resolve_result = gm_git_repository_port_resolve_blob_at_commit( - repo_port, &collect_ctx.storage[offset], file_path, sha_out); - return hook_result_to_code(resolve_result, GM_ERR_NOT_FOUND); -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/hooks/augment.c around lines 120-156, the code fails early when HEAD -is detached because it requires a branch name and builds refs/heads/; -change the logic so that if gm_git_repository_port_head_branch returns -GM_ERR_NOT_FOUND (detached HEAD) you use the literal "HEAD" ref instead of -building refs/heads/ (i.e. only call gm_build_ref when a branch name was -successfully obtained, otherwise set ref_name to "HEAD" and proceed to walk -commits and resolve the blob), keeping the existing error handling for other -failures. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082690 - -{response} - -### docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md:74 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required doc structure (title + ToC).** - -Per the repo documentation standards, each Markdown doc must keep the H1 title aligned with the front-matter `title` field and expose a `## Table of Contents` section. This file currently has a hash-valued title and no ToC section, so it fails the check. Please align the title with the H1 and add the required ToC (adding headings for the sections referenced in the ToC keeps the anchors stable). - -```diff ---- a/docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md -+++ b/docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md -@@ --title: 258c9f05de4f483c8c9a039df4b2307bba72ed97.md -+title: Code Review Feedback -@@ --# Code Review Feedback -+# Code Review Feedback -+ -+## Table of Contents -+ -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -+- [Finishing touches](#finishing-touches) -+- [Tips](#tips) -@@ --## CODE REVIEW FEEDBACK -+## CODE REVIEW FEEDBACK -@@ -- -+## Finishing touches -+ -+ -@@ -- -+## Tips -+ -+ -``` -As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents - -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -- [Finishing touches](#finishing-touches) -- [Tips](#tips) - -| Date | Agent | SHA | Branch | PR | -|------------|-----------------------------|---------------------------------------|------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------| -| 2025-09-27 | CodeRabbit (and reviewers) | `258c9f05de4f483c8c9a039df4b2307bba72ed97` | [chore/more-fixes](https://github.com/neuroglyph/git-mind/tree/chore/more-fixes) | [PR#171](https://github.com/neuroglyph/git-mind/pull/171) | - -## CODE REVIEW FEEDBACK - -### General comment — coderabbitai[bot] - -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md around -lines 1-138, the file H1 does not match the front-matter title (it's currently a -hash) and the required "## Table of Contents" section is missing; update the H1 -to exactly match the front-matter title value (or update the front-matter title -to the intended human-readable H1), add a "## Table of Contents" section beneath -the H1, and ensure you include the target headings that the ToC will anchor to -(add or adjust section headings so anchors are stable). -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082693 - -{response} - -### docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md:138 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore required doc structure (title + ToC).** - -Same issue as the sibling review artifact: the doc violates the Markdown guidelines because the H1 and front-matter title differ and there’s no `## Table of Contents` section. Sync the title with the H1 and add the mandated ToC plus headings for the sections the ToC references. - -```diff ---- a/docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md -+++ b/docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md -@@ --title: 7195186ca1374dcef93a846f882a11ebbc7fb861.md -+title: Code Review Feedback -@@ --# Code Review Feedback -+# Code Review Feedback -+ -+## Table of Contents -+ -+- [Code Review Feedback](#code-review-feedback) -+- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -+- [Finishing touches](#finishing-touches) -+- [Tips](#tips) -@@ --## CODE REVIEW FEEDBACK -+## CODE REVIEW FEEDBACK -@@ -- -+## Finishing touches -+ -+ -@@ -- -+## Tips -+ -+ -``` -As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: Code Review Feedback -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - -# Code Review Feedback - -## Table of Contents - -- [Code Review Feedback](#code-review-feedback) -- [CODE REVIEW FEEDBACK](#code-review-feedback-1) -- [Finishing touches](#finishing-touches) -- [Tips](#tips) - -## CODE REVIEW FEEDBACK - - - -## Finishing touches - - -- [ ] 📝 Generate Docstrings -
- 🧪 Generate unit tests - - [ ] Create PR with unit tests - - [ ] Post copyable unit tests in a comment - - [ ] Commit unit tests in branch `chore/more-fixes` -
- - -## Tips - - ---- -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 -- [Twitter](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20...) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20...) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit...) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai) -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md around -lines 1 to 138, the front-matter title and the H1 header are inconsistent and -the required "## Table of Contents" section is missing; update the H1 to match -the front-matter title (or vice versa) and insert a "## Table of Contents" -section with links to the major sections referenced in the doc (e.g., CODE -REVIEW FEEDBACK, General comment, Commits, Finishing touches) so the file -conforms to the Markdown guidelines. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384082695 - -{response} - -### apps/cli/cli_runtime.h:15 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Do not leak libgit2 types; carry the repository via the port.** - -Forward-declaring git_repository and exposing it in gm_cli_ctx_t re-couples the CLI to libgit2, undermining the new port abstraction. Store a gm_git_repository_port_t instead. - - -Apply within this range: -```diff --typedef struct git_repository git_repository; -@@ - typedef struct gm_cli_ctx { - gm_output_t *out; -- git_repository *repo; -+ const gm_git_repository_port_t *repo_port; - } gm_cli_ctx_t; -``` - -Also add the required include near the other project includes: -```c -#include "gitmind/ports/git_repository_port.h" -``` -As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In apps/cli/cli_runtime.h around lines 9 to 15, do not expose or forward-declare -the libgit2 type git_repository in the public CLI context; replace the -git_repository* field with a pointer to the port type gm_git_repository_port_t -and add the include for "gitmind/ports/git_repository_port.h" alongside the -other project includes. Update the struct definition to use -gm_git_repository_port_t *repo (and adjust any typedef/name spacing to match -project style) and ensure the new header is added at the top of the file so the -symbol is defined. -``` - -
- - - ---- - -_🛠️ Refactor suggestion_ | _🟠 Major_ - -
-🧩 Analysis chain - -**Follow-up: check call sites for breakage.** - -After the change, update all CLI code to use ctx->repo_port and obtain it via the adapter factory. - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -# Find usages of gm_cli_ctx_t.repo and direct git_repository references in apps/ -rg -n -C2 --type=c -g 'apps/**' -P '\bgm_cli_ctx_t\b|\bctx->repo\b|\bgit_repository\b' -``` - -Length of output: 6716 - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -rg -n 'repo_port' -g 'apps/**' -``` - -Length of output: 1599 - ---- - - - -
- -**Remove unused `repo` from `gm_cli_ctx_t`.** The CLI now uses `ctx->git_repo_port` via the adapter factory; delete the `git_repository *repo` field in apps/cli/cli_runtime.h. - -
-🤖 Prompt for AI Agents - -``` -In apps/cli/cli_runtime.h around lines 9 to 15, remove the unused git_repository -*repo field from the gm_cli_ctx struct definition; update the struct to only -have gm_output_t *out, then search the codebase for any references to ctx->repo -and replace them to use the adapter factory / ctx->git_repo_port as the comment -indicates (or call the accessor used by the CLI runtime) and adjust any -initializers or casts that set ctx->repo accordingly so there are no remaining -references to that field. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090388 - -{response} - -### apps/cli/main.c:198 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -
-🧩 Analysis chain - -**Balance libgit2 init: add git_libgit2_shutdown() on this early-return path.** - -init_context() calls git_libgit2_init() but on port creation failure it returns without a matching shutdown, since main() does not cleanup on init failure. Add shutdown here to avoid leaking the global refcount. - -Apply this diff: - -```diff - if (!repo_port_result.ok) { - int code = GM_ERR_UNKNOWN; - if (repo_port_result.u.err != NULL) { - code = repo_port_result.u.err->code; - gm_error_free(repo_port_result.u.err); - } - git_repository_free(repo); -+ git_libgit2_shutdown(); - return code; - } -``` - -Also, verify ownership: does ctx->git_repo_port_dispose() free the underlying git_repository? If yes, freeing repo again later (cli->repo) would double-free. If no, current free is correct. Please confirm. - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -set -e -echo "==== init_context definition & usage ====" -rg -n "init_context" -C3 -echo "==== git_libgit2_init calls ====" -rg -n "git_libgit2_init" -C3 -echo "==== gm_libgit2_repository_port_create usage ====" -rg -n "gm_libgit2_repository_port_create" -C3 -echo "==== repository_port_dispose occurrences ====" -rg -n "repository_port_dispose" -C10 -echo "==== git_repo_port_dispose occurrences ====" -rg -n "git_repo_port_dispose" -C3 -``` - -Length of output: 35515 - ---- - - - -
- -**Add git_libgit2_shutdown() on repo_port creation failure** -Match the earlier git_libgit2_init() to avoid leaking the libgit2 refcount. The dispose callback does not free `repo`, so keeping `git_repository_free(repo)` is correct. - -```diff -@@ apps/cli/main.c:186-197 - git_repository_free(repo); -+ git_libgit2_shutdown(); - return code; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - gm_result_void_t repo_port_result = - gm_libgit2_repository_port_create(&ctx->git_repo_port, NULL, - &ctx->git_repo_port_dispose, repo); - if (!repo_port_result.ok) { - int code = GM_ERR_UNKNOWN; - if (repo_port_result.u.err != NULL) { - code = repo_port_result.u.err->code; - gm_error_free(repo_port_result.u.err); - } - git_repository_free(repo); - git_libgit2_shutdown(); - return code; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In apps/cli/main.c around lines 186 to 197, the code returns early on repo_port -creation failure but doesn't call git_libgit2_shutdown(), leaking the libgit2 -refcount started by git_libgit2_init(); after freeing repo with -git_repository_free(repo) and before returning the error code, call -git_libgit2_shutdown() so libgit2 is properly balanced and resources are -released. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 4c424de -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090391 - -{response} - -### apps/cli/main.c:238 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Also balance libgit2 init on output allocation failure.** - -Return path needs a git_libgit2_shutdown() to match the init earlier in this function. - -Apply this diff: - -```diff - if (!cli->out) { - if (ctx->fs_temp_port_dispose != NULL) { - ctx->fs_temp_port_dispose(&ctx->fs_temp_port); - ctx->fs_temp_port_dispose = NULL; - } - if (ctx->git_repo_port_dispose != NULL) { - ctx->git_repo_port_dispose(&ctx->git_repo_port); - ctx->git_repo_port_dispose = NULL; - } - if (cli->repo != NULL) { - git_repository_free(cli->repo); - cli->repo = NULL; - } -- return GM_ERR_OUT_OF_MEMORY; -+ git_libgit2_shutdown(); -+ return GM_ERR_OUT_OF_MEMORY; - } -``` - -
-🤖 Prompt for AI Agents - -``` -In apps/cli/main.c around lines 221-233, the early return on output allocation -failure cleans up temp ports and repo but does not call git_libgit2_shutdown() -to balance the git_libgit2_init() done earlier; insert a call to -git_libgit2_shutdown() (or conditionally call it if you track init state) just -before the return GM_ERR_OUT_OF_MEMORY so libgit2 is properly shut down on this -error path. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 4c424de -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090393 - -{response} - -### core/include/gitmind/ports/git_repository_port.h:75 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Define ownership for blob data; add a disposer to the vtable.** - -`commit_read_blob` returns heap data without a matching `dispose` in the interface. Add a `blob_dispose` (or document “free() by caller”). Mismatched allocators across adapters can leak or crash. - -Apply this diff to extend the vtable: - -```diff - typedef struct gm_git_repository_port_vtbl { -@@ - gm_result_void_t (*commit_read_blob)(void *self, const gm_oid_t *commit_oid, - const char *path, uint8_t **out_data, - size_t *out_size); -+ void (*blob_dispose)(void *self, uint8_t *data, size_t size); -``` -And add a header helper: - -```diff -+static inline void gm_git_repository_port_blob_dispose( -+ const gm_git_repository_port_t *port, uint8_t *data, size_t size) { -+ if (port == NULL || port->vtbl == NULL || port->vtbl->blob_dispose == NULL) { -+ free(data); -+ return; -+ } -+ port->vtbl->blob_dispose(port->self, data, size); -+} -``` -As per coding guidelines - - -> Committable suggestion skipped: line range outside the PR's diff. - -
-🤖 Prompt for AI Agents - -``` -In core/include/gitmind/ports/git_repository_port.h around lines 71-74, the -commit_read_blob vtable entry returns heap-allocated blob data but the interface -lacks an ownership/disposal contract; add a new function pointer in the vtable -(e.g., void (*blob_dispose)(void *self, uint8_t *data, size_t size)) immediately -after commit_read_blob and update the struct declaration accordingly, and add a -small header helper function prototype (e.g., static inline void -git_repo_blob_dispose(gm_git_repository_port_t *port, uint8_t *data, size_t -size)) that calls the vtable disposer (and is NULL-safe) so callers have a -guaranteed way to free blobs provided by adapters. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 7a7557c -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090396 - -{response} - -### core/src/adapters/git/libgit2_repository_port.c:200 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Check snprintf truncation, not just negative return.** - -gm_snprintf can return a value >= buffer size; treat as buffer-too-small. - -As per coding guidelines -Apply this diff: - -```diff -- if (gm_snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, entry_name) < -- 0) { -+ int rn = gm_snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, entry_name); -+ if (rn < 0 || (size_t)rn >= sizeof(full_path)) { - return gm_err_void( - GM_ERROR(GM_ERR_PATH_TOO_LONG, "entry path exceeds buffer")); - } -``` - -
-🤖 Prompt for AI Agents - -``` -In core/src/adapters/git/libgit2_repository_port.c around lines 191 to 197, the -gm_snprintf call is only checking for negative return but not for truncation -(return >= buffer size); change the logic to capture the return value (int or -ssize_t), check if it is negative (error) or >= (int)sizeof(full_path) -(truncated), and in either case return gm_err_void with GM_ERR_PATH_TOO_LONG for -truncation or preserve existing error handling for negative results; ensure you -use the captured length for the comparison and do not assume the buffer contains -a complete path when gm_snprintf indicates truncation. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090397 - -{response} - -### core/src/adapters/git/libgit2_repository_port.c:652 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Remove NOLINT and avoid recursion per project policy.** - -Recursion suppression violates the “never use NOLINT” rule; replace with an iterative tree walk. - -As per coding guidelines -Apply this diff to replace the recursive helper with a non-recursive walk: - -```diff --/* NOLINTNEXTLINE(misc-no-recursion) */ --static gm_result_void_t tree_size_recursive(git_repository *repo, -- const git_oid *tree_oid, -- uint64_t *total_size) { -- git_tree *tree = NULL; -- if (git_tree_lookup(&tree, repo, tree_oid) != 0) { -- return gm_err_void( -- GM_ERROR(GM_ERR_UNKNOWN, "unable to lookup tree while sizing")); -- } -- -- git_odb *odb = NULL; -- if (git_repository_odb(&odb, repo) == 0) { -- size_t tree_size = 0; -- git_object_t tree_type = GIT_OBJECT_INVALID; -- if (git_odb_read_header(&tree_size, &tree_type, odb, tree_oid) == 0) { -- *total_size += tree_size; -- } -- git_odb_free(odb); -- } -- -- size_t entry_count = git_tree_entrycount(tree); -- for (size_t idx = 0; idx < entry_count; ++idx) { -- const git_tree_entry *entry = git_tree_entry_byindex(tree, idx); -- if (entry == NULL) { -- continue; -- } -- -- const git_oid *entry_oid = git_tree_entry_id(entry); -- git_filemode_t mode = git_tree_entry_filemode(entry); -- -- if (mode == GIT_FILEMODE_TREE) { -- gm_result_void_t sub_result = -- tree_size_recursive(repo, entry_oid, total_size); -- if (!sub_result.ok) { -- git_tree_free(tree); -- return sub_result; -- } -- continue; -- } -- -- if (mode == GIT_FILEMODE_BLOB) { -- git_odb *blob_odb = NULL; -- if (git_repository_odb(&blob_odb, repo) == 0) { -- size_t blob_size = 0; -- git_object_t blob_type = GIT_OBJECT_INVALID; -- if (git_odb_read_header(&blob_size, &blob_type, blob_odb, -- entry_oid) == 0) { -- *total_size += blob_size; -- } -- git_odb_free(blob_odb); -- } -- } -- } -- -- git_tree_free(tree); -- return gm_ok_void(); --} -+typedef struct { -+ git_repository *repo; -+ uint64_t total; -+} size_acc_t; -+ -+static int size_walk_cb(const char *root, const git_tree_entry *entry, void *payload) { -+ (void)root; -+ size_acc_t *acc = (size_acc_t *)payload; -+ const git_oid *oid = git_tree_entry_id(entry); -+ const git_filemode_t mode = git_tree_entry_filemode(entry); -+ git_odb *odb = NULL; -+ if (git_repository_odb(&odb, acc->repo) != 0) { -+ return 0; /* skip but keep walking */ -+ } -+ size_t obj_sz = 0; -+ git_object_t obj_type = GIT_OBJECT_INVALID; -+ if (mode == GIT_FILEMODE_TREE || mode == GIT_FILEMODE_BLOB) { -+ if (git_odb_read_header(&obj_sz, &obj_type, odb, oid) == 0) { -+ acc->total += obj_sz; -+ } -+ } -+ git_odb_free(odb); -+ return 0; -+} -``` - - -> Committable suggestion skipped: line range outside the PR's diff. - -
-🤖 Prompt for AI Agents - -``` -In core/src/adapters/git/libgit2_repository_port.c around lines 596 to 652, the -function tree_size_recursive uses recursion and a NOLINT to suppress it; replace -it with an iterative depth-first tree walk using an explicit stack to comply -with project policy. Implement a stack (e.g., dynamic array or linked list) of -git_oid (or git_tree pointers) and loop while the stack is non-empty: pop a tree -OID, lookup the git_tree, read the tree header size and add to total, iterate -entries and for blobs read header size and add to total, and for subtree entries -push their OIDs onto the stack; ensure every git_tree and every git_odb acquired -is freed promptly and propagate any gm_result_void_t error on failure. Keep -function signature the same, remove the NOLINT and any recursive calls, and -preserve existing error-return semantics and total_size accumulation. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090398 - -{response} - -### core/src/adapters/git/libgit2_repository_port.c:742 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Make commit_tree_size_impl iterative (pairs with previous change).** - -Compute root tree header size and walk entries without recursion. - -As per coding guidelines -Apply this diff: - -```diff - static gm_result_void_t commit_tree_size_impl( - gm_libgit2_repository_port_state_t *state, const gm_oid_t *commit_oid, - uint64_t *out_size_bytes) { - if (commit_oid == NULL || out_size_bytes == NULL) { - return gm_err_void(GM_ERROR(GM_ERR_INVALID_ARGUMENT, - "commit tree size requires inputs")); - } - - git_commit *commit = NULL; - if (git_commit_lookup(&commit, state->repo, commit_oid) != 0) { - return gm_err_void( - GM_ERROR(GM_ERR_NOT_FOUND, "commit not found while sizing")); - } - - const git_oid *tree_oid = git_commit_tree_id(commit); - if (tree_oid == NULL) { - git_commit_free(commit); - return gm_err_void( - GM_ERROR(GM_ERR_UNKNOWN, "commit missing tree while sizing")); - } - -- uint64_t total = 0; -- gm_result_void_t result = tree_size_recursive(state->repo, tree_oid, &total); -- git_commit_free(commit); -- -- if (!result.ok) { -- return result; -- } -- -- *out_size_bytes = total; -- return gm_ok_void(); -+ uint64_t total = 0; -+ /* Account for root tree object header size */ -+ git_odb *odb = NULL; -+ if (git_repository_odb(&odb, state->repo) == 0) { -+ size_t root_sz = 0; -+ git_object_t root_type = GIT_OBJECT_INVALID; -+ if (git_odb_read_header(&root_sz, &root_type, odb, tree_oid) == 0) { -+ total += root_sz; -+ } -+ git_odb_free(odb); -+ } -+ -+ git_tree *tree = NULL; -+ if (git_tree_lookup(&tree, state->repo, tree_oid) != 0) { -+ git_commit_free(commit); -+ return gm_err_void(GM_ERROR(GM_ERR_UNKNOWN, "unable to lookup root tree")); -+ } -+ -+ size_acc_t acc = {.repo = state->repo, .total = total}; -+ int walk_rc = git_tree_walk(tree, GIT_TREEWALK_PRE, size_walk_cb, &acc); -+ git_tree_free(tree); -+ git_commit_free(commit); -+ if (walk_rc != 0) { -+ return gm_err_void(GM_ERROR(GM_ERR_UNKNOWN, "tree walk failed")); -+ } -+ *out_size_bytes = acc.total; -+ return gm_ok_void(); - } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion -static gm_result_void_t commit_tree_size_impl( - gm_libgit2_repository_port_state_t *state, const gm_oid_t *commit_oid, - uint64_t *out_size_bytes) { - if (commit_oid == NULL || out_size_bytes == NULL) { - return gm_err_void(GM_ERROR(GM_ERR_INVALID_ARGUMENT, - "commit tree size requires inputs")); - } - - git_commit *commit = NULL; - if (git_commit_lookup(&commit, state->repo, commit_oid) != 0) { - return gm_err_void( - GM_ERROR(GM_ERR_NOT_FOUND, "commit not found while sizing")); - } - - const git_oid *tree_oid = git_commit_tree_id(commit); - if (tree_oid == NULL) { - git_commit_free(commit); - return gm_err_void( - GM_ERROR(GM_ERR_UNKNOWN, "commit missing tree while sizing")); - } - - uint64_t total = 0; - /* Account for root tree object header size */ - git_odb *odb = NULL; - if (git_repository_odb(&odb, state->repo) == 0) { - size_t root_sz = 0; - git_object_t root_type = GIT_OBJECT_INVALID; - if (git_odb_read_header(&root_sz, &root_type, odb, tree_oid) == 0) { - total += root_sz; - } - git_odb_free(odb); - } - - git_tree *tree = NULL; - if (git_tree_lookup(&tree, state->repo, tree_oid) != 0) { - git_commit_free(commit); - return gm_err_void( - GM_ERROR(GM_ERR_UNKNOWN, "unable to lookup root tree")); - } - - size_acc_t acc = {.repo = state->repo, .total = total}; - int walk_rc = git_tree_walk(tree, GIT_TREEWALK_PRE, size_walk_cb, &acc); - git_tree_free(tree); - git_commit_free(commit); - - if (walk_rc != 0) { - return gm_err_void( - GM_ERROR(GM_ERR_UNKNOWN, "tree walk failed")); - } - *out_size_bytes = acc.total; - return gm_ok_void(); -} -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/adapters/git/libgit2_repository_port.c lines 654 to 685, the -commit_tree_size_impl function currently computes the tree size using a -recursive helper. Refactor this to an iterative implementation that calculates -the root tree header size and iterates over entries without recursion, per -coding guidelines. Replace the recursive call with a loop or stack structure to -walk the tree entries and accumulate total size, ensuring to maintain the -current logic and error handling. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090400 - -{response} - -### core/src/app/cache/cache_rebuild_service.c:38 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Relax CLOCKS_PER_SEC assertion; current check breaks low-resolution platforms.** - -The rounding definition already guards small CLOCKS_PER_SEC; the _Static_assert requiring >= 1000 will fail on systems where CLOCKS_PER_SEC is 100 or similar. - -Apply this diff: - -```diff --_Static_assert(CLOCKS_PER_SEC >= MILLIS_PER_SECOND, -- "CLOCKS_PER_SEC must be >= 1000"); --#define CLOCKS_PER_MS \ -- ((clock_t)((CLOCKS_PER_SEC + (MILLIS_PER_SECOND - 1)) / MILLIS_PER_SECOND)) -+#if CLOCKS_PER_SEC <= 0 -+#error "CLOCKS_PER_SEC must be > 0" -+#endif -+#define CLOCKS_PER_MS \ -+ ((clock_t)((CLOCKS_PER_SEC + (MILLIS_PER_SECOND - 1)) / MILLIS_PER_SECOND)) -``` -As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In core/src/app/cache/cache_rebuild_service.c around lines 35-38, remove or -relax the strict _Static_assert(CLOCKS_PER_SEC >= MILLIS_PER_SECOND, ...) check -that forces CLOCKS_PER_SEC >= 1000; instead delete that _Static_assert (or -replace it with a no-op / minimal check like CLOCKS_PER_SEC >= 1) and keep the -existing CLOCKS_PER_MS rounding macro as-is so low-resolution platforms are -supported. -``` - -
- - - - - -✅ Addressed in commits f495f71 to b776c91 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090401 - -{response} - -### core/src/app/cache/cache_rebuild_service.c:48 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Remove remaining libgit2 OID helpers to complete decoupling.** - -This file still relies on git_oid_fmt/tostr (and includes git2/oid.h). Replace with a gm-owned OID→hex utility and drop the libgit2 include to keep core decoupled from libgit2. - -Apply these changes: -- Introduce a local helper (or a shared util) to hex-encode gm_oid_t. -- Replace git_oid_fmt/tostr call sites with that helper. -Example helper (add near the top of this file): - -```c -static void gm_oid_to_hex(char out_hex[GM_OID_HEX_CHARS + 1], - const gm_oid_t *oid) { - static const char kHex[] = "0123456789abcdef"; - for (size_t i = 0; i < GM_OID_RAWSZ; ++i) { - unsigned byte = oid->id[i]; - out_hex[i * 2] = kHex[(byte >> 4) & 0xF]; - out_hex[i * 2 + 1] = kHex[byte & 0xF]; - } - out_hex[GM_OID_HEX_CHARS] = '\0'; -} -``` - -Then: -- In get_oid_prefix: call gm_oid_to_hex(hex, oid) instead of git_oid_fmt. -- In oid_to_hex: copy from gm_oid_to_hex instead of git_oid_tostr. -Finally, remove the git2/oid.h include. As per PR objectives - - -Also applies to: 497-509 - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090402 - -{response} - -### core/src/cache/query.c:141 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Use a precise error for snprintf truncation.** - -Truncation should map to GM_ERR_BUFFER_TOO_SMALL, not GM_ERR_NOT_FOUND. - -As per coding guidelines -Apply this diff: - -```diff -- if (rn < 0 || (size_t)rn >= sizeof(pattern)) { -- return GM_ERR_NOT_FOUND; -- } -+ if (rn < 0 || (size_t)rn >= sizeof(pattern)) { -+ return GM_ERR_BUFFER_TOO_SMALL; -+ } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - int rn = gm_snprintf(pattern, sizeof(pattern), "%s%s/*", GM_CACHE_REF_PREFIX, - branch); - if (rn < 0 || (size_t)rn >= sizeof(pattern)) { - return GM_ERR_BUFFER_TOO_SMALL; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/cache/query.c around lines 83 to 86, the gm_snprintf return handling -currently maps both negative errors and truncation to GM_ERR_NOT_FOUND; change -this so that only the truncation case returns GM_ERR_BUFFER_TOO_SMALL: check rn -< 0 and keep the existing error return for that path, but if (size_t)rn >= -sizeof(pattern) return GM_ERR_BUFFER_TOO_SMALL instead of GM_ERR_NOT_FOUND to -precisely report buffer truncation. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090403 - -{response} - -### core/src/edge/attributed.c:71 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -
-🧩 Analysis chain - -**Port-based blob resolution looks solid; confirm header for gm_memcpy_span.** - -- Input validation and port usage are good. -- Ensure the header that declares gm_memcpy_span is included (util/memory.h). If not, include it. - - -Apply if missing: - -```diff -+#include "gitmind/util/memory.h" -``` - -Verify with: - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -set -euo pipefail - -# Where is gm_memcpy_span declared? -rg -n 'gm_memcpy_span' core/include | head -n 5 - -# Does this file include that header? -rg -n '^#include.*/util/memory.h' core/src/edge/attributed.c || true -rg -n '^#include.*/security/memory.h' core/src/edge/attributed.c || true -``` - -Length of output: 141 - ---- - - - -
- -**Include gitmind/util/memory.h in attributed.c** - -Add `#include "gitmind/util/memory.h"` to core/src/edge/attributed.c so gm_memcpy_span is declared. - -
-🤖 Prompt for AI Agents - -``` -In core/src/edge/attributed.c around lines 42 to 70, the function uses -gm_memcpy_span but the header declaring it is missing; add the include for -gitmind/util/memory.h near the top of this file (with the other project -includes) so gm_memcpy_span is declared and the file compiles; ensure the -include uses the same quoting style as other project headers and rebuild to -verify no further missing-declaration errors. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090404 - -{response} - -### core/src/fs/path_utils.c:93 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Remove NOLINT and harden error path to avoid partial writes** - -Do not suppress clang-tidy; also ensure output is cleared on copy failure to prevent partial writes. - -Apply this diff: - -```diff -- // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling) -- if (gm_memcpy_span(output + dst, output_size - dst, segment, seg_len) != 0) { -- return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -- "normalized path exceeds buffer")); -- } -+ if (gm_memcpy_span(output + dst, output_size - dst, segment, seg_len) != 0) { -+ /* prevent partial writes on failure */ -+ if (output_size > 0) { output[0] = '\0'; } -+ return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -+ "normalized path exceeds buffer")); -+ } -``` - -Also consider similarly clearing the buffer before the earlier overflow returns (Lines 85-88) to comply with “zero output buffers on failure.” As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In core/src/fs/path_utils.c around lines 85 to 93, remove the NOLINTNEXTLINE -comment and harden the error paths so the output buffer is zeroed on any -copy/overflow failure: when gm_memcpy_span fails (lines ~89-93) call a zero-fill -on output up to output_size before returning the gm_err_void error, and likewise -add a zero-fill before the earlier overflow return (lines ~85-88); ensure you do -the zeroing unconditionally on failure and then return the same GM_ERROR values. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090405 - -{response} - -### core/src/fs/path_utils.c:111 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Remove NOLINT for cognitive complexity; reduce function complexity instead** - -Suppressions are disallowed. Extract small helpers (e.g., trim_trailing_slashes, find_dirname_end) to drop complexity below the lint threshold, then remove this comment. - -As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -core/src/fs/path_utils.c around line 111: the -NOLINTNEXTLINE(readability-function-cognitive-complexity) suppression must be -removed; refactor the offending function by extracting small helpers (for -example trim_trailing_slashes to strip trailing '/' characters and -find_dirname_end to locate the split point) so the main function becomes a -simple sequence of calls, replace complex conditionals/loops with those helpers, -remove the NOLINT comment, and run the linter to verify complexity is now below -the threshold. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090406 - -{response} - -### core/src/fs/path_utils.c:164 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Zero the output buffer on failure to avoid partial writes** - -If the span copy fails, return an error after clearing the output. - -Apply this diff: - -```diff -- if (gm_memcpy_span(output, output_size, normalized, out_len) != 0) { -- return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -- "dirname output exceeds buffer")); -- } -+ if (gm_memcpy_span(output, output_size, normalized, out_len) != 0) { -+ if (output_size > 0) { output[0] = '\0'; } -+ return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -+ "dirname output exceeds buffer")); -+ } -``` - -Also consider clearing output before earlier overflow/error returns for consistency. As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In core/src/fs/path_utils.c around lines 161 to 164, when gm_memcpy_span(output, -output_size, normalized, out_len) fails you must zero the output buffer before -returning the error to avoid leaving partial data; call memset(output, 0, -output_size) (or an existing safe zeroing util) immediately prior to returning -gm_err_void(...). Also audit earlier overflow/error return paths in this -function and similarly clear the output buffer before each return that indicates -failure to ensure consistent behavior per the coding guidelines. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090407 - -{response} - -### core/src/fs/path_utils.c:172 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Remove NOLINT for cognitive complexity; refactor instead** - -Same as above; avoid suppression and split logic into helpers. - -As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In core/src/fs/path_utils.c around line 172, there's a -NOLINTNEXTLINE(readability-function-cognitive-complexity) suppression; remove -this suppression and refactor the affected function by extracting independent -logical blocks into small static helper functions (each with a single -responsibility and clear names), replace the inlined complex code with calls to -those helpers, add any necessary static prototypes near the top of the file, -update local variable scoping to minimize shared state, and re-run the linter to -ensure the original function's cognitive complexity is reduced so the NOLINT can -be deleted. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090409 - -{response} - -### core/src/fs/path_utils.c:215 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -**Avoid leaving base_io mutated on failure** - -If the copy fails, restore base_io to its original length to prevent a trailing slash or partial leaf. - -Apply this diff: - -```diff -- if (gm_memcpy_span(base_io + base_len, buffer_size - base_len, leaf, -- leaf_len) != 0) { -- return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -- "basename append exceeds buffer")); -- } -+ if (gm_memcpy_span(base_io + base_len, buffer_size - base_len, leaf, -+ leaf_len) != 0) { -+ /* restore original length to prevent partial writes */ -+ base_io[*inout_len] = '\0'; -+ return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, -+ "basename append exceeds buffer")); -+ } -``` -As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In core/src/fs/path_utils.c around lines 211 to 215, the code appends `leaf` -into `base_io` but on memcpy failure leaves `base_io` mutated (possible trailing -slash or partial leaf). Before performing the copy ensure you have the original -base length saved (already present as base_len) and on any failure restore -`base_io` to that original length by truncating it back to base_len (i.e., -remove any partially written bytes / trailing separator) and then return the -error; do this restoration immediately after the failed memcpy and before -returning. -``` - -
- - - - - -✅ Addressed in commits f495f71 to d0fec83 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090410 - -{response} - -### core/src/hooks/augment.c:11 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -
-🧩 Analysis chain - -**Avoid direct include to keep core decoupled.** - -Prefer a small gm_oid_equal/gm_oid_cmp wrapper in a public header and include that instead of libgit2 headers here. - - -Run to see remaining includes: - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -rg -nP -C2 ']+>' --type=c --type=h -``` - -Length of output: 4829 - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -# Search for existing gm_oid wrappers -rg -nP 'gm_oid_(equal|cmp)\b' -n --type=c --type=h - -# Inspect public types header for OID definitions -sed -n '1,200p' core/include/gitmind/types.h -``` - -Length of output: 1202 - ---- - - - -
- -**Replace direct `` include with a gm_oid wrapper header** -Remove `#include ` in core/src/hooks/augment.c and instead include a public header (e.g. core/include/gitmind/types.h or a new gitmind/oid.h) that declares thin `gm_oid_equal`/`gm_oid_cmp` wrappers around `git_oid_cmp`. - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090411 - -{response} - -### core/src/hooks/augment.c:78 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟡 Minor_ - -**Guard against size_t overflow while parsing HEAD~N.** - -Large N can overflow before later bounds checks. - - - -```diff -- while (*cursor != '\0') { -+ while (*cursor != '\0') { - if (!isdigit((unsigned char)*cursor)) { - return false; - } -- value = (value * 10U) + (size_t)(*cursor - '0'); -+ size_t digit = (size_t)(*cursor - '0'); -+ if (value > (SIZE_MAX - digit) / 10U) { -+ return false; /* overflow */ -+ } -+ value = (value * 10U) + digit; - cursor++; - } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - while (*cursor != '\0') { - if (!isdigit((unsigned char)*cursor)) { - return false; - } - size_t digit = (size_t)(*cursor - '0'); - if (value > (SIZE_MAX - digit) / 10U) { - return false; /* overflow */ - } - value = (value * 10U) + digit; - cursor++; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/hooks/augment.c around lines 71 to 77, the loop that parses digits -into size_t can overflow for large N; add a pre-check before multiplying/adding -to ensure value <= (SIZE_MAX - digit) / 10 and return false on overflow. Use -SIZE_MAX from (include it if not already present) and compute digit -as size_t before the check; keep behavior of rejecting non-digits as-is. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090412 - -{response} - -### core/src/journal/reader.c:237 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Propagate underlying error code from head_branch, don’t squash to INVALID_FORMAT.** - -Preserve `err->code` for better diagnosis and consistent gm_result propagation. - -Apply this diff: - -```diff -- if (!head_result.ok) { -- if (head_result.u.err != NULL) { -- gm_error_free(head_result.u.err); -- } -- return GM_ERR_INVALID_FORMAT; -- } -+ if (!head_result.ok) { -+ int code = GM_ERR_UNKNOWN; -+ if (head_result.u.err != NULL) { -+ code = head_result.u.err->code; -+ gm_error_free(head_result.u.err); -+ } -+ return code; -+ } -``` -As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In core/src/journal/reader.c around lines 228 to 235, the code currently -discards the specific error from gm_git_repository_port_head_branch and always -returns GM_ERR_INVALID_FORMAT; change this to preserve and return the underlying -error code: when head_result.ok is false, extract the error pointer, read its -.code into a local int, free the gm_error_t via gm_error_free, and then return -that saved code (fall back to GM_ERR_INVALID_FORMAT only if the error pointer is -NULL). -``` - -
- - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090413 - -{response} - -### core/src/journal/reader.c:303 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Propagate commit_read_message error code.** - -Don’t coerce to INVALID_FORMAT; return the adapter’s code. - -Apply this diff: - -```diff -- if (!message_result.ok) { -- if (message_result.u.err != NULL) { -- gm_error_free(message_result.u.err); -- } -- return GM_ERR_INVALID_FORMAT; -- } -+ if (!message_result.ok) { -+ int code = GM_ERR_UNKNOWN; -+ if (message_result.u.err != NULL) { -+ code = message_result.u.err->code; -+ gm_error_free(message_result.u.err); -+ } -+ return code; -+ } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - gm_result_void_t message_result = gm_git_repository_port_commit_read_message( - rctx->repo_port, commit_oid, &message); - if (!message_result.ok) { - int code = GM_ERR_UNKNOWN; - if (message_result.u.err != NULL) { - code = message_result.u.err->code; - gm_error_free(message_result.u.err); - } - return code; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/journal/reader.c around lines 291 to 299, the error from -gm_git_repository_port_commit_read_message is being ignored and coerced to -GM_ERR_INVALID_FORMAT; instead capture the adapter error code from -message_result (e.g., take message_result.u.err->code into a local variable), -free the gm_error_t as currently done, and return that captured error code so -the original adapter error is propagated back to the caller. -``` - -
- - - - - -✅ Addressed in commits f495f71 to dc66533 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090414 - -{response} - -### core/tests/fakes/fs/fake_fs_temp_port.c:205 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Align fake canonicalize semantics with the real POSIX adapter.** - -The real adapter rejects non-absolute paths in GM_FS_CANON_PHYSICAL_CREATE_OK. Mirror that here to avoid tests passing against behavior the real adapter won’t allow. - - -Apply: -```diff - case GM_FS_CANON_PHYSICAL_CREATE_OK: { - char normalized[GM_PATH_MAX]; - GM_TRY(gm_fs_path_normalize_logical(abs_path_in, normalized, - sizeof(normalized))); -+ if (normalized[0] != '/') { -+ return gm_err_void(GM_ERROR(GM_ERR_INVALID_ARGUMENT, -+ "create-ok canonicalize requires absolute path")); -+ } - char parent[GM_PATH_MAX]; - GM_TRY(gm_fs_path_dirname(normalized, parent, sizeof(parent))); - if (!fake_path_exists(fake, parent)) { - return gm_err_void(GM_ERROR(GM_ERR_NOT_FOUND, - "fake parent not found")); - } -``` -Parity reference: core/src/adapters/fs/posix_temp_adapter.c (canonicalize_impl). - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - case GM_FS_CANON_PHYSICAL_CREATE_OK: { - char normalized[GM_PATH_MAX]; - GM_TRY(gm_fs_path_normalize_logical(abs_path_in, normalized, - sizeof(normalized))); - if (normalized[0] != '/') { - return gm_err_void(GM_ERROR(GM_ERR_INVALID_ARGUMENT, - "create-ok canonicalize requires absolute path")); - } - char parent[GM_PATH_MAX]; - GM_TRY(gm_fs_path_dirname(normalized, parent, sizeof(parent))); - if (!fake_path_exists(fake, parent)) { - return gm_err_void(GM_ERROR(GM_ERR_NOT_FOUND, - "fake parent not found")); - } - const char *leaf = normalized; - const char *slash = strrchr(normalized, '/'); - if (slash != NULL && slash[1] != '\0') { - leaf = slash + 1; - } - char leaf_copy[GM_PATH_MAX]; - if (gm_strcpy_safe(leaf_copy, sizeof(leaf_copy), leaf) != 0) { - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "fake canonical basename overflow")); - } - size_t len = strlen(parent); - if (gm_strcpy_safe(fake->scratch, sizeof(fake->scratch), parent) != 0) { - return gm_err_void(GM_ERROR(GM_ERR_PATH_TOO_LONG, - "fake canonical path overflow")); - } - GM_TRY(gm_fs_path_basename_append(fake->scratch, sizeof(fake->scratch), &len, - leaf_copy)); - *out_abs_path = fake->scratch; - } -``` - -
- - - - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090415 - -{response} - -### core/tests/fakes/git/fake_git_repository_port.c:722 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Check gm_strcpy_safe and fail on truncation; zero buffer on error.** - -Ignoring the return value violates our safe-string policy. - -Apply this diff: - -```diff -- if (spec->message != NULL) { -- (void)gm_strcpy_safe(fake->last_commit_message, -- sizeof(fake->last_commit_message), spec->message); -- } else { -+ if (spec->message != NULL) { -+ int c_rc = gm_strcpy_safe(fake->last_commit_message, -+ sizeof(fake->last_commit_message), -+ spec->message); -+ if (c_rc != GM_OK) { -+ fake->last_commit_message[0] = '\0'; -+ return gm_err_void(GM_ERROR(GM_ERR_BUFFER_TOO_SMALL, -+ "fake commit message too long")); -+ } -+ } else { - fake->last_commit_message[0] = '\0'; - } -``` -As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (spec->message != NULL) { - int c_rc = gm_strcpy_safe(fake->last_commit_message, - sizeof(fake->last_commit_message), - spec->message); - if (c_rc != GM_OK) { - fake->last_commit_message[0] = '\0'; - return gm_err_void(GM_ERROR(GM_ERR_BUFFER_TOO_SMALL, - "fake commit message too long")); - } - } else { - fake->last_commit_message[0] = '\0'; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/tests/fakes/git/fake_git_repository_port.c around lines 709 to 714, the -call to gm_strcpy_safe ignores its return value; update the code to check -gm_strcpy_safe's return and treat a non-success (truncation/error) as a test -failure: if gm_strcpy_safe indicates truncation or error, zero out -fake->last_commit_message (set [0] = '\0' or memset) and fail the test -immediately (use the project's test-failure helper such as cl_fail/assert), -otherwise leave the copied message as-is. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090417 - -{response} - -### core/tests/fakes/git/fake_git_repository_port.c:773 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Validate gm_strcpy_safe for ref/log; return error on truncation.** - -We must not ignore truncation of ref or log messages. - -Apply this diff: - -```diff -- if (spec->ref_name != NULL) { -- (void)gm_strcpy_safe(fake->last_update_ref, sizeof(fake->last_update_ref), -- spec->ref_name); -- } else { -+ if (spec->ref_name != NULL) { -+ int r_rc = gm_strcpy_safe(fake->last_update_ref, -+ sizeof(fake->last_update_ref), -+ spec->ref_name); -+ if (r_rc != GM_OK) { -+ fake->last_update_ref[0] = '\0'; -+ return gm_err_void(GM_ERROR(GM_ERR_BUFFER_TOO_SMALL, -+ "fake update ref too long")); -+ } -+ } else { - fake->last_update_ref[0] = '\0'; - } - -- if (spec->log_message != NULL) { -- (void)gm_strcpy_safe(fake->last_update_log, -- sizeof(fake->last_update_log), spec->log_message); -- } else { -+ if (spec->log_message != NULL) { -+ int l_rc = gm_strcpy_safe(fake->last_update_log, -+ sizeof(fake->last_update_log), -+ spec->log_message); -+ if (l_rc != GM_OK) { -+ fake->last_update_log[0] = '\0'; -+ return gm_err_void(GM_ERROR(GM_ERR_BUFFER_TOO_SMALL, -+ "fake update log too long")); -+ } -+ } else { - fake->last_update_log[0] = '\nu'; - } -``` -As per coding guidelines - - -> Committable suggestion skipped: line range outside the PR's diff. - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090418 - -{response} - -### core/tests/unit/test_cache_query.c:80 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -
-🧩 Analysis chain - -**Good port initialization; also assert vtbl and verify ownership.** - -- Add an assert that ctx.git_repo_port.vtbl != NULL after creation. -- Verify dispose() does not free repo to avoid double-free with git_repository_free(). - - -Run: - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -set -euo pipefail - -# Check the create call site and vtbl presence in this file -rg -n -C2 $'gm_libgit2_repository_port_create\\(' core/tests/unit/test_cache_query.c - -# Inspect dispose implementation and whether it frees the libgit2 repo -rg -n -C3 --type=c 'dispose_repository_port\s*\(' core/src/adapters/git/libgit2_repository_port.c || true -rg -n -C3 --type=c 'git_repository_free\s*\(' core/src/adapters/git/libgit2_repository_port.c || true -``` - -Length of output: 458 - ---- - - - -
- -**Verify vtbl and non-freeing dispose** - -- After `gm_libgit2_repository_port_create(&ctx.git_repo_port, …)`, add `assert(ctx.git_repo_port.vtbl != NULL)`. -- Add a unit test that invokes `ctx.git_repo_port_dispose(&ctx.git_repo_port)` and confirms the underlying `repo` isn’t freed (to avoid a double-free when calling `git_repository_free()`). - -
-🤖 Prompt for AI Agents - -``` -In core/tests/unit/test_cache_query.c around lines 75-79, after the -gm_libgit2_repository_port_create call add an assertion that -ctx.git_repo_port.vtbl != NULL to verify the vtable is set; then add a unit test -that saves the original repo pointer, calls -ctx.git_repo_port_dispose(&ctx.git_repo_port), asserts the saved repo pointer is -unchanged (not freed or nulled), and finally calls git_repository_free(repo) to -ensure disposing the port did not free the underlying repo (no double-free). -``` - -
- - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090420 - -{response} - -### core/tests/unit/test_journal_mixed_cbor.c:75 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Fix potential payload buffer overflow during concatenation** - -len1 + len2 is unchecked against payload size. Use span copies and assert capacity to avoid overruns. - -Apply this diff: - -```diff -- uint8_t payload[1024]; memcpy(payload, buf1, len1); memcpy(payload + len1, buf2, len2); -+ uint8_t payload[1024] = {0}; -+ size_t total = len1 + len2; -+ assert(total <= sizeof payload && "payload buffer too small"); -+ int c1 = gm_memcpy_span(payload, sizeof payload, buf1, len1); -+ int c2 = gm_memcpy_span(payload + len1, sizeof payload - len1, buf2, len2); -+ assert(c1 == 0 && c2 == 0); -``` - -Also add the needed include at the top (outside this hunk): - -```c -#include "gitmind/util/memory.h" -``` - -
-🤖 Prompt for AI Agents - -``` -In core/tests/unit/test_journal_mixed_cbor.c around lines 74 to 75, the -concatenation into uint8_t payload[1024] blindly copies len1 and len2 bytes and -can overflow payload; add #include "gitmind/util/memory.h" at the top of the -file, assert that (len1 + len2) <= sizeof(payload) before copying, and replace -raw memcpy calls with safe span-based copies (or memcpy_span equivalents -provided by the included header) to ensure capacity is respected and prevent -overruns. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 5efa2d0 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090422 - -{response} - -### docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md:20 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Fix doc guideline violations (SPDX, H1/title, missing ToC).** - -Docs under `docs/**/*.md` must follow the house style: add the SPDX/license comment immediately after the front matter, ensure the sole H1 matches the filename title, and include a `## Table of Contents` section. This file currently misses all three, so it won’t pass the doc linters. Please bring it in line with the docs requirements. As per coding guidelines - - -```diff - --- - status: archive - --- -+ -+ -+ --# Code Review Feedback -+# 258c9f05de4f483c8c9a039df4b2307bba72ed97 -+ -+## Table of Contents -+- [CODE REVIEW FEEDBACK](#code-review-feedback) - - ## CODE REVIEW FEEDBACK -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion ---- -title: 258c9f05de4f483c8c9a039df4b2307bba72ed97.md -description: Preserved review artifacts and rationale. -audience: [contributors] -domain: [quality] -tags: [review] -status: archive ---- - - - -# 258c9f05de4f483c8c9a039df4b2307bba72ed97 - -## Table of Contents -- [CODE REVIEW FEEDBACK](#code-review-feedback) - -## CODE REVIEW FEEDBACK - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-27 | CodeRabbit (and reviewers) | `258c9f05de4f483c8c9a039df4b2307bba72ed97` | [chore/more-fixes](https://github.com/neuroglyph/git-mind/tree/chore/more-fixes "neuroglyph/git-mind:chore/more-fixes") | [PR#171](https://github.com/neuroglyph/git-mind/pull/171) | -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md lines -1–20, the file violates doc guidelines: it lacks the SPDX license comment after -the front-matter, is missing a sole H1 that matches the filename title, and has -no "## Table of Contents" section. Fix by inserting the SPDX/license comment -immediately after the closing front-matter delimiter (---), ensure the document -body contains a single H1 whose text exactly matches the filename/title (remove -any extra H1s or adjust the existing header to match), and add a "## Table of -Contents" section beneath that H1 (populate with the main section anchors or a -placeholder list) so the file conforms to the docs linter requirements. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 97f31b1 - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090423 - -{response} - -### docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md:138 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Bring the doc in line with markdown conventions.** - -This file violates our docs guidelines: the lone H1 must match the front-matter title, and we need an explicit “## Table of Contents” section. Please update the H1 to `# 7195186ca1374dcef93a846f882a11ebbc7fb861`, insert the required TOC, and then demote “Code Review Feedback” to `##`. Sample fix: - -```diff --# Code Review Feedback -+# 7195186ca1374dcef93a846f882a11ebbc7fb861 -+ -+## Table of Contents -+ -+- [Code Review Feedback](#code-review-feedback) -+- [General comment — coderabbitai\bot](#general-comment--coderabbitai-bot) -+- [Finishing touches](#finishing-touches) -+- [Share](#share) -+ -+## Code Review Feedback -``` - -Also add section headings (e.g., `## Finishing touches`, `## Share`) so the TOC anchors resolve. As per coding guidelines - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion -# 7195186ca1374dcef93a846f882a11ebbc7fb861 - -## Table of Contents - -- [Code Review Feedback](#code-review-feedback) -- [General comment — coderabbitai\bot](#general-comment--coderabbitai-bot) -- [Finishing touches](#finishing-touches) -- [Share](#share) - -## Code Review Feedback - -| Date | Agent | SHA | Branch | PR | -|------|-------|-----|--------|----| -| 2025-09-27 | CodeRabbit (and reviewers) | `7195186ca1374dcef93a846f882a11ebbc7fb861` | [chore/more-fixes](https://github.com/neuroglyph/git-mind/tree/chore/more-fixes "neuroglyph/git-mind:chore/more-fixes") | [PR#171](https://github.com/neuroglyph/git-mind/pull/171) | - - -``` - -
- - - - - - - -✅ Addressed in commits f495f71 to 5efa2d0 - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384090425 - -{response} - -### benchmarks/wildebeest_stampede.c:120 — flyingrobots - -```text -Thanks for the catch! The benchmark now seeds a persistent `gm_oid_t` (`mufasa_oid`) and passes its address into `gm_cache_query_fanout`; we fill the SHA bytes via `generate_wildebeest_sha(mufasa_oid.id)` so the call stays const-correct. No raw `uint8_t*` usage remains in that file. -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358699 - -{response} - -### core/src/fs/path_utils.c:93 — flyingrobots - -```text -Good call—dropped the stray NOLINT while swapping to `gm_memcpy_span`, so the block now builds cleanly without suppressions. -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358722 - -{response} - -### core/src/hooks/augment.c:146 — flyingrobots - -```text -Handled—`gm_hook_get_blob_sha` keeps walking `"HEAD"` when `head_branch` returns `GM_ERR_NOT_FOUND`, so detached HEADs still resolve the commit history. Added an explicit fallback branch in the function to make that intent obvious. -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358761 - -{response} - -### docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md:20 — flyingrobots - -```text -Updated the review artifact to match the doc template: front-matter title now mirrors the filename, the SPDX/licensing block stays in place, H1 matches the title, and the TOC lists the remaining sections. -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358779 - -{response} - -### docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md:138 — flyingrobots - -```text -Reworked this doc too: title/H1 now use the commit hash, the TOC exists with working anchors, and the review table sits under a `## Code Review Feedback` heading. Remaining sections (`## Notes`, `## Tips`) line up with the TOC entries. -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358793 - -{response} - -### benchmarks/wildebeest_stampede.c:120 — coderabbitai[bot] - -```text -@flyingrobots Perfect! Your fix correctly resolves the type mismatch issue. Using `gm_oid_t mufasa_oid` and filling it with `generate_wildebeest_sha(mufasa_oid.id)` ensures that `gm_cache_query_fanout` receives the expected `const gm_oid_t*` type, eliminating the compilation error and maintaining proper API contracts throughout the benchmark. - - - ---- - -
-🧠 Learnings used - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: docs/code-reviews/CLAUDE.md:0-0 -Timestamp: 2025-09-19T03:59:13.318Z -Learning: Applies to docs/code-reviews/core/src/cache/{builder,query}.c : Keep naming consistent with OID terminology (e.g., OID_HASH_MULTIPLIER, oid_hash) after migration from SHA -``` - ---- - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: docs/code-reviews/CLAUDE.md:0-0 -Timestamp: 2025-09-19T03:59:13.318Z -Learning: Applies to docs/code-reviews/core/src/edge/edge.c : gm_edge_equal() must compare OIDs first and only fall back to SHA when OIDs are unset/zero; never treat mismatched OIDs as equal due to matching SHAs -``` - ---- - -``` -Learnt from: flyingrobots -PR: neuroglyph/git-mind#169 -File: docs/templates/code-review-feedback.md:26-33 -Timestamp: 2025-09-16T17:10:27.477Z -Learning: The user (flyingrobots) uses Obsidian to view/edit Markdown files and prefers to keep Obsidian-specific syntax like collapsible callout markers (e.g., `[!NOTE]-` for collapsible callouts) even if they're not GitHub-compatible. -``` - -
- ---- - - - -If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Fixed%20gm_cache_query_fanout%20compile%20error%20by%20wrapping%20the%20SHA%20in%20a%20gm_oid_t%20and%20passing%20its%20address%20%E2%80%94%20enforces%20const-correctness%20and%20prevents%20pointer%20mismatches.%20Try%20%40coderabbitai%20%F0%9F%9A%80&url=https%3A%2F%2Fgithub.com%2Fneuroglyph%2Fgit-mind%2Fpull%2F171%23discussion_r2384074004)? - -Thank you for using CodeRabbit! - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358812 - -{response} - -### core/src/fs/path_utils.c:93 — coderabbitai[bot] - -```text -@flyingrobots Thank you for removing the redundant NOLINT suppression! The code is now clean and follows the coding guidelines properly. Great attention to detail in maintaining code quality while implementing the safer `gm_memcpy_span` approach. - - - ---- - -
-🧠 Learnings used - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: AGENTS.md:0-0 -Timestamp: 2025-09-20T17:35:43.632Z -Learning: Applies to {core,include}/**/*.{c,h} : Prefer GM_PATH_MAX; do not use GM_PATH_MAX*2; allocate if larger is required -``` - ---- - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: AGENTS.md:0-0 -Timestamp: 2025-09-20T17:35:43.632Z -Learning: Applies to {core,include}/**/*.{c,h} : Use safe string/memory functions (gm_snprintf, gm_strcpy_safe, gm_memcpy_span); check return codes; treat truncation as error; zero output buffers on error paths -``` - ---- - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: docs/code-reviews/CLAUDE.md:0-0 -Timestamp: 2025-09-19T03:59:13.318Z -Learning: Applies to docs/code-reviews/core/**/*.{c,h} : Use bounded string functions (e.g., gm_snprintf) and check return values for overflow; ensure explicit NUL termination -``` - ---- - -``` -Learnt from: flyingrobots -PR: neuroglyph/git-mind#169 -File: docs/templates/code-review-feedback.md:26-33 -Timestamp: 2025-09-16T17:10:27.477Z -Learning: The user (flyingrobots) uses Obsidian to view/edit Markdown files and prefers to keep Obsidian-specific syntax like collapsible callout markers (e.g., `[!NOTE]-` for collapsible callouts) even if they're not GitHub-compatible. -``` - -
- ---- - - - -If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=%40coderabbitai%20spotted%20a%20redundant%20NOLINT%20after%20swapping%20memcpy%20for%20gm_memcpy_span%E2%80%94removed%20the%20suppression%20and%20added%20a%20proper%20error%20return%20to%20honor%20%E2%80%9CNEVER%20use%20NOLINT%E2%80%9D.%20Try%20it!%20%F0%9F%A7%B9&url=https%3A%2F%2Fgithub.com%2Fneuroglyph%2Fgit-mind%2Fpull%2F171%23discussion_r2384074006)? - -Thank you for using CodeRabbit! - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358839 - -{response} - -### docs/code-reviews/PR171/258c9f05de4f483c8c9a039df4b2307bba72ed97.md:20 — coderabbitai[bot] - -```text -@flyingrobots Thank you for updating the review artifact to conform to the documentation guidelines! The file now properly follows the house style with the SPDX license comment, matching H1 title, and Table of Contents section. This ensures it will pass the doc linters as expected. - - - ---- - -
-🧠 Learnings used - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: AGENTS.md:0-0 -Timestamp: 2025-09-20T17:35:43.632Z -Learning: Applies to .coderabbit.yml : Maintain .coderabbit.yml to prefer summary-first reviews and limit per-line comments on docs -``` - ---- - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: AGENTS.md:0-0 -Timestamp: 2025-09-20T17:35:43.695Z -Learning: Applies to docs/**/*.md : Docs must include front matter first, a single H1 whose title matches the filename title, a '## Table of Contents' section, and API docs must include api_version; add License/SPDX comments after front matter -``` - ---- - -``` -Learnt from: flyingrobots -PR: neuroglyph/git-mind#169 -File: docs/templates/code-review-feedback.md:26-33 -Timestamp: 2025-09-16T17:10:27.477Z -Learning: The user (flyingrobots) uses Obsidian to view/edit Markdown files and prefers to keep Obsidian-specific syntax like collapsible callout markers (e.g., `[!NOTE]-` for collapsible callouts) even if they're not GitHub-compatible. -``` - -
- ---- - - - -If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Missed%20SPDX%2C%20wrong%20H1%2C%20no%20TOC%20broke%20doc%20linting.%20%40coderabbitai%20flagged%20precise%20fixes%20(SPDX%20after%20front-matter%2C%20H1%20%3D%20filename%2C%20add%20TOC)%20to%20restore%20CI%2Flint%20%E2%80%94%20try%20it%20%F0%9F%94%A7%E2%9C%85&url=https%3A%2F%2Fgithub.com%2Fneuroglyph%2Fgit-mind%2Fpull%2F171%23discussion_r2384090423)? - -Thank you for using CodeRabbit! - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384358903 - -{response} - -### docs/code-reviews/PR171/7195186ca1374dcef93a846f882a11ebbc7fb861.md:138 — coderabbitai[bot] - -```text -@flyingrobots Perfect! Thank you for bringing the documentation in line with our markdown conventions. Having the H1 match the front-matter title, the explicit TOC with working anchors, and properly structured section headings makes the document much more consistent with our docs guidelines. Great attention to detail! - - - - /| /| - ( :v: ) - \___/ - I'm happy! 🎉 - ---- - -
-🧠 Learnings used - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: AGENTS.md:0-0 -Timestamp: 2025-09-20T17:35:43.632Z -Learning: Applies to .coderabbit.yml : Maintain .coderabbit.yml to prefer summary-first reviews and limit per-line comments on docs -``` - ---- - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: AGENTS.md:0-0 -Timestamp: 2025-09-20T17:35:43.695Z -Learning: Applies to docs/**/*.md : Docs must include front matter first, a single H1 whose title matches the filename title, a '## Table of Contents' section, and API docs must include api_version; add License/SPDX comments after front matter -``` - ---- - -``` -Learnt from: flyingrobots -PR: neuroglyph/git-mind#169 -File: docs/templates/code-review-feedback.md:26-33 -Timestamp: 2025-09-16T17:10:27.477Z -Learning: The user (flyingrobots) uses Obsidian to view/edit Markdown files and prefers to keep Obsidian-specific syntax like collapsible callout markers (e.g., `[!NOTE]-` for collapsible callouts) even if they're not GitHub-compatible. -``` - -
- ---- - - - -If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Fix%20docs%3A%20make%20H1%20match%20front-matter%2C%20add%20an%20explicit%20%22%23%23%20Table%20of%20Contents%22%2C%20demote%20headings%20%26%20add%20section%20anchors%20so%20the%20TOC%20works.%20Cleaner%2C%20linkable%20docs%20%E2%80%94%20try%20%40coderabbitai%20%F0%9F%93%9A%F0%9F%94%A7&url=https%3A%2F%2Fgithub.com%2Fneuroglyph%2Fgit-mind%2Fpull%2F171%23discussion_r2384090425)? - -Thank you for using CodeRabbit! - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384359000 - -{response} - -### core/src/hooks/augment.c:146 — coderabbitai[bot] - -```text -
-🧩 Analysis chain - -I need to verify that your fix has been properly implemented. Let me check the current state of the code: - - - - - - - - - - -@flyingrobots Looking at the current code, I can see that the detached HEAD fix hasn't been implemented yet. The function still contains the early return logic on lines 114-116: - -```c -int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); -if (branch_rc != GM_OK) { - return branch_rc; // This still causes early return on detached HEAD -} -``` - -The code continues to return `GM_ERR_NOT_FOUND` when `gm_git_repository_port_head_branch` fails, which will cause the augment system to skip processing changes in detached HEAD scenarios (common in CI environments). - -To implement the fix you described, you'll need to modify the logic to fall back to walking "HEAD" directly when the branch lookup fails, rather than returning the error. The suggested approach from my original comment would handle this properly. - -Would you like me to create a follow-up issue to track this fix, or are you planning to address it in this PR? - ---- - -🏁 Script executed: -``` -#!/bin/bash -# Check the current implementation of gm_hook_get_blob_sha for the detached HEAD fix -ast-grep --pattern $'int gm_hook_get_blob_sha($_, $_, $_, $_) { - $$$ -}' -``` - -Length of output: 3921 - ---- - -🏁 Script executed: -``` -#!/bin/bash -# Look specifically for the branch resolution logic in the augment hook -rg -nA 20 -B 5 "gm_git_repository_port_head_branch" core/src/hooks/augment.c -``` - -Length of output: 1875 - ---- - -🏁 Script executed: -``` -#!/bin/bash -# Check for any fallback logic or "HEAD" references in the function -rg -nC 10 'walk_ref.*HEAD|HEAD.*walk' core/src/hooks/augment.c -``` - -Length of output: 0 - ---- - - - -
- -@flyingrobots I can see from the current code that the detached HEAD fix hasn't been implemented yet. Both `gm_hook_get_blob_sha` (lines 124-126) and `gm_hook_is_merge_commit` (lines 305-307) still contain the early return logic that causes the issue: - -```c -int branch_rc = hook_result_to_code(branch_result, GM_ERR_NOT_FOUND); -if (branch_rc != GM_OK) { - return branch_rc; // Still returns early on detached HEAD -} -``` - -This means that in detached HEAD scenarios (common in CI), the function will return `GM_ERR_NOT_FOUND` instead of falling back to walking "HEAD" directly. - -To implement the fix you described, you'll need to modify the logic around these lines to: -1. Only return early on non-`GM_ERR_NOT_FOUND` errors -2. Fall back to using "HEAD" as the ref when branch lookup fails with `GM_ERR_NOT_FOUND` -3. Proceed with commit walking using the fallback ref - -Would you like me to open a follow-up issue to track this fix, or are you planning to implement it as part of this PR? - - - ---- - -
-🧠 Learnings used - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: docs/code-reviews/CLAUDE.md:0-0 -Timestamp: 2025-09-19T03:59:13.318Z -Learning: Applies to docs/code-reviews/core/include/gitmind/hooks/augment.h : Prefix public hook APIs with gm_hook_ and provide deprecation warnings for legacy macro/function names with a clear removal timeline -``` - ---- - -``` -Learnt from: CR -PR: neuroglyph/git-mind#0 -File: docs/code-reviews/CLAUDE.md:0-0 -Timestamp: 2025-09-19T03:59:13.318Z -Learning: Applies to docs/code-reviews/core/**/*.{c,h} : Use consistent error handling across modules (prefer GM_OK/GM_ERR_* over mixing with raw libgit2 codes) -``` - ---- - -``` -Learnt from: flyingrobots -PR: neuroglyph/git-mind#169 -File: docs/templates/code-review-feedback.md:26-33 -Timestamp: 2025-09-16T17:10:27.477Z -Learning: The user (flyingrobots) uses Obsidian to view/edit Markdown files and prefers to keep Obsidian-specific syntax like collapsible callout markers (e.g., `[!NOTE]-` for collapsible callouts) even if they're not GitHub-compatible. -``` - -
- ---- - - - -If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Fixed%20detached-HEAD%20regression%3A%20augment%20now%20falls%20back%20to%20walking%20%22HEAD%22%20when%20head-branch%20lookup%20returns%20GM_ERR_NOT_FOUND%2C%20restoring%20edge%20updates%20in%20CI.%20Try%20%40coderabbitai%20%F0%9F%91%A9%E2%80%8D%F0%9F%92%BB&url=https%3A%2F%2Fgithub.com%2Fneuroglyph%2Fgit-mind%2Fpull%2F171%23discussion_r2384074008)? - -Thank you for using CodeRabbit! - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384359082 - -{response} - -### core/src/adapters/fs/posix_temp_adapter.c:7 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard `_GNU_SOURCE` to keep builds warning-free** - -Unconditionally redefining `_GNU_SOURCE` risks `-Wmacro-redefined` (promoted to error in our `-Werror` builds) whenever the flag is already supplied via compiler args. Wrap it so we only define when absent. - - - -```diff -+#ifndef _GNU_SOURCE - #define _GNU_SOURCE -+#endif -``` - -
-🤖 Prompt for AI Agents - -``` -In core/src/adapters/fs/posix_temp_adapter.c around lines 4 to 5, the file -unconditionally defines _GNU_SOURCE which can trigger -Wmacro-redefined; wrap -the define in a conditional guard: only #define _GNU_SOURCE if it is not already -defined (use #ifndef _GNU_SOURCE / #define _GNU_SOURCE / #endif) so builds that -pass the macro via compiler flags won’t produce a redefinition warning/error. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384369273 - -{response} - -### core/src/journal/writer.c:170 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Preserve commit creation error codes** - -If `gm_git_repository_port_commit_create` fails we flatten the port’s diagnostic into `GM_ERR_UNKNOWN`, hiding actionable error codes (e.g., out-of-memory, permission issues) from callers. Capture and propagate the original code the same way we do for the walk failure so upstream logic can respond correctly. - -```diff - gm_result_void_t commit_result = - gm_git_repository_port_commit_create(jctx->repo_port, &spec, commit_oid); - free(message); - if (!commit_result.ok) { -- if (commit_result.u.err != NULL) { -- gm_error_free(commit_result.u.err); -- } -- return GM_ERR_UNKNOWN; -+ int commit_code = GM_ERR_UNKNOWN; -+ if (commit_result.u.err != NULL) { -+ commit_code = commit_result.u.err->code; -+ gm_error_free(commit_result.u.err); -+ } -+ return commit_code; - } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - gm_result_void_t commit_result = - gm_git_repository_port_commit_create(jctx->repo_port, &spec, commit_oid); - free(message); - if (!commit_result.ok) { - int commit_code = GM_ERR_UNKNOWN; - if (commit_result.u.err != NULL) { - commit_code = commit_result.u.err->code; - gm_error_free(commit_result.u.err); - } - return commit_code; - } - - return GM_OK; -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/journal/writer.c around lines 159 to 168, the code currently throws -away the port commit creation error and always returns GM_ERR_UNKNOWN; instead -capture the result code from gm_git_repository_port_commit_create, free its -diagnostic if present, and return the original error code (or GM_ERR_UNKNOWN -only if no specific code is provided). Update the branch that checks -commit_result.ok to mirror the walk-failure handling: if commit_result.u.err != -NULL free it, then return commit_result.code (falling back to GM_ERR_UNKNOWN -only when commit_result.code is absent). -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384369274 - -{response} - -### core/src/journal/writer.c:218 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Propagate reference update failures** - -`gm_git_repository_port_reference_update` already surfaces detailed error codes; discarding them and always returning `GM_ERR_UNKNOWN` makes debugging impossible if the ref advance is rejected. Forward the underlying code just like the walk path does. - -```diff -- gm_result_void_t update_result = gm_git_repository_port_reference_update( -- jctx->repo_port, &spec); -- if (!update_result.ok) { -- if (update_result.u.err != NULL) { -- gm_error_free(update_result.u.err); -- } -- return GM_ERR_UNKNOWN; -+ gm_result_void_t update_result = -+ gm_git_repository_port_reference_update(jctx->repo_port, &spec); -+ if (!update_result.ok) { -+ int update_code = GM_ERR_UNKNOWN; -+ if (update_result.u.err != NULL) { -+ update_code = update_result.u.err->code; -+ gm_error_free(update_result.u.err); -+ } -+ return update_code; - } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - struct gm_reference_spec spec = { - .ref_name = jctx->ref_name, - .target_oid = &commit_oid, - .log_message = "Journal append", - .force = true, - }; - gm_result_void_t update_result = - gm_git_repository_port_reference_update(jctx->repo_port, &spec); - if (!update_result.ok) { - int update_code = GM_ERR_UNKNOWN; - if (update_result.u.err != NULL) { - update_code = update_result.u.err->code; - gm_error_free(update_result.u.err); - } - return update_code; - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/journal/writer.c around lines 206 to 218, the code currently frees -the error from gm_git_repository_port_reference_update and returns -GM_ERR_UNKNOWN; instead propagate the actual error returned by update_result so -callers get the real failure code. Do not free update_result.u.err before -returning—either return the error code/value directly (as done for the walk -path) or translate and return update_result.u.err->code, and only free the error -if you convert/copy it into a different error object; ensure the returned value -reflects update_result's underlying error rather than GM_ERR_UNKNOWN. -``` - -
- - - - - -✅ Addressed in commits f495f71 to 1a4a7d2 -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384369276 - -{response} - -### docs/tools/Review_Worksheet_Flow.md:24 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Add required Table of Contents and SPDX marker** - -Per the docs guidelines, every Markdown doc under `docs/` needs a `## Table of Contents` section near the top and an SPDX/License comment immediately after the front matter. This file is missing both, so `make docs-verify` will fail until they’re added. Please drop in the SPDX comment that matches the repo’s standard and add the ToC before the first content section. As per coding guidelines - -
-🤖 Prompt for AI Agents - -``` -In docs/tools/Review_Worksheet_Flow.md around lines 11 to 24, the file is -missing the required SPDX/license comment immediately after the front matter and -a "## Table of Contents" section before the first content section; add the -repository's standard SPDX license marker (placed directly after the front -matter) and insert a "## Table of Contents" header plus a minimal ToC block -immediately before the "## 1. Generation" heading so the file conforms to docs/ -standards and passes make docs-verify. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384369277 - -{response} - -### core/src/adapters/fs/posix_temp_adapter.c:5 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Guard `_GNU_SOURCE` definition to prevent build breakage** - -We build with warnings-as-errors, so redefining `_GNU_SOURCE` (e.g., when the toolchain already passes `-D_GNU_SOURCE=1`) will fail compilation. Please wrap this define so it only fires when the macro is absent. - - -```diff --#define _GNU_SOURCE -+#ifndef _GNU_SOURCE -+#define _GNU_SOURCE 1 -+#endif -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/adapters/fs/posix_temp_adapter.c around line 4, the unconditional -`#define _GNU_SOURCE` can break builds when the macro is already defined; change -it to only define `_GNU_SOURCE` if it is not present (wrap the definition with -an `#ifndef _GNU_SOURCE` / `#define _GNU_SOURCE` / `#endif` guard) so -compilation won’t fail under warnings-as-errors when the toolchain supplies the -macro. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384372238 - -{response} - -### core/src/journal/writer.c:213 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Do not force-update the journal ref (violates append-only policy)** - -Using force=true enables non-FF ref moves on transient errors, risking history rewrite. Use fast-forward only. - - - -```diff - gm_git_reference_update_spec_t spec = { - .ref_name = jctx->ref_name, - .target_oid = &commit_oid, - .log_message = "Journal append", -- .force = true, -+ .force = false, - }; -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - gm_git_reference_update_spec_t spec = { - .ref_name = jctx->ref_name, - .target_oid = &commit_oid, - .log_message = "Journal append", - .force = false, - }; - gm_result_void_t update_result = gm_git_repository_port_reference_update( - jctx->repo_port, &spec); - if (!update_result.ok) { - // … - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In core/src/journal/writer.c around lines 205 to 213, the ref update is using -force=true which allows non-fast-forward rewrites and violates the append-only -policy; change the update to perform fast-forward-only by setting force=false -(or removing the force override), and update the error handling: if the update -fails due to non-fast-forward, reload the repo head and retry the append (or -return a clear conflict error to caller) instead of force-updating, ensuring we -never rewrite history. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384372240 - -{response} - -### docs/architecture/MIGRATION_PHILOSOPHY.md:2 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🟠 Major_ - -**Restore title to match filename** - -Per the docs style guide, the sole H1/front‑matter title must match the filename’s title (“Migration Philosophy”). The new “From Chaos to Excellence” suffix breaks that rule and will fail docs lint. Please revert the title (and the H1 if it now differs) and keep any extra phrasing in the body or description instead. - -```diff --title: Migration Philosophy: From Chaos to Excellence -+title: Migration Philosophy -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion -title: Migration Philosophy -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In docs/architecture/MIGRATION_PHILOSOPHY.md around line 2, the front-matter -H1/title includes a suffix "From Chaos to Excellence" that doesn't match the -filename; remove the suffix so the title is exactly "Migration Philosophy" (and -if there is an H1 in the body that differs, update it to match the filename as -well), and move any extra phrasing into the body or description section to -preserve the wording without changing the required title. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384372241 - -{response} - -### docs/legacy/src/edge.md:11 — coderabbitai[bot] - -```text -_🛠️ Refactor suggestion_ | _🟠 Major_ - -
-🧩 Analysis chain - -**Add a “## Table of Contents” section to satisfy docs-verify** - -Docs policy requires a ToC in docs/**/*.md. - - - - -```diff - # Legacy Notes — Edge Management -+ -+## Table of Contents -+- Purpose -+- Design Rationale -+- Implementation Details -+- Edge Cases -+- Equality Semantics -+- Display Format -+- Performance Characteristics -+- Security Considerations -+- Testing Strategy -+- Future Evolution -+- Why This Design Satisfies -``` - -Run: - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -make docs-verify -``` - -Length of output: 42 - ---- - -🏁 Script executed: - -```shell -#!/bin/bash -# Check for Makefile at repository root -if [ -f Makefile ]; then - echo "Makefile exists" -else - echo "Makefile not found" -fi - -# Search for docs-verify references in repository -rg -n "docs-verify" -C2 --hidden --color never || echo "No docs-verify references found" -``` - -Length of output: 18558 - ---- - - - -
- -**Add missing “## Table of Contents” below H1 in docs/legacy/src/edge.md** -Insert a `## Table of Contents` section (with entries for Purpose, Design Rationale, Implementation Details, Edge Cases, Equality Semantics, Display Format, Performance Characteristics, Security Considerations, Testing Strategy, Future Evolution, Why This Design Satisfies) immediately after the `# Legacy Notes — Edge Management` header, then re-run `make docs-verify`. - -
-🤖 Prompt for AI Agents - -``` -In docs/legacy/src/edge.md around line 11, the document is missing a "## Table -of Contents" section immediately after the H1; add a "## Table of Contents" -heading followed by bullet or numbered entries for: Purpose, Design Rationale, -Implementation Details, Edge Cases, Equality Semantics, Display Format, -Performance Characteristics, Security Considerations, Testing Strategy, Future -Evolution, and Why This Design Satisfies, placed directly below "# Legacy Notes -— Edge Management", then save and re-run `make docs-verify`. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384372242 - -{response} - -### benchmarks/wildebeest_stampede.c:157 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Don't free the shared repo inside `run_stampede`.** - -`run_stampede` is invoked three times from `main` with the same `git_repository *repo`. Freeing it here invalidates the pointer after the first run, so the second iteration dereferences freed memory and the third double-frees it. Move the cleanup to the caller and free the repository once after the loop completes. - -```diff -- if (ctx.git_repo_port_dispose != NULL) { -- ctx.git_repo_port_dispose(&ctx.git_repo_port); -- } -- git_repository_free(repo); -+ if (ctx.git_repo_port_dispose != NULL) { -+ ctx.git_repo_port_dispose(&ctx.git_repo_port); -+ } -``` - -Then call `git_repository_free(repo);` once in `main` after the stampede loop. - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (ctx.git_repo_port_dispose != NULL) { - ctx.git_repo_port_dispose(&ctx.git_repo_port); - } -``` - -
- - - -
-🤖 Prompt for AI Agents - -``` -In benchmarks/wildebeest_stampede.c around lines 154-157, run_stampede currently -calls git_repository_free(repo) which frees a shared git_repository used across -three invocations; remove the git_repository_free(repo) call from run_stampede -(leave any per-run ctx.git_repo_port_dispose calls if they are per-run) and -instead add a single git_repository_free(repo) in main after the loop that -invokes run_stampede three times so the repository is freed exactly once when -all runs complete. -``` - -
- - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384459051 - -{response} - -### core/src/fs/path_utils.c:90 — coderabbitai[bot] - -```text -_⚠️ Potential issue_ | _🔴 Critical_ - -**Preserve chained `..` segments in relative paths.** - -The current logic collapses `"../.."` (and longer chains) down to `"."` because the second `..` pops the first one from the stack. That breaks relative path semantics (e.g., joining into a temp dir now yields the wrong location). Only consume a `..` when there’s a real segment to cancel. Otherwise, retain the new `..` for relative paths. - -```diff -- if (strcmp(segment, "..") == 0) { -- if (*count > 0) { -- (*count)--; -- return gm_ok_void(); -- } -- if (!is_absolute) { -- return push_segment(segments, count, max_segments, segment); -- } -- return gm_ok_void(); -- } -+ if (strcmp(segment, "..") == 0) { -+ if (*count > 0 && strcmp(segments[*count - 1], "..") != 0) { -+ (*count)--; -+ return gm_ok_void(); -+ } -+ if (!is_absolute) { -+ return push_segment(segments, count, max_segments, segment); -+ } -+ return gm_ok_void(); -+ } -``` - - - -
-📝 Committable suggestion - -> ‼️ **IMPORTANT** -> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. - -```suggestion - if (strcmp(segment, "..") == 0) { - if (*count > 0 && strcmp(segments[*count - 1], "..") != 0) { - (*count)--; - return gm_ok_void(); - } - if (!is_absolute) { - return push_segment(segments, count, max_segments, segment); - } - return gm_ok_void(); - } -``` - -
- - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#discussion_r2384459054 - -{response} - -### General comment — coderabbitai[bot] - -```text - - - -> [!NOTE] -> Currently processing new changes in this PR. This may take a few minutes, please wait... -> ->
-> 📥 Commits -> -> Reviewing files that changed from the base of the PR and between dc665330593f5e6a4d86fb2fd883ef5b7f733586 and 542d2ac051f5ae32ef5b07c44d7765bd392136d5. -> ->
-> ->
-> 📒 Files selected for processing (8) -> -> * `core/include/gitmind/ports/git_repository_port.h` (1 hunks) -> * `core/src/adapters/fs/posix_temp_adapter.c` (1 hunks) -> * `core/src/adapters/git/libgit2_repository_port.c` (1 hunks) -> * `core/src/app/cache/cache_rebuild_service.c` (11 hunks) -> * `core/src/fs/path_utils.c` (2 hunks) -> * `core/src/hooks/post-commit.c` (7 hunks) -> * `core/src/journal/writer.c` (7 hunks) -> * `core/tests/fakes/git/fake_git_repository_port.c` (1 hunks) -> ->
-> -> ```ascii -> __________________________ -> < // TODO: Find more bugs. > -> -------------------------- -> \ -> \ (\__/) -> (•ㅅ•) -> /   づ -> ``` - - - - - -## Walkthrough -Introduces a Git repository port abstraction and a LibGit2 adapter, refactors CLI, cache, hooks, journal, and tests to use the port, updates context structures and headers, removes direct libgit2 usages in core logic, replaces tree builder/size with port calls, adds fakes for testing, updates docs and build/test wiring. - -## Changes -| Cohort / File(s) | Summary of changes | -| --- | --- | -| **Repository Port API & Adapter**
`core/include/gitmind/ports/git_repository_port.h`, `core/include/gitmind/adapters/git/libgit2_repository_port.h`, `core/src/adapters/git/libgit2_repository_port.c` | Added Git repository port interface and LibGit2-backed implementation; introduced vtbl, port wrappers, creation/dispose API, result handling, and state struct. | -| **Context & Public Headers**
`core/include/gitmind/context.h`, `core/include/gitmind/cache.h`, `core/include/gitmind/hooks/augment.h`, `core/include/gitmind/ports/fs_temp_port.h`, `core/include/gitmind/ports/env_port.h`, `core/include/gitmind/adapters/fs/posix_temp_adapter.h`, `core/include/gitmind/security/string.h` | Replaced git_repo and git_ops with git_repo_port + disposer; added cache_tip_oid; port-based hook signatures; fs_temp path_join parameter rename; include cleanups; gm_snprintf made inline with format attribute. | -| **CLI & Bench Integration**
`apps/cli/main.c`, `apps/cli/main.md`, `apps/cli/cache_rebuild.c`, `benchmarks/wildebeest_stampede.c` | Wired LibGit2 repository port creation/disposal; stored raw repo in user_data; updated branch resolution and cache rebuild to use port; adjusted benchmarks to use context/port and oid type changes. | -| **Cache Rebuild/Query Refactor**
`core/src/app/cache/cache_rebuild_service.c`, `core/src/cache/query.c`, `core/src/cache/builder.c` | Migrated to port-based repo interactions (tips, blobs, commits, sizes); updated validations; introduced helpers for oid/hex conversion and result unwrapping; adjusted builder validations. | -| **Hooks & Journal Refactor**
`core/src/hooks/augment.c`, `core/src/hooks/post-commit.c`, `core/src/journal/reader.c`, `core/src/journal/writer.c`, `core/include/gitmind/hooks/augment.h` | Replaced direct git2 operations with port calls for blob resolution, merge detection, commit walking, reading messages, commit creation, and ref updates; updated function signatures and internal flows. | -| **Filesystem Path Utilities**
`core/src/fs/path_utils.c`, `core/src/adapters/fs/posix_temp_adapter.c` | Rewrote path normalization/dirname/basename-append with span-based helpers and safety checks; minor adapter defines/cleanup. | -| **Removed Legacy Git Helpers**
`core/src/cache/tree_builder.c`, `core/src/cache/tree_size.c`, `core/src/cache/cache_internal.h` | Deleted tree build/size implementations and private cache header; responsibilities moved behind repository port. | -| **Ports: Env & FS**
`core/src/ports/env_port.c`, `core/tests/fakes/fs/fake_fs_temp_port.c` | Added includes; strengthened fake FS path join/canonicalize with absolute checks and overflow-safe basename handling; parameter renames. | -| **Testing: Fake Git Port & Unit Tests**
`core/tests/fakes/git/fake_git_repository_port.h`, `core/tests/fakes/git/fake_git_repository_port.c`, `core/tests/unit/test_edge.c`, `core/tests/unit/test_hook_augment.c`, `core/tests/unit/test_cache_*...`, `benchmarks/...` | Added comprehensive fake repo port with vtbl and state controls; updated tests to use ports; added new hook augment tests; adjusted cache tests to create/dispose ports and use new APIs. | -| **Docs & Architecture**
`AGENTS.md`, `docs/architecture/*`, `docs/legacy/src/*`, `docs/tools/Review_Worksheet_Flow.md`, `docs/talk-shop/Graph-Lvl-Up-Tank.md`, `docs/code-reviews/PR171/*`, `docs/code-reviews/PR170/*` | Documented port-based architecture and wiring; updated headings/timestamps/titles; added review workflow doc; removed old review artifacts; adjusted builder docs. | -| **Build & CI Config**
`meson.build`, `.github/labeler.yml`, `.github/workflows/label-docs-only.yml`, `tools/docs/check_docs.py`, `tools/docs/check_titles.py` | Added adapter/augment sources; removed tree builder/size; included fake port in tests; added new test executable; removed docs-only labeling workflow and rule; expanded docs check skip lists. | - -## Sequence Diagram(s) -```mermaid -sequenceDiagram - autonumber - participant CLI as CLI - participant Ctx as Context (gm_context_t) - participant Port as RepoPort (gm_git_repository_port) - participant L2 as Adapter: LibGit2 - participant Git as Git (libgit2) - - CLI->>L2: gm_libgit2_repository_port_create(repo*) - L2-->>CLI: gm_git_repository_port (+dispose) - - CLI->>Ctx: set git_repo_port, disposer - - Note over Ctx,Port: Runtime operations via port vtbl - - Ctx->>Port: head_branch(out_name) - Port->>L2: vtbl.head_branch(self,…) - L2->>Git: resolve HEAD branch - Git-->>L2: branch name - L2-->>Port: ok - Port-->>Ctx: branch name - - Ctx->>Port: reference_tip(ref, out_tip) - Port->>L2: vtbl.reference_tip(self,…) - L2->>Git: lookup ref tip - Git-->>L2: tip OID + when - L2-->>Ctx: tip - - Ctx->>Port: commit_read_blob(commit_oid, path) - Port->>L2: vtbl.commit_read_blob(self,…) - L2->>Git: load blob - Git-->>L2: data ptr/size - L2-->>Ctx: blob data - Ctx-->>Port: blob_dispose(data,size) - - CLI-->>L2: dispose(port) at shutdown -``` - -```mermaid -sequenceDiagram - autonumber - participant App as Cache Rebuild - participant Port as RepoPort - participant FS as FS Temp Port - - App->>Port: reference_tip("refs/heads/", out_tip) - alt no tip - App->>App: handle not found - else tip found - App->>FS: build temp dir contents - App->>Port: build_tree_from_directory(tmpdir, out_tree) - App->>Port: commit_create(spec(tree, parents, author)) - App->>Port: reference_update(update_spec) - end -``` - -## Estimated code review effort -🎯 5 (Critical) | ⏱️ ~120–180 minutes - -## Possibly related PRs -- neuroglyph/git-mind#169 — Touches repository/ref/OID handling and cache/journal code paths also refactored here, indicating overlapping modules. -- neuroglyph/git-mind#165 — Continues API reshaping toward OID-first and header/umbrella moves affecting edge/hooks/cache like in this PR. -- neuroglyph/git-mind#166 — Modifies CLI wiring and command signatures; overlaps with this PR’s CLI and cache_rebuild refactors. - -## Poem -> Thump-thump go my ports, neatly aligned,
-> Adapters hop in, libgit2 behind.
-> Branches and blobs, I nibble by spec,
-> Hex to OID—no fur out of check.
-> Tests in the meadow, fakes in a row—
-> Cache rebuild sings, “Let’s git and go!” 🐇✨ - - - - - -## Pre-merge checks and finishing touches -
-❌ Failed checks (2 warnings, 1 inconclusive) - -| Check name | Status | Explanation | Resolution | -| :----------------: | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Description Check | ⚠️ Warning | The pull request description does not follow the repository’s description template and lacks the required “Summary”, “Change Areas”, and “Risk” sections with corresponding checkboxes, instead listing a series of bullet points without structure or context. | Please reformat the description to match the template by adding a clear “## Summary” section, completing the “## Change Areas” and “## Risk” checkboxes, and including any relevant links or PRDs as specified in the repository’s description template. | -| Docstring Coverage | ⚠️ Warning | Docstring coverage is 19.90% which is insufficient. The required threshold is 80.00%. | You can run `@coderabbitai generate docstrings` to improve docstring coverage. | -| Title Check | ❓ Inconclusive | The title “chore/more fixes” is too generic and does not clearly summarize the most significant changes in the pull request, making it hard to understand the primary purpose at a glance. | Please choose a more descriptive title that concisely reflects the largest scope of work in this PR, such as “refactor: introduce gm_git_repository_port abstraction and migrate core logic to port-based API.” | - -
- - - - - ---- - -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 - -- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) -- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) -- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) -- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) - -
- -Comment `@coderabbitai help` to get the list of available commands and usage tips. - - - - - - - - - -``` - -_Meta_: https://github.com/neuroglyph/git-mind/pull/171#issuecomment-3341495866 - -{response} - From 7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f Mon Sep 17 00:00:00 2001 From: "J. Kirby Ross" Date: Mon, 29 Sep 2025 00:39:16 -0700 Subject: [PATCH 3/8] feat(core/oid): add gm helpers and migrate edge/cache hooks --- core/include/gitmind/util/oid.h | 38 ++++++++ core/src/cache/query.c | 54 ++---------- core/src/domain/cache/edge_map.c | 3 +- core/src/edge/attributed.c | 31 +++++-- core/src/edge/edge.c | 31 ++++--- core/src/hooks/augment.c | 3 +- core/src/journal/writer.c | 6 +- core/src/util/oid.c | 88 +++++++++++++++++++ core/tests/unit/test_cache_branch_limits.c | 5 +- core/tests/unit/test_cache_edge_map.c | 8 +- core/tests/unit/test_cache_query.c | 11 ++- .../unit/test_cache_shard_distribution.c | 4 +- core/tests/unit/test_edge_attributed_cbor.c | 14 +-- core/tests/unit/test_edge_cbor_oid.c | 11 +-- core/tests/unit/test_edge_equal_semantics.c | 11 +-- core/tests/unit/test_edge_oid_fallback.c | 8 +- core/tests/unit/test_journal_mixed_cbor.c | 7 +- core/tests/unit/test_journal_safety.c | 18 ++-- docs/activity/2025-09.md | 9 +- 19 files changed, 247 insertions(+), 113 deletions(-) diff --git a/core/include/gitmind/util/oid.h b/core/include/gitmind/util/oid.h index bba3b199..b57a4522 100644 --- a/core/include/gitmind/util/oid.h +++ b/core/include/gitmind/util/oid.h @@ -4,6 +4,7 @@ #ifndef GITMIND_UTIL_OID_H #define GITMIND_UTIL_OID_H +#include #include #include @@ -36,6 +37,43 @@ GM_NODISCARD int gm_bytes_to_hex(const uint8_t *bytes, size_t len, */ GM_NODISCARD int gm_oid_to_hex(const gm_oid_t *oid, char *out, size_t out_size); +/** + * Test whether two OIDs refer to the same object. + * + * @param lhs Left-hand OID operand + * @param rhs Right-hand OID operand + * @return true when both pointers are non-null and contain identical raw bytes + */ +GM_NODISCARD bool gm_oid_equal(const gm_oid_t *lhs, const gm_oid_t *rhs); + +/** + * Determine whether an OID is the all-zero sentinel. + * + * @param oid OID to inspect (may be NULL) + * @return true when every byte is zero or the pointer is NULL + */ +GM_NODISCARD bool gm_oid_is_zero(const gm_oid_t *oid); + +/** + * Populate an OID from raw bytes. + * + * @param oid Destination OID (must not be NULL) + * @param raw Source byte buffer + * @param raw_len Number of bytes provided in `raw` + * @return GM_OK on success, GM_ERR_INVALID_ARGUMENT when parameters are invalid + */ +GM_NODISCARD int gm_oid_from_raw(gm_oid_t *oid, const uint8_t *raw, + size_t raw_len); + +/** + * Parse a hexadecimal string into an OID. + * + * @param oid Destination OID (cleared on failure) + * @param hex Null-terminated hex string (must be GM_OID_HEX_CHARS long) + * @return GM_OK on success, GM_ERR_INVALID_ARGUMENT otherwise + */ +GM_NODISCARD int gm_oid_from_hex(gm_oid_t *oid, const char *hex); + #ifdef __cplusplus } #endif diff --git a/core/src/cache/query.c b/core/src/cache/query.c index 13b07881..e52507a7 100644 --- a/core/src/cache/query.c +++ b/core/src/cache/query.c @@ -28,49 +28,6 @@ #define CACHE_PATH_BUFFER_SIZE 128 /* Buffer for cache paths */ #define INITIAL_EDGE_CAPACITY 100 /* Initial allocation for edge arrays */ -static int gm_hex_to_raw(const char *hex, uint8_t *out_raw, size_t raw_size); - -static int gm_hex_value(char c) { - if (c >= '0' && c <= '9') { - return c - '0'; - } - c = (char)(c | 0x20); /* lowercase */ - if (c >= 'a' && c <= 'f') { - return c - 'a' + 10; - } - return -1; -} - -static int gm_hex_to_raw(const char *hex, uint8_t *out_raw, size_t raw_size) { - if (hex == NULL || out_raw == NULL) { - return GM_ERR_INVALID_ARGUMENT; - } - size_t len = strlen(hex); - if (len != raw_size * 2) { - return GM_ERR_INVALID_ARGUMENT; - } - for (size_t i = 0; i < raw_size; ++i) { - int hi = gm_hex_value(hex[i * 2]); - int lo = gm_hex_value(hex[i * 2 + 1]); - if (hi < 0 || lo < 0) { - return GM_ERR_INVALID_ARGUMENT; - } - out_raw[i] = (uint8_t)((hi << 4) | lo); - } - return GM_OK; -} - -static int gm_hex_to_oid(const char *hex, gm_oid_t *oid) { - if (oid == NULL) { - return GM_ERR_INVALID_ARGUMENT; - } - return gm_hex_to_raw(hex, oid->id, GM_OID_RAWSZ); -} - -static bool gm_oid_equal(const gm_oid_t *a, const gm_oid_t *b) { - return a != NULL && b != NULL && memcmp(a->id, b->id, GM_OID_RAWSZ) == 0; -} - /* Get SHA prefix for sharding */ static void get_sha_prefix(const uint8_t *sha, char *prefix, int bits) { int chars = (bits + 3) / BITS_PER_HEX_CHAR; /* Round up to hex chars */ @@ -203,6 +160,7 @@ bool gm_cache_is_stale(gm_context_t *ctx, const char *branch) { } gm_cache_meta_t meta; + gm_memset_safe(&meta, sizeof(meta), 0, sizeof(meta)); if (gm_cache_load_meta(ctx, branch, &meta) != GM_OK) { return true; } @@ -229,15 +187,13 @@ bool gm_cache_is_stale(gm_context_t *ctx, const char *branch) { return true; } - bool have_binary = (memcmp(&meta.journal_tip_oid_bin, &(const gm_oid_t){0}, - sizeof(gm_oid_t)) != 0); - if (have_binary) { + if (!gm_oid_is_zero(&meta.journal_tip_oid_bin)) { return !gm_oid_equal(¤t_tip.oid, &meta.journal_tip_oid_bin); } if (meta.journal_tip_oid[0] != '\0') { gm_oid_t cached_tip; - if (gm_hex_to_oid(meta.journal_tip_oid, &cached_tip) != GM_OK) { + if (gm_oid_from_hex(&cached_tip, meta.journal_tip_oid) != GM_OK) { return true; } return !gm_oid_equal(¤t_tip.oid, &cached_tip); @@ -343,7 +299,7 @@ static int try_cache_query(gm_context_t *ctx, const char *branch, return rc; } - if (memcmp(&meta.cache_tip_oid, &(const gm_oid_t){0}, sizeof(gm_oid_t)) == 0) { + if (gm_oid_is_zero(&meta.cache_tip_oid)) { return GM_ERR_NOT_FOUND; } @@ -470,7 +426,7 @@ int gm_cache_stats(gm_context_t *ctx, const char *branch, } if (cache_size_bytes) { - if (memcmp(&meta.cache_tip_oid, &(const gm_oid_t){0}, sizeof(gm_oid_t)) != 0) { + if (!gm_oid_is_zero(&meta.cache_tip_oid)) { rc = unwrap_result_code(gm_git_repository_port_commit_tree_size( &ctx->git_repo_port, &meta.cache_tip_oid, cache_size_bytes)); if (rc != GM_OK) { diff --git a/core/src/domain/cache/edge_map.c b/core/src/domain/cache/edge_map.c index de3ee88a..860d74b8 100644 --- a/core/src/domain/cache/edge_map.c +++ b/core/src/domain/cache/edge_map.c @@ -8,6 +8,7 @@ #include "gitmind/error.h" #include "gitmind/util/memory.h" +#include "gitmind/util/oid.h" struct gm_edge_map_entry { gm_oid_t oid; @@ -125,7 +126,7 @@ gm_result_void_t gm_edge_map_add(gm_edge_map_t *map, const gm_oid_t *oid, size_t bucket_index = gm_edge_map_hash(oid, map->bucket_count); struct gm_edge_map_entry *entry = map->buckets[bucket_index]; while (entry != NULL) { - if (git_oid_cmp(&entry->oid, oid) == 0) { + if (gm_oid_equal(&entry->oid, oid)) { gm_bitmap_add(entry->bitmap, edge_id); return gm_ok_void(); } diff --git a/core/src/edge/attributed.c b/core/src/edge/attributed.c index f8208139..e8e1d434 100644 --- a/core/src/edge/attributed.c +++ b/core/src/edge/attributed.c @@ -11,6 +11,7 @@ #include "gitmind/types.h" #include "gitmind/attribution.h" #include "gitmind/util/memory.h" +#include "gitmind/util/oid.h" #include "gitmind/edge/internal/blob_identity.h" #include #include "gitmind/security/memory.h" @@ -237,11 +238,25 @@ static int decode_attr_ex_impl(const uint8_t *buffer, size_t len, gm_result_void_t rr = gm_cbor_read_text(buffer, &offset, len, out.ulid, GM_ULID_SIZE + 1); if (!rr.ok) return GM_ERR_INVALID_FORMAT; break; } case GM_CBOR_KEY_SRC_OID: { - uint8_t raw[GM_OID_RAWSZ]; gm_result_void_t rr = gm_cbor_read_bytes(buffer, &offset, len, raw, GM_OID_RAWSZ); - if (!rr.ok) return GM_ERR_INVALID_FORMAT; git_oid_fromraw(&out.src_oid, raw); break; } + uint8_t raw[GM_OID_RAWSZ]; + gm_result_void_t rr = + gm_cbor_read_bytes(buffer, &offset, len, raw, GM_OID_RAWSZ); + if (!rr.ok) return GM_ERR_INVALID_FORMAT; + if (gm_oid_from_raw(&out.src_oid, raw, GM_OID_RAWSZ) != GM_OK) { + return GM_ERR_INVALID_FORMAT; + } + break; + } case GM_CBOR_KEY_TGT_OID: { - uint8_t raw[GM_OID_RAWSZ]; gm_result_void_t rr = gm_cbor_read_bytes(buffer, &offset, len, raw, GM_OID_RAWSZ); - if (!rr.ok) return GM_ERR_INVALID_FORMAT; git_oid_fromraw(&out.tgt_oid, raw); break; } + uint8_t raw[GM_OID_RAWSZ]; + gm_result_void_t rr = + gm_cbor_read_bytes(buffer, &offset, len, raw, GM_OID_RAWSZ); + if (!rr.ok) return GM_ERR_INVALID_FORMAT; + if (gm_oid_from_raw(&out.tgt_oid, raw, GM_OID_RAWSZ) != GM_OK) { + return GM_ERR_INVALID_FORMAT; + } + break; + } case GM_CBOR_KEY_SOURCE_TYPE: { gm_result_uint64_t rr = gm_cbor_read_uint(buffer, &offset, len); if (!rr.ok) return GM_ERR_INVALID_FORMAT; out.attribution.source_type = (gm_source_type_t)rr.u.val; break; } @@ -262,8 +277,12 @@ static int decode_attr_ex_impl(const uint8_t *buffer, size_t len, } } - if (git_oid_is_zero(&out.src_oid)) git_oid_fromraw(&out.src_oid, out.src_sha); - if (git_oid_is_zero(&out.tgt_oid)) git_oid_fromraw(&out.tgt_oid, out.tgt_sha); + if (gm_oid_is_zero(&out.src_oid)) { + (void)gm_oid_from_raw(&out.src_oid, out.src_sha, GM_OID_RAWSZ); + } + if (gm_oid_is_zero(&out.tgt_oid)) { + (void)gm_oid_from_raw(&out.tgt_oid, out.tgt_sha, GM_OID_RAWSZ); + } *e = out; *consumed = offset; return GM_OK; } diff --git a/core/src/edge/edge.c b/core/src/edge/edge.c index d597b6a6..31605644 100644 --- a/core/src/edge/edge.c +++ b/core/src/edge/edge.c @@ -13,6 +13,7 @@ #include "gitmind/security/string.h" #include "gitmind/security/memory.h" #include "gitmind/util/memory.h" +#include "gitmind/util/oid.h" #include "gitmind/cbor/keys.h" #include #include @@ -114,8 +115,8 @@ bool gm_edge_equal(const gm_edge_t *edge_a, const gm_edge_t *edge_b) { } /* Source: if both OIDs present, they must match; otherwise fallback to legacy SHA */ - if (!git_oid_is_zero(&edge_a->src_oid) && !git_oid_is_zero(&edge_b->src_oid)) { - if (git_oid_cmp(&edge_a->src_oid, &edge_b->src_oid) != 0) { + if (!gm_oid_is_zero(&edge_a->src_oid) && !gm_oid_is_zero(&edge_b->src_oid)) { + if (!gm_oid_equal(&edge_a->src_oid, &edge_b->src_oid)) { return false; } } else { @@ -125,8 +126,8 @@ bool gm_edge_equal(const gm_edge_t *edge_a, const gm_edge_t *edge_b) { } /* Target: same rule as Source */ - if (!git_oid_is_zero(&edge_a->tgt_oid) && !git_oid_is_zero(&edge_b->tgt_oid)) { - if (git_oid_cmp(&edge_a->tgt_oid, &edge_b->tgt_oid) != 0) { + if (!gm_oid_is_zero(&edge_a->tgt_oid) && !gm_oid_is_zero(&edge_b->tgt_oid)) { + if (!gm_oid_equal(&edge_a->tgt_oid, &edge_b->tgt_oid)) { return false; } } else { @@ -318,7 +319,7 @@ gm_result_void_t gm_edge_encode_cbor(const gm_edge_t *edge, uint8_t *buffer, uint8_t src_oid_bytes[GM_OID_RAWSZ] = {0}; uint8_t tgt_oid_bytes[GM_OID_RAWSZ] = {0}; - if (!git_oid_is_zero(&edge->src_oid)) { + if (!gm_oid_is_zero(&edge->src_oid)) { (void)gm_memcpy_span(src_oid_bytes, sizeof(src_oid_bytes), edge->src_oid.id, GM_OID_RAWSZ); } else { @@ -331,7 +332,7 @@ gm_result_void_t gm_edge_encode_cbor(const gm_edge_t *edge, uint8_t *buffer, } } - if (!git_oid_is_zero(&edge->tgt_oid)) { + if (!gm_oid_is_zero(&edge->tgt_oid)) { (void)gm_memcpy_span(tgt_oid_bytes, sizeof(tgt_oid_bytes), edge->tgt_oid.id, GM_OID_RAWSZ); } else { @@ -436,14 +437,20 @@ static gm_result_void_t decode_cbor_field(const uint8_t *buffer, size_t *offset, uint8_t raw[GM_OID_RAWSZ]; gm_result_void_t r = gm_cbor_read_bytes(buffer, offset, len, raw, GM_OID_RAWSZ); if (!r.ok) return r; - git_oid_fromraw(&edge->src_oid, raw); + if (gm_oid_from_raw(&edge->src_oid, raw, GM_OID_RAWSZ) != GM_OK) { + return gm_err_void( + GM_ERROR(GM_ERR_INVALID_FORMAT, "Invalid source OID payload")); + } return gm_ok_void(); } case GM_CBOR_KEY_TGT_OID: { uint8_t raw[GM_OID_RAWSZ]; gm_result_void_t r = gm_cbor_read_bytes(buffer, offset, len, raw, GM_OID_RAWSZ); if (!r.ok) return r; - git_oid_fromraw(&edge->tgt_oid, raw); + if (gm_oid_from_raw(&edge->tgt_oid, raw, GM_OID_RAWSZ) != GM_OK) { + return gm_err_void( + GM_ERROR(GM_ERR_INVALID_FORMAT, "Invalid target OID payload")); + } return gm_ok_void(); } default: @@ -482,11 +489,11 @@ static int gm_edge_decode_cbor_ex_impl(const uint8_t *buffer, size_t len, gm_edg } /* Backfill OIDs from legacy SHA if missing */ - if (git_oid_is_zero(&edge.src_oid)) { - git_oid_fromraw(&edge.src_oid, edge.src_sha); + if (gm_oid_is_zero(&edge.src_oid)) { + (void)gm_oid_from_raw(&edge.src_oid, edge.src_sha, GM_OID_RAWSZ); } - if (git_oid_is_zero(&edge.tgt_oid)) { - git_oid_fromraw(&edge.tgt_oid, edge.tgt_sha); + if (gm_oid_is_zero(&edge.tgt_oid)) { + (void)gm_oid_from_raw(&edge.tgt_oid, edge.tgt_sha, GM_OID_RAWSZ); } *edge_out = edge; diff --git a/core/src/hooks/augment.c b/core/src/hooks/augment.c index 772b86b6..2f6d8f1a 100644 --- a/core/src/hooks/augment.c +++ b/core/src/hooks/augment.c @@ -13,6 +13,7 @@ #include "gitmind/result.h" #include "gitmind/util/memory.h" #include "gitmind/util/ref.h" +#include "gitmind/util/oid.h" #include "gitmind/security/memory.h" /* Note: replace any private header usage with public equivalents when available. */ @@ -184,7 +185,7 @@ static int edge_search_callback(const gm_edge_t *edge, void *userdata) { } /* Check if source matches (OID compare) */ - if (git_oid_cmp(&edge->src_oid, ctx->target_oid) == 0) { + if (gm_oid_equal(&edge->src_oid, ctx->target_oid)) { /* Grow array if needed */ if (ctx->count >= ctx->capacity) { size_t new_capacity = ctx->capacity * ARRAY_GROWTH_FACTOR; diff --git a/core/src/journal/writer.c b/core/src/journal/writer.c index cfa679dc..1f41c51e 100644 --- a/core/src/journal/writer.c +++ b/core/src/journal/writer.c @@ -50,7 +50,7 @@ static int journal_init(journal_ctx_t *jctx, gm_context_t *ctx, jctx->repo_port = &ctx->git_repo_port; /* Parse empty tree OID */ - if (git_oid_fromstr(&jctx->empty_tree_oid, EMPTY_TREE_SHA) < 0) { + if (gm_oid_from_hex(&jctx->empty_tree_oid, EMPTY_TREE_SHA) != GM_OK) { return GM_ERR_UNKNOWN; } @@ -124,7 +124,7 @@ static int collect_parent_tip(const gm_oid_t *commit_oid, void *userdata) { /* Create journal commit */ static int create_journal_commit(journal_ctx_t *jctx, const uint8_t *cbor_data, - size_t cbor_len, git_oid *commit_oid) { + size_t cbor_len, gm_oid_t *commit_oid) { parent_lookup_ctx_t lookup_ctx; gm_memset_safe(&lookup_ctx, sizeof(lookup_ctx), 0, sizeof(lookup_ctx)); gm_result_void_t walk_result = gm_git_repository_port_walk_commits( @@ -371,7 +371,7 @@ int gm_journal_create_commit(gm_context_t *ctx, const char *ref, jctx.repo_port = &ctx->git_repo_port; /* Parse empty tree OID */ - if (git_oid_fromstr(&jctx.empty_tree_oid, EMPTY_TREE_SHA) < 0) { + if (gm_oid_from_hex(&jctx.empty_tree_oid, EMPTY_TREE_SHA) != GM_OK) { return GM_ERR_UNKNOWN; } diff --git a/core/src/util/oid.c b/core/src/util/oid.c index dd44541f..3a771c31 100644 --- a/core/src/util/oid.c +++ b/core/src/util/oid.c @@ -4,17 +4,34 @@ #include "gitmind/util/oid.h" #include +#include #include #include +#include #include "gitmind/error.h" #include "gitmind/result.h" #include "gitmind/security/memory.h" #include "gitmind/types.h" +#include "gitmind/util/memory.h" static const char KHexDigits[] = "0123456789abcdef"; static const uint8_t KNibbleMask = 0x0FU; static const unsigned KNibbleBits = 4U; +static const int KHexAlphaOffset = 10; + +static int gm_hex_value(char hex_char) { + if (hex_char >= '0' && hex_char <= '9') { + return hex_char - '0'; + } + if (hex_char >= 'a' && hex_char <= 'f') { + return hex_char - 'a' + KHexAlphaOffset; + } + if (hex_char >= 'A' && hex_char <= 'F') { + return hex_char - 'A' + KHexAlphaOffset; + } + return -1; +} GM_NODISCARD int gm_bytes_to_hex(const uint8_t *bytes, size_t len, char *out, size_t out_size) { @@ -54,3 +71,74 @@ GM_NODISCARD int gm_oid_to_hex(const gm_oid_t *oid, char *out, size_t out_size) } return gm_bytes_to_hex(oid->id, GM_OID_RAWSZ, out, out_size); } + +GM_NODISCARD bool gm_oid_equal(const gm_oid_t *lhs, const gm_oid_t *rhs) { + if (lhs == NULL || rhs == NULL) { + return false; + } + return memcmp(lhs->id, rhs->id, GM_OID_RAWSZ) == 0; +} + +GM_NODISCARD bool gm_oid_is_zero(const gm_oid_t *oid) { + if (oid == NULL) { + return true; + } + for (size_t index = 0; index < GM_OID_RAWSZ; ++index) { + if (oid->id[index] != 0U) { + return false; + } + } + return true; +} + +GM_NODISCARD int gm_oid_from_raw(gm_oid_t *oid, const uint8_t *raw, + size_t raw_len) { + if (oid == NULL) { + return GM_ERR_INVALID_ARGUMENT; + } + + gm_memset_safe(oid, sizeof(*oid), 0, sizeof(*oid)); + + if (raw == NULL || raw_len != GM_OID_RAWSZ) { + return GM_ERR_INVALID_ARGUMENT; + } + + if (gm_memcpy_span(oid->id, GM_OID_RAWSZ, raw, raw_len) != 0) { + gm_memset_safe(oid, sizeof(*oid), 0, sizeof(*oid)); + return GM_ERR_BUFFER_TOO_SMALL; + } + + return GM_OK; +} + +GM_NODISCARD int gm_oid_from_hex(gm_oid_t *oid, const char *hex) { + if (oid == NULL) { + return GM_ERR_INVALID_ARGUMENT; + } + + gm_memset_safe(oid, sizeof(*oid), 0, sizeof(*oid)); + + if (hex == NULL) { + return GM_ERR_INVALID_ARGUMENT; + } + + size_t len = strlen(hex); + if (len != GM_OID_HEX_CHARS) { + return GM_ERR_INVALID_ARGUMENT; + } + + for (size_t index = 0; index < GM_OID_RAWSZ; ++index) { + int high_nibble_value = gm_hex_value(hex[index * 2U]); + int low_nibble_value = gm_hex_value(hex[(index * 2U) + 1U]); + if (high_nibble_value < 0 || low_nibble_value < 0) { + gm_memset_safe(oid, sizeof(*oid), 0, sizeof(*oid)); + return GM_ERR_INVALID_ARGUMENT; + } + uint8_t hi_component = + (uint8_t)(((uint32_t)high_nibble_value) << KNibbleBits); + uint8_t lo_component = (uint8_t)low_nibble_value; + oid->id[index] = (uint8_t)(hi_component | lo_component); + } + + return GM_OK; +} diff --git a/core/tests/unit/test_cache_branch_limits.c b/core/tests/unit/test_cache_branch_limits.c index 7edf9f78..4ea6679f 100644 --- a/core/tests/unit/test_cache_branch_limits.c +++ b/core/tests/unit/test_cache_branch_limits.c @@ -15,6 +15,7 @@ #include "gitmind/journal.h" #include "gitmind/result.h" #include "gitmind/types.h" +#include "gitmind/util/oid.h" #include "gitmind/types/ulid.h" #include "gitmind/adapters/fs/posix_temp_adapter.h" @@ -73,8 +74,8 @@ static void append_dummy_edge(gm_context_t *ctx) { memset(src_raw, 0x11, sizeof src_raw); memset(tgt_raw, 0x22, sizeof tgt_raw); - git_oid_fromraw(&edge.src_oid, src_raw); - git_oid_fromraw(&edge.tgt_oid, tgt_raw); + assert(gm_oid_from_raw(&edge.src_oid, src_raw, sizeof src_raw) == GM_OK); + assert(gm_oid_from_raw(&edge.tgt_oid, tgt_raw, sizeof tgt_raw) == GM_OK); edge.rel_type = GM_REL_IMPLEMENTS; edge.confidence = 0x3C00; diff --git a/core/tests/unit/test_cache_edge_map.c b/core/tests/unit/test_cache_edge_map.c index a9dcae83..74c9c2ce 100644 --- a/core/tests/unit/test_cache_edge_map.c +++ b/core/tests/unit/test_cache_edge_map.c @@ -6,15 +6,13 @@ #include #include -#include - #include "gitmind/cache/bitmap.h" #include "gitmind/error.h" +#include "gitmind/util/oid.h" static gm_oid_t make_oid(const char *hex) { gm_oid_t oid = {{0}}; - int status = git_oid_fromstr(&oid, hex); - assert(status == 0); + assert(gm_oid_from_hex(&oid, hex) == GM_OK); return oid; } @@ -38,7 +36,7 @@ static int visit_and_collect(const gm_oid_t *oid, const roaring_bitmap_t *bitmap void *userdata) { visit_ctx_t *ctx = (visit_ctx_t *)userdata; for (size_t index = 0; index < 2; ++index) { - if (git_oid_cmp(&ctx->expected[index], oid) == 0) { + if (gm_oid_equal(&ctx->expected[index], oid)) { ctx->counts[index] = (uint32_t)gm_bitmap_count(bitmap); ++ctx->seen; return GM_OK; diff --git a/core/tests/unit/test_cache_query.c b/core/tests/unit/test_cache_query.c index 280232a0..0df0ebc8 100644 --- a/core/tests/unit/test_cache_query.c +++ b/core/tests/unit/test_cache_query.c @@ -14,6 +14,7 @@ #include "gitmind/result.h" #include "gitmind/edge.h" #include "gitmind/types.h" +#include "gitmind/util/oid.h" #include "gitmind/adapters/fs/posix_temp_adapter.h" #include "gitmind/adapters/git/libgit2_repository_port.h" @@ -87,10 +88,12 @@ int main(void) { gm_edge_t edges[2]; memset(edges, 0, sizeof edges); uint8_t A[GM_OID_RAWSZ], B[GM_OID_RAWSZ], C[GM_OID_RAWSZ]; memset(A, 0x11, sizeof A); memset(B, 0x22, sizeof B); memset(C, 0x33, sizeof C); - git_oid_fromraw(&edges[0].src_oid, A); git_oid_fromraw(&edges[0].tgt_oid, B); + assert(gm_oid_from_raw(&edges[0].src_oid, A, sizeof A) == GM_OK); + assert(gm_oid_from_raw(&edges[0].tgt_oid, B, sizeof B) == GM_OK); edges[0].rel_type = GM_REL_IMPLEMENTS; edges[0].confidence = 0x3C00; strcpy(edges[0].src_path, "A"); strcpy(edges[0].tgt_path, "B"); (void)gm_ulid_generate(edges[0].ulid); - git_oid_fromraw(&edges[1].src_oid, A); git_oid_fromraw(&edges[1].tgt_oid, C); + assert(gm_oid_from_raw(&edges[1].src_oid, A, sizeof A) == GM_OK); + assert(gm_oid_from_raw(&edges[1].tgt_oid, C, sizeof C) == GM_OK); edges[1].rel_type = GM_REL_IMPLEMENTS; edges[1].confidence = 0x3C00; strcpy(edges[1].src_path, "A"); strcpy(edges[1].tgt_path, "C"); (void)gm_ulid_generate(edges[1].ulid); @@ -102,13 +105,13 @@ int main(void) { assert(rc == GM_OK); gm_cache_result_t r1 = {0}, r2 = {0}; - gm_oid_t a_oid; git_oid_fromraw(&a_oid, A); + gm_oid_t a_oid; assert(gm_oid_from_raw(&a_oid, A, sizeof A) == GM_OK); rc = gm_cache_query_fanout(&ctx, "testq", &a_oid, &r1); assert(rc == GM_OK); assert(r1.count >= 2); gm_cache_result_free(&r1); - gm_oid_t b_oid; git_oid_fromraw(&b_oid, B); + gm_oid_t b_oid; assert(gm_oid_from_raw(&b_oid, B, sizeof B) == GM_OK); rc = gm_cache_query_fanin(&ctx, "testq", &b_oid, &r2); assert(rc == GM_OK); assert(r2.count >= 1); diff --git a/core/tests/unit/test_cache_shard_distribution.c b/core/tests/unit/test_cache_shard_distribution.c index 79c9cbb1..f4fd917f 100644 --- a/core/tests/unit/test_cache_shard_distribution.c +++ b/core/tests/unit/test_cache_shard_distribution.c @@ -7,6 +7,8 @@ #include #include "gitmind/types.h" +#include "gitmind/util/oid.h" +#include "gitmind/error.h" /* Simple LCG for deterministic pseudo-random bytes */ static uint32_t lcg_state = 0x12345678u; @@ -18,7 +20,7 @@ static uint32_t lcg_next(void) { static void random_oid(gm_oid_t *oid) { uint8_t raw[GM_OID_RAWSZ]; for (int i = 0; i < GM_OID_RAWSZ; i++) raw[i] = (uint8_t)(lcg_next() & 0xFF); - git_oid_fromraw(oid, raw); + assert(gm_oid_from_raw(oid, raw, sizeof raw) == GM_OK); } int main(void) { diff --git a/core/tests/unit/test_edge_attributed_cbor.c b/core/tests/unit/test_edge_attributed_cbor.c index dc794922..ab405893 100644 --- a/core/tests/unit/test_edge_attributed_cbor.c +++ b/core/tests/unit/test_edge_attributed_cbor.c @@ -9,6 +9,8 @@ #include "gitmind/cbor/cbor.h" #include "gitmind/cbor/keys.h" #include "gitmind/types.h" +#include "gitmind/util/oid.h" +#include "gitmind/error.h" static void test_roundtrip_full(void) { printf("test_edge_attributed_roundtrip_full... "); @@ -23,8 +25,8 @@ static void test_roundtrip_full(void) { strcpy(e.ulid, "01ARZ3NDEKTSV4RRFFQ69G5FAV"); uint8_t rawA[GM_OID_RAWSZ]; memset(rawA, 0xAA, sizeof rawA); uint8_t rawB[GM_OID_RAWSZ]; memset(rawB, 0xBB, sizeof rawB); - git_oid_fromraw(&e.src_oid, rawA); - git_oid_fromraw(&e.tgt_oid, rawB); + assert(gm_oid_from_raw(&e.src_oid, rawA, sizeof rawA) == GM_OK); + assert(gm_oid_from_raw(&e.tgt_oid, rawB, sizeof rawB) == GM_OK); e.attribution.source_type = GM_SOURCE_AI_CLAUDE; strcpy(e.attribution.author, "claude@local"); strcpy(e.attribution.session_id, "sess-1"); @@ -38,8 +40,8 @@ static void test_roundtrip_full(void) { assert(dec.ok); gm_edge_attributed_t d = dec.u.val; - assert(git_oid_cmp(&e.src_oid, &d.src_oid) == 0); - assert(git_oid_cmp(&e.tgt_oid, &d.tgt_oid) == 0); + assert(gm_oid_equal(&e.src_oid, &d.src_oid)); + assert(gm_oid_equal(&e.tgt_oid, &d.tgt_oid)); assert(d.rel_type == e.rel_type); assert(d.confidence == e.confidence); assert(strcmp(d.src_path, e.src_path) == 0); @@ -105,8 +107,8 @@ static void test_legacy_backfill(void) { gm_result_edge_attributed_t dec = gm_edge_attributed_decode_cbor(buf, off); assert(dec.ok); gm_edge_attributed_t d = dec.u.val; - assert(!git_oid_is_zero(&d.src_oid)); /* backfilled from SHA */ - assert(!git_oid_is_zero(&d.tgt_oid)); + assert(!gm_oid_is_zero(&d.src_oid)); /* backfilled from SHA */ + assert(!gm_oid_is_zero(&d.tgt_oid)); printf("OK\n"); } diff --git a/core/tests/unit/test_edge_cbor_oid.c b/core/tests/unit/test_edge_cbor_oid.c index 390f3525..d463471c 100644 --- a/core/tests/unit/test_edge_cbor_oid.c +++ b/core/tests/unit/test_edge_cbor_oid.c @@ -7,6 +7,8 @@ #include "gitmind/edge.h" #include "gitmind/types.h" +#include "gitmind/util/oid.h" +#include "gitmind/error.h" /* Simple test for OID-first CBOR encode/decode */ int main(void) { @@ -26,8 +28,8 @@ int main(void) { /* Set preferred OIDs */ uint8_t src_raw[GM_OID_RAWSZ]; memset(src_raw, 0xAA, sizeof src_raw); uint8_t tgt_raw[GM_OID_RAWSZ]; memset(tgt_raw, 0xBB, sizeof tgt_raw); - git_oid_fromraw(&e.src_oid, src_raw); - git_oid_fromraw(&e.tgt_oid, tgt_raw); + assert(gm_oid_from_raw(&e.src_oid, src_raw, sizeof src_raw) == GM_OK); + assert(gm_oid_from_raw(&e.tgt_oid, tgt_raw, sizeof tgt_raw) == GM_OK); uint8_t buf[1024]; size_t len = sizeof buf; @@ -40,8 +42,8 @@ int main(void) { gm_edge_t d = dec.u.val; /* OIDs must carry through */ - assert(git_oid_cmp(&d.src_oid, &e.src_oid) == 0); - assert(git_oid_cmp(&d.tgt_oid, &e.tgt_oid) == 0); + assert(gm_oid_equal(&d.src_oid, &e.src_oid)); + assert(gm_oid_equal(&d.tgt_oid, &e.tgt_oid)); /* Equality must use OID-first */ assert(gm_edge_equal(&e, &d)); @@ -49,4 +51,3 @@ int main(void) { printf("OK\n"); return 0; } - diff --git a/core/tests/unit/test_edge_equal_semantics.c b/core/tests/unit/test_edge_equal_semantics.c index 357f025d..9935c1a6 100644 --- a/core/tests/unit/test_edge_equal_semantics.c +++ b/core/tests/unit/test_edge_equal_semantics.c @@ -7,6 +7,8 @@ #include "gitmind/edge.h" #include "gitmind/types.h" +#include "gitmind/util/oid.h" +#include "gitmind/error.h" static void test_equal_with_oids(void) { printf("test_equal_with_oids... "); @@ -16,12 +18,12 @@ static void test_equal_with_oids(void) { memset(a.src_sha, 0x11, GM_SHA1_SIZE); memset(b.src_sha, 0x22, GM_SHA1_SIZE); uint8_t raw[GM_OID_RAWSZ]; memset(raw, 0xAA, sizeof raw); - git_oid_fromraw(&a.src_oid, raw); - git_oid_fromraw(&b.src_oid, raw); + assert(gm_oid_from_raw(&a.src_oid, raw, sizeof raw) == GM_OK); + assert(gm_oid_from_raw(&b.src_oid, raw, sizeof raw) == GM_OK); memset(a.tgt_sha, 0x33, GM_SHA1_SIZE); memset(b.tgt_sha, 0x44, GM_SHA1_SIZE); - git_oid_fromraw(&a.tgt_oid, raw); - git_oid_fromraw(&b.tgt_oid, raw); + assert(gm_oid_from_raw(&a.tgt_oid, raw, sizeof raw) == GM_OK); + assert(gm_oid_from_raw(&b.tgt_oid, raw, sizeof raw) == GM_OK); assert(gm_edge_equal(&a, &b)); printf("OK\n"); } @@ -49,4 +51,3 @@ int main(void) { printf("\nAll Edge Equality Semantics Tests Passed! ✅\n"); return 0; } - diff --git a/core/tests/unit/test_edge_oid_fallback.c b/core/tests/unit/test_edge_oid_fallback.c index 049b39f1..a34f2f89 100644 --- a/core/tests/unit/test_edge_oid_fallback.c +++ b/core/tests/unit/test_edge_oid_fallback.c @@ -6,6 +6,8 @@ #include #include "gitmind/edge.h" +#include "gitmind/util/oid.h" +#include "gitmind/error.h" int main(void) { printf("test_edge_oid_fallback... "); @@ -27,8 +29,10 @@ int main(void) { /* Now set OIDs non-zero and different; equality must use OIDs */ uint8_t raw1[GM_OID_RAWSZ]; memset(raw1, 0xAA, sizeof raw1); uint8_t raw2[GM_OID_RAWSZ]; memset(raw2, 0xBB, sizeof raw2); - git_oid_fromraw(&a.src_oid, raw1); git_oid_fromraw(&b.src_oid, raw2); - git_oid_fromraw(&a.tgt_oid, raw1); git_oid_fromraw(&b.tgt_oid, raw2); + assert(gm_oid_from_raw(&a.src_oid, raw1, sizeof raw1) == GM_OK); + assert(gm_oid_from_raw(&b.src_oid, raw2, sizeof raw2) == GM_OK); + assert(gm_oid_from_raw(&a.tgt_oid, raw1, sizeof raw1) == GM_OK); + assert(gm_oid_from_raw(&b.tgt_oid, raw2, sizeof raw2) == GM_OK); assert(!gm_edge_equal(&a, &b)); printf("OK\n"); diff --git a/core/tests/unit/test_journal_mixed_cbor.c b/core/tests/unit/test_journal_mixed_cbor.c index 06aade2a..632adb4e 100644 --- a/core/tests/unit/test_journal_mixed_cbor.c +++ b/core/tests/unit/test_journal_mixed_cbor.c @@ -16,6 +16,7 @@ #include "gitmind/context.h" #include "gitmind/result.h" #include "gitmind/util/memory.h" +#include "gitmind/util/oid.h" #include "gitmind/adapters/git/libgit2_repository_port.h" typedef struct { @@ -56,14 +57,16 @@ int main(void) { e.rel_type = GM_REL_IMPLEMENTS; e.confidence = 0x3C00; e.timestamp = 7; uint8_t rawA[GM_OID_RAWSZ]; memset(rawA, 0xCC, sizeof rawA); uint8_t rawB[GM_OID_RAWSZ]; memset(rawB, 0xDD, sizeof rawB); - git_oid_fromraw(&e.src_oid, rawA); git_oid_fromraw(&e.tgt_oid, rawB); + assert(gm_oid_from_raw(&e.src_oid, rawA, sizeof rawA) == GM_OK); + assert(gm_oid_from_raw(&e.tgt_oid, rawB, sizeof rawB) == GM_OK); gm_result_ulid_t u = gm_ulid_generate(e.ulid); assert(u.ok); uint8_t buf1[512]; size_t len1 = sizeof buf1; assert(gm_edge_encode_cbor(&e, buf1, &len1).ok); gm_edge_attributed_t ae = {0}; strcpy(ae.src_path, "docs/A.md"); strcpy(ae.tgt_path, "src/C.c"); ae.rel_type = GM_REL_REFERENCES; ae.confidence = 0x1C00; ae.timestamp = 8; - git_oid_fromraw(&ae.src_oid, rawA); git_oid_fromraw(&ae.tgt_oid, rawB); + assert(gm_oid_from_raw(&ae.src_oid, rawA, sizeof rawA) == GM_OK); + assert(gm_oid_from_raw(&ae.tgt_oid, rawB, sizeof rawB) == GM_OK); ae.attribution.source_type = GM_SOURCE_AI_CLAUDE; strcpy(ae.attribution.author, "claude@local"); strcpy(ae.attribution.session_id, "s1"); diff --git a/core/tests/unit/test_journal_safety.c b/core/tests/unit/test_journal_safety.c index 7ef1e386..887320f3 100644 --- a/core/tests/unit/test_journal_safety.c +++ b/core/tests/unit/test_journal_safety.c @@ -9,6 +9,8 @@ #include "gitmind/security/string.h" #include "gitmind/edge.h" #include "gitmind/types.h" +#include "gitmind/util/oid.h" +#include "gitmind/error.h" static void test_base64_roundtrip(void) { printf("test_base64_roundtrip... "); @@ -55,24 +57,24 @@ static void test_edge_equal_oid_preferred(void) { /* Same OIDs */ uint8_t same_raw[GM_OID_RAWSZ]; memset(same_raw, 0xAA, sizeof same_raw); - git_oid_fromraw(&a.src_oid, same_raw); - git_oid_fromraw(&b.src_oid, same_raw); - git_oid_fromraw(&a.tgt_oid, same_raw); - git_oid_fromraw(&b.tgt_oid, same_raw); + assert(gm_oid_from_raw(&a.src_oid, same_raw, sizeof same_raw) == GM_OK); + assert(gm_oid_from_raw(&b.src_oid, same_raw, sizeof same_raw) == GM_OK); + assert(gm_oid_from_raw(&a.tgt_oid, same_raw, sizeof same_raw) == GM_OK); + assert(gm_oid_from_raw(&b.tgt_oid, same_raw, sizeof same_raw) == GM_OK); assert(gm_edge_equal(&a, &b)); /* OIDs differ but legacy SHAs match => OID-first: not equal */ gm_edge_t c = a, d = a; uint8_t other_raw[GM_OID_RAWSZ]; memset(other_raw, 0xBB, sizeof other_raw); - git_oid_fromraw(&c.src_oid, other_raw); - git_oid_fromraw(&d.tgt_oid, other_raw); + assert(gm_oid_from_raw(&c.src_oid, other_raw, sizeof other_raw) == GM_OK); + assert(gm_oid_from_raw(&d.tgt_oid, other_raw, sizeof other_raw) == GM_OK); assert(!gm_edge_equal(&c, &d)); /* Both differ (OIDs and legacy) => not equal */ gm_edge_t e1 = a, e2 = b; - git_oid_fromraw(&e2.src_oid, other_raw); - git_oid_fromraw(&e2.tgt_oid, other_raw); + assert(gm_oid_from_raw(&e2.src_oid, other_raw, sizeof other_raw) == GM_OK); + assert(gm_oid_from_raw(&e2.tgt_oid, other_raw, sizeof other_raw) == GM_OK); assert(!gm_edge_equal(&e1, &e2)); printf("OK\n"); } diff --git a/docs/activity/2025-09.md b/docs/activity/2025-09.md index c332df94..68893690 100644 --- a/docs/activity/2025-09.md +++ b/docs/activity/2025-09.md @@ -5,9 +5,16 @@ audience: [contributors] domain: [quality] tags: [activity] status: archive -last_updated: 2025-09-20 +last_updated: 2025-09-29 --- +## 2025-09-29 + +2025-09-29 +- GM OID utilities: added `gm_oid_from_raw`, `gm_oid_from_hex`, `gm_oid_equal`, and `gm_oid_is_zero`, then rewired edge encode/decode, cache metadata checks, hooks, and the journal writer to consume the port-friendly helpers (no direct libgit2 helpers remain in those paths). +- Cache stability: zero-initialize cache metadata before reuse to avoid garbage OID bytes and eliminate the sporadic cache-query assertion we hit during `make ci-local`. +- Test update sweep: migrated unit tests off `git_oid_fromraw/git_oid_cmp` to the new helpers and asserted return codes so fixtures stay aligned with the hexagonal seams. + ## 2025-09-20 2025-09-20 From ebd9f75e1e67cb421f946521a9337949d43fef02 Mon Sep 17 00:00:00 2001 From: "P.R. PhiedBach" Date: Mon, 29 Sep 2025 07:40:38 +0000 Subject: [PATCH 4/8] opus(PR#173): seed rehearsal score (7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f) --- ...445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md diff --git a/docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md b/docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md new file mode 100644 index 00000000..22e6a91d --- /dev/null +++ b/docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md @@ -0,0 +1,125 @@ +--- +title: 7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md +description: Preserved review artifacts and rationale. +audience: [contributors] +domain: [quality] +tags: [review] +status: archive +--- + +# Code Review Feedback + +| Date | Agent | SHA | Branch | PR | +|------|-------|-----|--------|----| +| 2025-09-29 | CodeRabbit (and reviewers) | `7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f` | [feat/edge-port-followup](https://github.com/neuroglyph/git-mind/tree/feat/edge-port-followup "neuroglyph/git-mind:feat/edge-port-followup") | [PR#173](https://github.com/neuroglyph/git-mind/pull/173) | + +## CODE REVIEW FEEDBACK + +### General comment — coderabbitai[bot] + +```text + + + +> [!NOTE] +> Currently processing new changes in this PR. This may take a few minutes, please wait... +> +>
+> 📥 Commits +> +> Reviewing files that changed from the base of the PR and between 069ff595ec98e22c5075f06289eaca3395359691 and 7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f. +> +>
+> +>
+> 📒 Files selected for processing (28) +> +> * `AGENTS.md` (1 hunks) +> * `core/include/gitmind/util/oid.h` (2 hunks) +> * `core/src/cache/query.c` (4 hunks) +> * `core/src/domain/cache/edge_map.c` (2 hunks) +> * `core/src/edge/attributed.c` (3 hunks) +> * `core/src/edge/edge.c` (7 hunks) +> * `core/src/hooks/augment.c` (2 hunks) +> * `core/src/journal/writer.c` (4 hunks) +> * `core/src/util/oid.c` (2 hunks) +> * `core/tests/unit/test_cache_branch_limits.c` (2 hunks) +> * `core/tests/unit/test_cache_edge_map.c` (2 hunks) +> * `core/tests/unit/test_cache_query.c` (3 hunks) +> * `core/tests/unit/test_cache_shard_distribution.c` (2 hunks) +> * `core/tests/unit/test_edge_attributed_cbor.c` (4 hunks) +> * `core/tests/unit/test_edge_cbor_oid.c` (3 hunks) +> * `core/tests/unit/test_edge_equal_semantics.c` (2 hunks) +> * `core/tests/unit/test_edge_oid_fallback.c` (2 hunks) +> * `core/tests/unit/test_journal_mixed_cbor.c` (2 hunks) +> * `core/tests/unit/test_journal_safety.c` (2 hunks) +> * `docs/activity/2025-09.md` (1 hunks) +> * `docs/code-reviews/PR172/203f4e3539b1d8fc73b641e94b0a420f2e592a14.md` (0 hunks) +> * `docs/code-reviews/PR172/5402cadb5e7a3f71e0bee7a1e05a1f5034d4fc3c.md` (0 hunks) +> * `docs/code-reviews/PR172/5add14fcdabafff59a99ea484d691140afdb68c3.md` (0 hunks) +> * `docs/code-reviews/PR172/7b7b5f565ef23d959b126b0df50e0a3992c52da2.md` (0 hunks) +> * `docs/code-reviews/PR172/82dab217893b6ee8bb8dcdca2217f9900a06b76f.md` (0 hunks) +> * `docs/code-reviews/PR172/8a32c6a810ebf632709cec6c928381c9c47fdee9.md` (0 hunks) +> * `docs/code-reviews/PR172/b22c22398de39c4ab93e1c747b1122d2241eed22.md` (0 hunks) +> * `docs/code-reviews/PR172/d11ee830d5615e5582114d625a52283760d61767.md` (0 hunks) +> +>
+> +> ```ascii +> _________________________________________ +> < Never ask an AI its Energy Star rating. > +> ----------------------------------------- +> \ +> \ \ +> \ /\ +> ( ) +> .( o ). +> ``` + + + + + + +
+✨ Finishing touches + +- [ ] 📝 Generate Docstrings +
+🧪 Generate unit tests + +- [ ] Create PR with unit tests +- [ ] Post copyable unit tests in a comment +- [ ] Commit unit tests in branch `feat/edge-port-followup` + +
+ +
+ + + + + +--- + +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 + +- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) +- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) +- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) +- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) + +
+ +Comment `@coderabbitai help` to get the list of available commands and usage tips. + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#issuecomment-3345476880 + +{response} + From 17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d Mon Sep 17 00:00:00 2001 From: "J. Kirby Ross" Date: Mon, 29 Sep 2025 02:22:33 -0700 Subject: [PATCH 5/8] fix(review): address coderabbit feedback --- .../adapters/git/libgit2_repository_port.c | 3 +- core/src/cache/query.c | 7 +- core/src/domain/cache/edge_map.c | 5 + core/src/hooks/augment.c | 7 +- core/tests/unit/test_cache_branch_limits.c | 5 +- core/tests/unit/test_cache_query.c | 4 +- core/tests/unit/test_edge_cbor_oid.c | 5 + core/tests/unit/test_edge_oid_fallback.c | 7 +- core/tests/unit/test_journal_mixed_cbor.c | 14 +- core/tests/unit/test_journal_safety.c | 1 + docs/activity/2025-09.md | 11 + ...445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md | 297 +++++++++++++++++- 12 files changed, 351 insertions(+), 15 deletions(-) diff --git a/core/src/adapters/git/libgit2_repository_port.c b/core/src/adapters/git/libgit2_repository_port.c index 208eceab..88aa7dcc 100644 --- a/core/src/adapters/git/libgit2_repository_port.c +++ b/core/src/adapters/git/libgit2_repository_port.c @@ -37,6 +37,7 @@ #include "gitmind/security/memory.h" #include "gitmind/security/string.h" #include "gitmind/types.h" +#include "gitmind/util/oid.h" struct gm_libgit2_repository_port_state { git_repository *repo; @@ -923,7 +924,7 @@ static gm_result_void_t reference_update_impl( GM_ERROR(GM_ERR_UNKNOWN, "reference %s missing target", spec->ref_name)); } - if (!git_oid_equal(current_target, spec->target_oid)) { + if (!gm_oid_equal(current_target, spec->target_oid)) { int descendant = git_graph_descendant_of(state->repo, spec->target_oid, current_target); if (descendant < 0) { diff --git a/core/src/cache/query.c b/core/src/cache/query.c index e52507a7..c3a30bfb 100644 --- a/core/src/cache/query.c +++ b/core/src/cache/query.c @@ -167,7 +167,12 @@ bool gm_cache_is_stale(gm_context_t *ctx, const char *branch) { /* Check age */ time_t now = time(NULL); - if ((uint64_t)now - meta.journal_tip_time > CACHE_MAX_AGE_SECONDS) { + if (now <= 0) { + return true; + } + uint64_t now_u = (uint64_t)now; + if (now_u > meta.journal_tip_time && + (now_u - meta.journal_tip_time) > CACHE_MAX_AGE_SECONDS) { return true; } diff --git a/core/src/domain/cache/edge_map.c b/core/src/domain/cache/edge_map.c index 860d74b8..73f80d63 100644 --- a/core/src/domain/cache/edge_map.c +++ b/core/src/domain/cache/edge_map.c @@ -82,6 +82,11 @@ gm_result_void_t gm_edge_map_create(size_t bucket_count, gm_edge_map_t **out_map GM_ERROR(GM_ERR_INVALID_ARGUMENT, "edge map output pointer required")); } + if (bucket_count == 0U) { + return gm_err_void(GM_ERROR(GM_ERR_INVALID_ARGUMENT, + "edge map bucket count must be > 0")); + } + gm_edge_map_t *map = calloc(1, sizeof(gm_edge_map_t)); if (map == NULL) { return gm_err_void(GM_ERROR(GM_ERR_OUT_OF_MEMORY, "edge map alloc failed")); diff --git a/core/src/hooks/augment.c b/core/src/hooks/augment.c index 2f6d8f1a..d6046d11 100644 --- a/core/src/hooks/augment.c +++ b/core/src/hooks/augment.c @@ -4,6 +4,7 @@ #include "gitmind/hooks/augment.h" #include +#include #include #include @@ -181,7 +182,7 @@ static int edge_search_callback(const gm_edge_t *edge, void *userdata) { /* Limit lookback */ ctx->scanned++; if (ctx->scanned > LOOKBACK_LIMIT) { - return 1; /* Stop iteration */ + return GM_CALLBACK_STOP; /* Stop iteration */ } /* Check if source matches (OID compare) */ @@ -202,7 +203,7 @@ static int edge_search_callback(const gm_edge_t *edge, void *userdata) { ctx->edges[ctx->count++] = *edge; } - return 0; /* Continue */ + return GM_OK; /* Continue */ } /* Find recent edges with given source blob */ @@ -222,7 +223,7 @@ int gm_hook_find_edges_by_source(gm_context_t *ctx, const gm_oid_t *src_oid, /* Walk journal looking for edges */ int error = gm_journal_read(ctx, NULL, edge_search_callback, &search_ctx); - if (error < 0 && error != 1) { /* 1 means we stopped early */ + if (error != GM_OK && error != GM_CALLBACK_STOP) { /* stopped early */ free(search_ctx.edges); return error; } diff --git a/core/tests/unit/test_cache_branch_limits.c b/core/tests/unit/test_cache_branch_limits.c index 4ea6679f..4236dacf 100644 --- a/core/tests/unit/test_cache_branch_limits.c +++ b/core/tests/unit/test_cache_branch_limits.c @@ -11,6 +11,7 @@ #include "gitmind/cache.h" #include "gitmind/context.h" #include "gitmind/edge.h" +#include "gitmind/util/memory.h" #include "gitmind/error.h" #include "gitmind/journal.h" #include "gitmind/result.h" @@ -79,8 +80,8 @@ static void append_dummy_edge(gm_context_t *ctx) { edge.rel_type = GM_REL_IMPLEMENTS; edge.confidence = 0x3C00; - strcpy(edge.src_path, "A"); - strcpy(edge.tgt_path, "B"); + assert(gm_strcpy_safe(edge.src_path, sizeof edge.src_path, "A") == GM_OK); + assert(gm_strcpy_safe(edge.tgt_path, sizeof edge.tgt_path, "B") == GM_OK); (void)gm_ulid_generate(edge.ulid); int rc = gm_journal_append(ctx, &edge, 1); diff --git a/core/tests/unit/test_cache_query.c b/core/tests/unit/test_cache_query.c index 0df0ebc8..0dd48db5 100644 --- a/core/tests/unit/test_cache_query.c +++ b/core/tests/unit/test_cache_query.c @@ -15,6 +15,7 @@ #include "gitmind/edge.h" #include "gitmind/types.h" #include "gitmind/util/oid.h" +#include "gitmind/security/string.h" #include "gitmind/adapters/fs/posix_temp_adapter.h" #include "gitmind/adapters/git/libgit2_repository_port.h" @@ -35,7 +36,8 @@ static void ensure_branch_with_commit(git_repository *repo, const char *branch) assert(rc == 0); char refname[128]; - snprintf(refname, sizeof refname, "refs/heads/%s", branch); + int wn = gm_snprintf(refname, sizeof refname, "refs/heads/%s", branch); + assert(wn >= 0 && (size_t)wn < sizeof refname); /* Create a commit object and then a direct ref to it */ rc = git_commit_create_from_ids(&commit_oid, repo, NULL, sig, sig, NULL, diff --git a/core/tests/unit/test_edge_cbor_oid.c b/core/tests/unit/test_edge_cbor_oid.c index d463471c..9e3cf387 100644 --- a/core/tests/unit/test_edge_cbor_oid.c +++ b/core/tests/unit/test_edge_cbor_oid.c @@ -8,6 +8,7 @@ #include "gitmind/edge.h" #include "gitmind/types.h" #include "gitmind/util/oid.h" +#include "gitmind/util/memory.h" #include "gitmind/error.h" /* Simple test for OID-first CBOR encode/decode */ @@ -30,6 +31,10 @@ int main(void) { uint8_t tgt_raw[GM_OID_RAWSZ]; memset(tgt_raw, 0xBB, sizeof tgt_raw); assert(gm_oid_from_raw(&e.src_oid, src_raw, sizeof src_raw) == GM_OK); assert(gm_oid_from_raw(&e.tgt_oid, tgt_raw, sizeof tgt_raw) == GM_OK); + assert(gm_strcpy_safe(e.src_path, sizeof e.src_path, "src/A.c") == GM_OK); + assert(gm_strcpy_safe(e.tgt_path, sizeof e.tgt_path, "src/B.c") == GM_OK); + assert(gm_strcpy_safe(e.ulid, sizeof e.ulid, + "01ARZ3NDEKTSV4RRFFQ69G5FAV") == GM_OK); uint8_t buf[1024]; size_t len = sizeof buf; diff --git a/core/tests/unit/test_edge_oid_fallback.c b/core/tests/unit/test_edge_oid_fallback.c index a34f2f89..2f8af3cc 100644 --- a/core/tests/unit/test_edge_oid_fallback.c +++ b/core/tests/unit/test_edge_oid_fallback.c @@ -7,6 +7,7 @@ #include "gitmind/edge.h" #include "gitmind/util/oid.h" +#include "gitmind/util/memory.h" #include "gitmind/error.h" int main(void) { @@ -20,8 +21,10 @@ int main(void) { memset(b.src_sha, 0x11, GM_SHA1_SIZE); memset(b.tgt_sha, 0x22, GM_SHA1_SIZE); a.rel_type = b.rel_type = GM_REL_REFERENCES; - strcpy(a.src_path, "A"); strcpy(a.tgt_path, "B"); - strcpy(b.src_path, "A"); strcpy(b.tgt_path, "B"); + assert(gm_strcpy_safe(a.src_path, sizeof a.src_path, "A") == GM_OK); + assert(gm_strcpy_safe(a.tgt_path, sizeof a.tgt_path, "B") == GM_OK); + assert(gm_strcpy_safe(b.src_path, sizeof b.src_path, "A") == GM_OK); + assert(gm_strcpy_safe(b.tgt_path, sizeof b.tgt_path, "B") == GM_OK); /* With zero OIDs and identical legacy bytes, edges should be equal */ assert(gm_edge_equal(&a, &b)); diff --git a/core/tests/unit/test_journal_mixed_cbor.c b/core/tests/unit/test_journal_mixed_cbor.c index 632adb4e..4a15a2d1 100644 --- a/core/tests/unit/test_journal_mixed_cbor.c +++ b/core/tests/unit/test_journal_mixed_cbor.c @@ -53,7 +53,8 @@ int main(void) { /* Build mixed CBOR payload: one basic, one attributed */ gm_edge_t e = {0}; - strcpy(e.src_path, "src/A.c"); strcpy(e.tgt_path, "src/B.c"); + assert(gm_strcpy_safe(e.src_path, sizeof e.src_path, "src/A.c") == GM_OK); + assert(gm_strcpy_safe(e.tgt_path, sizeof e.tgt_path, "src/B.c") == GM_OK); e.rel_type = GM_REL_IMPLEMENTS; e.confidence = 0x3C00; e.timestamp = 7; uint8_t rawA[GM_OID_RAWSZ]; memset(rawA, 0xCC, sizeof rawA); uint8_t rawB[GM_OID_RAWSZ]; memset(rawB, 0xDD, sizeof rawB); @@ -63,13 +64,18 @@ int main(void) { uint8_t buf1[512]; size_t len1 = sizeof buf1; assert(gm_edge_encode_cbor(&e, buf1, &len1).ok); gm_edge_attributed_t ae = {0}; - strcpy(ae.src_path, "docs/A.md"); strcpy(ae.tgt_path, "src/C.c"); + assert(gm_strcpy_safe(ae.src_path, sizeof ae.src_path, + "docs/A.md") == GM_OK); + assert(gm_strcpy_safe(ae.tgt_path, sizeof ae.tgt_path, + "src/C.c") == GM_OK); ae.rel_type = GM_REL_REFERENCES; ae.confidence = 0x1C00; ae.timestamp = 8; assert(gm_oid_from_raw(&ae.src_oid, rawA, sizeof rawA) == GM_OK); assert(gm_oid_from_raw(&ae.tgt_oid, rawB, sizeof rawB) == GM_OK); ae.attribution.source_type = GM_SOURCE_AI_CLAUDE; - strcpy(ae.attribution.author, "claude@local"); - strcpy(ae.attribution.session_id, "s1"); + assert(gm_strcpy_safe(ae.attribution.author, sizeof ae.attribution.author, + "claude@local") == GM_OK); + assert(gm_strcpy_safe(ae.attribution.session_id, + sizeof ae.attribution.session_id, "s1") == GM_OK); ae.lane = GM_LANE_ANALYSIS; u = gm_ulid_generate(ae.ulid); assert(u.ok); uint8_t buf2[512]; size_t len2 = sizeof buf2; assert(gm_edge_attributed_encode_cbor(&ae, buf2, &len2).ok); diff --git a/core/tests/unit/test_journal_safety.c b/core/tests/unit/test_journal_safety.c index 887320f3..35a9f574 100644 --- a/core/tests/unit/test_journal_safety.c +++ b/core/tests/unit/test_journal_safety.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "gitmind/security/string.h" #include "gitmind/edge.h" diff --git a/docs/activity/2025-09.md b/docs/activity/2025-09.md index 68893690..4f31d007 100644 --- a/docs/activity/2025-09.md +++ b/docs/activity/2025-09.md @@ -8,6 +8,17 @@ status: archive last_updated: 2025-09-29 --- + + +# Activity 2025-09 + +## Table of Contents +- [2025-09-29](#2025-09-29) +- [2025-09-20](#2025-09-20) +- [2025-09-19](#2025-09-19) +- [2025-09-17](#2025-09-17) +- [2025-09-14](#2025-09-14) + ## 2025-09-29 2025-09-29 diff --git a/docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md b/docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md index 22e6a91d..6ec10a7b 100644 --- a/docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md +++ b/docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md @@ -78,6 +78,9 @@ status: archive +> [!NOTE]- **Accepted** +> Response: Monitoring CodeRabbit’s processing note; no action required yet. + @@ -121,5 +124,297 @@ Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. _Meta_: https://github.com/neuroglyph/git-mind/pull/173#issuecomment-3345476880 -{response} +--- + +## ⚠️ Outside diff range comments (12) + +### docs/activity/2025-09.md (1) + +#### 1-12: Add SPDX header, H1, and Table of Contents + +> [!NOTE]- **Accepted** +> Response: House style applied—SPDX comment, H1, and the manual ToC are all in place. + +Conform this activity log to house style: SPDX after front matter, single H1 matching title, and a ToC. + +As per coding guidelines + +```yaml + --- + title: Activity 2025-09 + description: Archived agent activity logs. + audience: [contributors] + domain: [quality] + tags: [activity] + status: archive + last_updated: 2025-09-29 + --- + + +-## 2025-09-29 ++ ++ ++# Activity 2025-09 ++ ++## Table of Contents ++- 2025-09-29 ++- 2025-09-20 ++- 2025-09-19 ++- 2025-09-14 ++ ++## 2025-09-29 +``` + +### core/tests/unit/test_edge_oid_fallback.c (1) + +#### 23-25: Replace strcpy with safe gm string API and check return codes + +> [!NOTE]- **Accepted** +> Response: Updated the test to use `gm_strcpy_safe` everywhere and wired in the util header so we catch truncation immediately. + +Tests must use `gm_strcpy_safe`/`gm_snprintf` per guidelines; also check return codes. + +As per coding guidelines + +```c +#include "gitmind/edge.h" + #include "gitmind/util/oid.h" + #include "gitmind/error.h" ++#include "gitmind/util/strings.h" + +@@ +- strcpy(a.src_path, "A"); strcpy(a.tgt_path, "B"); +- strcpy(b.src_path, "A"); strcpy(b.tgt_path, "B"); ++ assert(gm_strcpy_safe(a.src_path, sizeof a.src_path, "A") == 0); ++ assert(gm_strcpy_safe(a.tgt_path, sizeof a.tgt_path, "B") == 0); ++ assert(gm_strcpy_safe(b.src_path, sizeof b.src_path, "A") == 0); ++ assert(gm_strcpy_safe(b.tgt_path, sizeof b.tgt_path, "B") == 0); ++ +``` + +### core/src/domain/cache/edge_map.c (1) + +#### 79-99: Disallow `bucket_count == 0` to prevent OOB access in add + +> [!NOTE]- **Accepted** +> Response: Creation now rejects `bucket_count == 0U`; added the guard and re-ran CI to confirm coverage stays green. + +With zero buckets, `gm_edge_map_add` computes index 0 and `dereferences map->buckets[0]`, which is OOB. Reject zero at creation. + +```c + gm_result_void_t gm_edge_map_create(size_t bucket_count, gm_edge_map_t **out_map) { + if (out_map == NULL) { + return gm_err_void( + GM_ERROR(GM_ERR_INVALID_ARGUMENT, "edge map output pointer required")); + } + ++ if (bucket_count == 0U) { ++ return gm_err_void( ++ GM_ERROR(GM_ERR_INVALID_ARGUMENT, "bucket_count must be > 0")); ++ } ++ + gm_edge_map_t *map = calloc(1, sizeof(gm_edge_map_t)); + if (map == NULL) { + return gm_err_void(GM_ERROR(GM_ERR_OUT_OF_MEMORY, "edge map alloc failed")); + } +``` + +### core/src/hooks/augment.c (2) + +#### 181-186: Replace magic number with `GM_CALLBACK_STOP` consistently. + +> [!NOTE]- **Accepted** +> Response: No more magic numbers—the callback now returns `GM_CALLBACK_STOP`, the caller treats both `GM_OK` and `GM_CALLBACK_STOP` as success, and CI has been rerun. + +Return `GM_CALLBACK_STOP` from the callback and check for it at the call site; relying on literal 1 is brittle. + +```c +- if (ctx->scanned > LOOKBACK_LIMIT) { +- return 1; /* Stop iteration */ ++ if (ctx->scanned > LOOKBACK_LIMIT) { ++ return GM_CALLBACK_STOP; /* Stop iteration */ + } +... +- if (error < 0 && error != 1) { /* 1 means we stopped early */ ++ if (error < 0 && error != GM_CALLBACK_STOP) { /* stopped early */ + free(search_ctx.edges); + return error; + } +``` + +**Also applies to: 223-226** + +#### 4-18: Missing for malloc/realloc/free under C23 (warnings-as-errors). + +> [!NOTE]- **Accepted** +> Response: Added `` alongside the existing headers so malloc/realloc/free build cleanly under C23 + Werror. + +`malloc`/`realloc`/`free` are used below without including ``; this will fail our C23 + `Werror` build. + +```c + #include "gitmind/hooks/augment.h" + + #include ++#include + #include + #include +``` + +### core/tests/unit/test_cache_branch_limits.c (1) + +#### 82-85: Replace unsafe strcpy with gm_strcpy_safe and check return codes. + +> [!NOTE]- **Accepted** +> Response: Test now uses `gm_strcpy_safe` with `GM_OK` checks and includes `gitmind/util/memory.h`. + +Tests follow the same safety rules: use `gm_strcpy_safe` and fail on truncation. + +```c +- strcpy(edge.src_path, "A"); +- strcpy(edge.tgt_path, "B"); ++ assert(gm_strcpy_safe(edge.src_path, GM_PATH_MAX, "A") == GM_OK); ++ assert(gm_strcpy_safe(edge.tgt_path, GM_PATH_MAX, "B") == GM_OK); +``` + +Add the needed include if not present: + +```c ++#include "gitmind/util/memory.h" +``` + +As per coding guidelines + +> [!NOTE]- **Accepted** +> Response: Swapped in `gm_strcpy_safe` (and the util header) so the fallback test matches the safety contract. + + +### core/tests/unit/test_edge_cbor_oid.c (1) + +#### 24-27: Use `gm_strcpy_safe` for paths and ULID; fail on truncation. + +Bring test in line with string safety rules. + +> [!NOTE]- **Accepted** +> Response: Updated the test to use `gm_strcpy_safe` for both paths and the ULID, and pulled in `gitmind/util/memory.h`. + +```c +- strcpy(e.src_path, "src/A.c"); +- strcpy(e.tgt_path, "src/B.c"); +- strcpy(e.ulid, "01ARZ3NDEKTSV4RRFFQ69G5FAV"); ++ assert(gm_strcpy_safe(e.src_path, GM_PATH_MAX, "src/A.c") == GM_OK); ++ assert(gm_strcpy_safe(e.tgt_path, GM_PATH_MAX, "src/B.c") == GM_OK); ++ assert(gm_strcpy_safe(e.ulid, sizeof e.ulid, "01ARZ3NDEKTSV4RRFFQ69G5FAV") == GM_OK); +``` + + Add header if missing: + +```c ++#include "gitmind/util/memory.h" +``` + +As per coding guidelines + +### core/tests/unit/test_cache_query.c (1) + +#### 37-39: Prefer gm_snprintf and check truncation + +Replace raw `snprintf` with `gm_snprintf` and assert the result for determinism. + +> [!NOTE]- **Accepted** +> Response: Replaced the `snprintf` call with `gm_snprintf`, asserted the bounds, and included the security string header. + +```c +- char refname[128]; +- snprintf(refname, sizeof refname, "refs/heads/%s", branch); ++ char refname[128]; ++ int wn = gm_snprintf(refname, sizeof refname, "refs/heads/%s", branch); ++ assert(wn >= 0 && (size_t)wn < sizeof refname); +``` + +Include: + +```c +#include "gitmind/security/string.h" +``` + +As per coding guidelines. + +### core/tests/unit/test_journal_safety.c (1) + +#### 4-8: Missing stdlib.h for malloc/free — will fail under C23 with Werror. + +Add the header to satisfy prototypes and avoid implicit declarations. + +> [!NOTE]- **Accepted** +> Response: `` is now included so the malloc/free prototypes are visible. + +```c + #include + #include + #include + #include ++#include +``` + +### core/include/gitmind/util/oid.h (1) + +#### 4-76: Remove lingering direct libgit2 OID helper calls + +Replace the call to `git_oid_equal` at `core/src/adapters/git/libgit2_repository_port.c:926` with `gm_oid_equal`. + +> [!NOTE]- **Accepted** +> Response: Updated the adapter to call `gm_oid_equal` and included the util header. + +### core/src/cache/query.c (1) + +#### 169-172: Fix unsigned underflow in staleness age check + +If `meta.journal_tip_time > now`, `(uint64_t)now - meta.journal_tip_time underflows`, marking fresh caches as stale. Guard and only subtract when `now_u > journal_tip_time`. + +> [!NOTE]- **Accepted** +> Response: Applied the guarded subtraction exactly as outlined and reverified `make ci-local`. + +```c +- time_t now = time(NULL); +- if ((uint64_t)now - meta.journal_tip_time > CACHE_MAX_AGE_SECONDS) { +- return true; +- } ++ time_t now = time(NULL); ++ if (now <= 0) { ++ return true; ++ } ++ uint64_t now_u = (uint64_t)now; ++ if (now_u > meta.journal_tip_time && ++ (now_u - meta.journal_tip_time) > CACHE_MAX_AGE_SECONDS) { ++ return true; ++ } ++ +``` + +### core/tests/unit/test_journal_mixed_cbor.c (1) + +#### 56-57: Replace unsafe strcpy with gm_strcpy_safe and check results + +Tests must follow the same safe string/memory rules. Replace `strcpy`, assert `GM_OK`, and keep buffers zero‑initialized on failure paths. + +> [!NOTE]- **Accepted** +> Response: Replaced every `strcpy` in that file with `gm_strcpy_safe`, added assertions, and included the util header. + +```c +- strcpy(e.src_path, "src/A.c"); strcpy(e.tgt_path, "src/B.c"); ++ assert(gm_strcpy_safe(e.src_path, sizeof e.src_path, "src/A.c") == GM_OK); ++ assert(gm_strcpy_safe(e.tgt_path, sizeof e.tgt_path, "src/B.c") == GM_OK); +@@ +- strcpy(ae.src_path, "docs/A.md"); strcpy(ae.tgt_path, "src/C.c"); ++ assert(gm_strcpy_safe(ae.src_path, sizeof ae.src_path, "docs/A.md") == GM_OK); ++ assert(gm_strcpy_safe(ae.tgt_path, sizeof ae.tgt_path, "src/C.c") == GM_OK); +@@ +- strcpy(ae.attribution.author, "claude@local"); +- strcpy(ae.attribution.session_id, "s1"); ++ assert(gm_strcpy_safe(ae.attribution.author, sizeof ae.attribution.author, "claude@local") == GM_OK); ++ assert(gm_strcpy_safe(ae.attribution.session_id, sizeof ae.attribution.session_id, "s1") == GM_OK); +``` + +As per coding guidelines +**Also applies to: 66-67, 71-73** From eaf10c68312837f2c879203292c0e58b568b83a8 Mon Sep 17 00:00:00 2001 From: "P.R. PhiedBach" Date: Mon, 29 Sep 2025 09:42:34 +0000 Subject: [PATCH 6/8] opus(PR#173): seed rehearsal score (17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d) --- ...7ddad1aa3747f40ecacc0bd202e7b83edbf1d1d.md | 681 ++++++++++++++++++ 1 file changed, 681 insertions(+) create mode 100644 docs/code-reviews/PR173/17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d.md diff --git a/docs/code-reviews/PR173/17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d.md b/docs/code-reviews/PR173/17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d.md new file mode 100644 index 00000000..c222d7a2 --- /dev/null +++ b/docs/code-reviews/PR173/17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d.md @@ -0,0 +1,681 @@ +--- +title: 17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d.md +description: Preserved review artifacts and rationale. +audience: [contributors] +domain: [quality] +tags: [review] +status: archive +--- + +# Code Review Feedback + +| Date | Agent | SHA | Branch | PR | +|------|-------|-----|--------|----| +| 2025-09-29 | CodeRabbit (and reviewers) | `17ddad1aa3747f40ecacc0bd202e7b83edbf1d1d` | [feat/edge-port-followup](https://github.com/neuroglyph/git-mind/tree/feat/edge-port-followup "neuroglyph/git-mind:feat/edge-port-followup") | [PR#173](https://github.com/neuroglyph/git-mind/pull/173) | + +## CODE REVIEW FEEDBACK + +### core/include/gitmind/util/oid.h:7 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🔴 Critical_ + +
+🧩 Analysis chain + +**Verify umbrella exposure in include/gitmind.h.** + +Public headers must be umbrella‑safe and reachable via the umbrella. Please confirm this header is re‑exported. + +--- + +🏁 Script executed: + +```shell +#!/bin/bash +# Expect: include/gitmind.h exists and references util/oid.h +fd -a gitmind.h include | xargs -I{} rg -n 'gitmind/util/oid\.h' {} +# Also check for duplicates/different paths: +rg -nP --glob 'include/**' '\butil/oid\.h\b' +``` + +Length of output: 0 + +--- + +🏁 Script executed: + +```shell +#!/usr/bin/env bash +# Locate all gitmind.h files and check for util/oid.h references +find . -type f -name gitmind.h | while read file; do + echo "---- $file ----" + grep -Hn "util/oid\.h" "$file" || echo "no reference" +done +``` + +Length of output: 42 + +--- + + + +
+ +**Include util/oid.h in the umbrella header** +Add the following to `include/gitmind.h` so that `core/include/gitmind/util/oid.h` is re-exported by the umbrella API: +```diff +--- a/include/gitmind.h ++++ b/include/gitmind.h +@@ /* somewhere among other includes */ ++#include +``` + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion +++ b/include/gitmind.h +@@ /* somewhere among other umbrella-header includes */ + #include +#include + #include +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In core/include/gitmind/util/oid.h at line 7, the util/oid header is not being +re-exported by the umbrella API; open include/gitmind.h and add an #include +"gitmind/util/oid.h" (placed with the other util/includes or alphabetical group) +so that core/include/gitmind/util/oid.h is exposed via the umbrella header; +update any include guards or ordering if necessary to preserve compile order. +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021216 + +{response} + +### core/src/edge/attributed.c:285 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🔴 Critical_ + +**Fix OID backfill length mismatch (potential OOB read)** + +You pass GM_OID_RAWSZ while sourcing from out.src_sha/out.tgt_sha (GM_SHA1_SIZE). That can read past the SHA buffer or fail. Zero‑pad into a GM_OID_RAWSZ scratch first. + +```diff +- if (gm_oid_is_zero(&out.src_oid)) { +- (void)gm_oid_from_raw(&out.src_oid, out.src_sha, GM_OID_RAWSZ); +- } +- if (gm_oid_is_zero(&out.tgt_oid)) { +- (void)gm_oid_from_raw(&out.tgt_oid, out.tgt_sha, GM_OID_RAWSZ); +- } ++ if (gm_oid_is_zero(&out.src_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, out.src_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&out.src_oid, tmp, GM_OID_RAWSZ); ++ } ++ if (gm_oid_is_zero(&out.tgt_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, out.tgt_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&out.tgt_oid, tmp, GM_OID_RAWSZ); ++ } +``` +As per coding guidelines (zero outputs on error paths; use gm_memcpy_span). Based on learnings. + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion + if (gm_oid_is_zero(&out.src_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, out.src_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&out.src_oid, tmp, GM_OID_RAWSZ); + } + if (gm_oid_is_zero(&out.tgt_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, out.tgt_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&out.tgt_oid, tmp, GM_OID_RAWSZ); + } +``` + +
+ + + + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021226 + +{response} + +### core/src/edge/edge.c:497 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🔴 Critical_ + +**Fix OID backfill length mismatch (potential OOB read)** + +As in attributed.c, passing GM_OID_RAWSZ while sourcing from GM_SHA1_SIZE buffers risks OOB. Zero‑pad into a GM_OID_RAWSZ scratch first. + +```diff +- if (gm_oid_is_zero(&edge.src_oid)) { +- (void)gm_oid_from_raw(&edge.src_oid, edge.src_sha, GM_OID_RAWSZ); +- } +- if (gm_oid_is_zero(&edge.tgt_oid)) { +- (void)gm_oid_from_raw(&edge.tgt_oid, edge.tgt_sha, GM_OID_RAWSZ); +- } ++ if (gm_oid_is_zero(&edge.src_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, edge.src_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&edge.src_oid, tmp, GM_OID_RAWSZ); ++ } ++ if (gm_oid_is_zero(&edge.tgt_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, edge.tgt_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&edge.tgt_oid, tmp, GM_OID_RAWSZ); ++ } +``` +As per coding guidelines (safe memory ops; zero on error). + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion + if (gm_oid_is_zero(&edge.src_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, edge.src_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&edge.src_oid, tmp, GM_OID_RAWSZ); + } + if (gm_oid_is_zero(&edge.tgt_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, edge.tgt_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&edge.tgt_oid, tmp, GM_OID_RAWSZ); + } +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In core/src/edge/edge.c around lines 492 to 497, the code calls gm_oid_from_raw +using edge.src_sha/edge.tgt_sha buffers sized GM_SHA1_SIZE but passes +GM_OID_RAWSZ which can read past the source buffer; to fix, allocate a +GM_OID_RAWSZ-byte scratch array, zero it, copy GM_SHA1_SIZE bytes from the SHA +buffer into the scratch, then call gm_oid_from_raw with the scratch and +GM_OID_RAWSZ; ensure the scratch is zeroed before use and that any failure from +gm_oid_from_raw leaves the oid zeroed (follow existing safe-memory/error-zeroing +patterns). +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021236 + +{response} + +### core/src/util/oid.c:17 — coderabbitai[bot] + +```text +_🛠️ Refactor suggestion_ | _🟠 Major_ + +
+🧩 Analysis chain + +**Repo-wide check: ensure no straggler `git_oid_cmp`/raw memcmp remain** + +Run a quick scan to confirm all equality moves funnel through gm_oid_equal. + +--- + +🏁 Script executed: + +```shell +#!/bin/bash +# Find legacy equality patterns that should be gm_oid_equal +rg -nP --type=c --type=h -C2 '\bgit_oid_cmp\s*\(|\bmemcmp\s*\(\s*[^,]*->id\s*,\s*[^,]*->id\s*,\s*GM_OID_RAWSZ\s*\)' +``` + +Length of output: 201 + +--- + + + +
+ +**Replace raw memcmp in OID comparison with gm_oid_equal** + +* In `core/src/util/oid.c:79`, replace + `return memcmp(lhs->id, rhs->id, GM_OID_RAWSZ) == 0;` + with + `return gm_oid_equal(lhs, rhs);` + +
+🤖 Prompt for AI Agents + +``` +In core/src/util/oid.c around lines 4 to 17 and specifically at line ~79, +replace the raw memcmp comparison `memcmp(lhs->id, rhs->id, GM_OID_RAWSZ) == 0` +with the helper `gm_oid_equal(lhs, rhs)`; update the return to `return +gm_oid_equal(lhs, rhs);` so the OID equality uses the centralized function (no +other changes needed if oid.h is already included). +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021242 + +{response} + +### core/tests/unit/test_cache_query.c:101 — coderabbitai[bot] + +```text +_🛠️ Refactor suggestion_ | _🟠 Major_ + +**Use gm_strcpy_safe in tests (no raw strcpy)** + +Per project guidelines, tests also use safety wrappers. Replace both strcpy calls. + +Apply: + +```diff +- edges[0].rel_type = GM_REL_IMPLEMENTS; edges[0].confidence = 0x3C00; strcpy(edges[0].src_path, "A"); strcpy(edges[0].tgt_path, "B"); ++ edges[0].rel_type = GM_REL_IMPLEMENTS; ++ edges[0].confidence = 0x3C00; ++ (void)gm_strcpy_safe(edges[0].src_path, GM_PATH_MAX, "A"); ++ (void)gm_strcpy_safe(edges[0].tgt_path, GM_PATH_MAX, "B"); +@@ +- edges[1].rel_type = GM_REL_IMPLEMENTS; edges[1].confidence = 0x3C00; strcpy(edges[1].src_path, "A"); strcpy(edges[1].tgt_path, "C"); ++ edges[1].rel_type = GM_REL_IMPLEMENTS; ++ edges[1].confidence = 0x3C00; ++ (void)gm_strcpy_safe(edges[1].src_path, GM_PATH_MAX, "A"); ++ (void)gm_strcpy_safe(edges[1].tgt_path, GM_PATH_MAX, "C"); +``` + +Include header if not already: +```c +#include "gitmind/security/string.h" +``` +As per coding guidelines. + +
+🤖 Prompt for AI Agents + +``` +In core/tests/unit/test_cache_query.c around lines 93 to 99, the test uses raw +strcpy which violates project safety guidelines; replace both +strcpy(edges[0].src_path, "A") / strcpy(edges[0].tgt_path, "B") and the pair for +edges[1] with gm_strcpy_safe(dest, sizeof dest, "literal") calls, and ensure the +file includes the safety header by adding #include "gitmind/security/string.h" +at the top if it isn't already present. +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021247 + +{response} + +### docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md:10 — coderabbitai[bot] + +```text +_🛠️ Refactor suggestion_ | _🟠 Major_ + +**Align title/H1, add ToC, and insert SPDX header** + +To meet docs guidelines: make H1 match the title, add a "## Table of Contents", and place SPDX after front matter. + +As per coding guidelines + +```diff + --- +-title: 7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md ++title: Code Review Feedback + description: Preserved review artifacts and rationale. + audience: [contributors] + domain: [quality] + tags: [review] + status: archive + --- + +-# Code Review Feedback ++ ++ ++# Code Review Feedback ++ ++## Table of Contents ++- Overview ++- Commits Reviewed ++- Notes ++- Finishing Touches +``` + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion +--- +title: Code Review Feedback +description: Preserved review artifacts and rationale. +audience: [contributors] +domain: [quality] +tags: [review] +status: archive +--- + + + +# Code Review Feedback + +## Table of Contents +- Overview +- Commits Reviewed +- Notes +- Finishing Touches +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md around +lines 1 to 10, the document needs to follow docs guidelines: make the H1 match +the title, add a "## Table of Contents" section, and insert an SPDX header +immediately after the YAML front matter; update the top-level heading to exactly +match the title line, add a "## Table of Contents" line beneath the H1, and add +a standard SPDX license identifier line (e.g., "SPDX-License-Identifier: MIT") +directly after the closing front-matter delimiter. +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021252 + +{response} + +### docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md:419 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🟡 Minor_ + +**Drop leftover `{response}` placeholder** + +The placeholder renders verbatim and is confusing in a static artifact. Remove it. + + +```diff +- {response} +- +``` + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#issuecomment-3345476880 + +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md around +lines 122 to 125, there is a leftover literal "{response}" placeholder that +renders verbatim and is confusing; remove the "{response}" token and any +surrounding placeholder markers so the file contains only the intended static +text (or replace it with the correct static content if one was intended), then +save and run a quick preview to confirm no stray placeholders remain. +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021260 + +{response} + +### General comment — coderabbitai[bot] + +```text + + + +## Walkthrough +Adds a new gm_oid utility API (equal/is_zero/from_raw/from_hex) and migrates core modules and tests to it, replacing libgit2 OID helpers. Updates cache/journal flows to use new helpers and safer init. Cleans up review artifacts, updates docs, and logs activity. + +## Changes +| Cohort / File(s) | Summary | +| --- | --- | +| — OID utilities API
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | Add gm_oid_equal, gm_oid_is_zero, gm_oid_from_raw, gm_oid_from_hex; retain gm_oid_to_hex; implement hex parsing and defensive checks. | +| — Cache & journal integration
`core/src/cache/query.c`, `core/src/journal/writer.c` | Swap legacy hex/OID helpers for gm_oid_*; zero-init cache meta; use gm_oid_is_zero, gm_oid_from_hex/raw; adjust commit OID param type. | +| — Edge/Hook/Domain integration
`core/src/edge/edge.c`, `core/src/edge/attributed.c`, `core/src/hooks/augment.c`, `core/src/domain/cache/edge_map.c` | Replace git_oid_* usage with gm_oid_* across comparisons, encode/decode, and backfill; include new header. | +| — Tests migration
`core/tests/unit/test_cache_branch_limits.c`, `.../test_cache_edge_map.c`, `.../test_cache_query.c`, `.../test_cache_shard_distribution.c`, `.../test_edge_attributed_cbor.c`, `.../test_edge_cbor_oid.c`, `.../test_edge_equal_semantics.c`, `.../test_edge_oid_fallback.c`, `.../test_journal_mixed_cbor.c`, `.../test_journal_safety.c` | Replace git_oid_fromraw/compare with gm_oid_from_raw/equal/is_zero; add GM_OK asserts; include new headers. | +| — Docs updates
`AGENTS.md`, `docs/activity/2025-09.md` | Update project notes and add 2025‑09‑29 activity entry; timestamp refresh. | +| — Docs cleanup/additions (review artifacts)
`docs/code-reviews/PR172/*.md`, `docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md` | Delete PR172 review artifacts; add PR173 review artifact document. | + +## Sequence Diagram(s) +```mermaid +sequenceDiagram + autonumber + actor Caller as CacheUser + participant CQ as cache/query.c + participant OID as gm_oid utils + participant Meta as CacheMeta + + Caller->>CQ: gm_cache_is_stale(repo, branch) + CQ->>Meta: read meta (tip oids) + alt binary tip present + CQ->>OID: gm_oid_is_zero(meta.journal_tip_oid_bin) + alt not zero + CQ->>OID: gm_oid_equal(meta.journal_tip_oid_bin, current_tip.oid) + OID-->>CQ: equal?/not + else zero + CQ->>OID: gm_oid_from_hex(&cached_tip, meta.journal_tip_oid) + OID-->>CQ: GM_OK/ERR + end + else no binary tip + CQ->>OID: gm_oid_from_hex(&cached_tip, meta.journal_tip_oid) + OID-->>CQ: GM_OK/ERR + end + CQ-->>Caller: stale?/fresh status +``` + +```mermaid +sequenceDiagram + autonumber + actor Producer as EdgeEncoder + participant EDGE as edge/edge.c + participant OID as gm_oid utils + + Producer->>EDGE: encode/decode edge + EDGE->>OID: gm_oid_is_zero(src_oid/tgt_oid) + alt OIDs present + EDGE->>OID: gm_oid_equal(...) for comparisons + else fallback + EDGE->>OID: gm_oid_from_raw(&oid, sha_raw, GM_OID_RAWSZ) + OID-->>EDGE: GM_OK/ERR + end + EDGE-->>Producer: result (edge state) +``` + +## Estimated code review effort +🎯 3 (Moderate) | ⏱️ ~25 minutes + +## Possibly related PRs +- neuroglyph/git-mind#172 — Prior OID utilities introduction and integration; overlaps with same OID paths and replacements. +- neuroglyph/git-mind#169 — Earlier OID-first migration touching refs/cache/journal; closely related code areas. +- neuroglyph/git-mind#171 — Repository interaction migration that intersects with files now updated to gm_oid_*. + +## Poem +> A nibble of hex, a hop through bytes, +> I twitch my ears at zeroed nights. +> From raw to oid, I softly tread— +> Equal or not? “GM_OK,” I said. +> Caches tidy, journals sing— +> Thump-thump! New seams in everything. 🐇✨ + + + + + + +## Pre-merge checks and finishing touches +
+❌ Failed checks (2 warnings) + +| Check name | Status | Explanation | Resolution | +| :----------------: | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Description Check | ⚠️ Warning | The pull request description provides a summary of the changes and testing instructions but omits the required Change Areas and Risk sections defined in the repository’s description template, and it does not include the prescribed Code Review Guidance section. | Please update the description to include the Change Areas checklist and the Risk section with appropriate checkboxes from the repository template and add the Code Review Guidance section to fully comply with the required structure. | +| Docstring Coverage | ⚠️ Warning | Docstring coverage is 35.14% which is insufficient. The required threshold is 80.00%. | You can run `@coderabbitai generate docstrings` to improve docstring coverage. | + +
+
+✅ Passed checks (1 passed) + +| Check name | Status | Explanation | +| :---------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Title Check | ✅ Passed | The pull request title follows a conventional commit format by indicating a new feature in the core OID module and succinctly describes migrating edge and cache code to gm helpers, which directly reflects a significant part of the changeset. | + +
+ + + + + +
+✨ Finishing touches + +- [ ] 📝 Generate Docstrings +
+🧪 Generate unit tests + +- [ ] Create PR with unit tests +- [ ] Post copyable unit tests in a comment +- [ ] Commit unit tests in branch `feat/edge-port-followup` + +
+ +
+ + + + + +--- + +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 + +- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) +- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) +- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) +- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) + +
+ +Comment `@coderabbitai help` to get the list of available commands and usage tips. + + + + + + + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#issuecomment-3345476880 + +{response} + From e0243058aac14ff3a8c83af2f6d4dcfe97dd2804 Mon Sep 17 00:00:00 2001 From: "J. Kirby Ross" Date: Mon, 29 Sep 2025 05:11:51 -0700 Subject: [PATCH 7/8] fix(tests): apply coderabbit cache_query suggestions --- core/include/gitmind/util/oid.h | 4 ++-- core/src/util/oid.c | 2 +- core/tests/unit/test_cache_query.c | 20 +++++++++++++++----- include/gitmind.h | 1 + 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/core/include/gitmind/util/oid.h b/core/include/gitmind/util/oid.h index b57a4522..202b7f03 100644 --- a/core/include/gitmind/util/oid.h +++ b/core/include/gitmind/util/oid.h @@ -49,8 +49,8 @@ GM_NODISCARD bool gm_oid_equal(const gm_oid_t *lhs, const gm_oid_t *rhs); /** * Determine whether an OID is the all-zero sentinel. * - * @param oid OID to inspect (may be NULL) - * @return true when every byte is zero or the pointer is NULL + * @param oid OID to inspect; NULL is treated as invalid / not zero + * @return true when every byte is zero; false otherwise (including NULL) */ GM_NODISCARD bool gm_oid_is_zero(const gm_oid_t *oid); diff --git a/core/src/util/oid.c b/core/src/util/oid.c index 3a771c31..db3b950e 100644 --- a/core/src/util/oid.c +++ b/core/src/util/oid.c @@ -81,7 +81,7 @@ GM_NODISCARD bool gm_oid_equal(const gm_oid_t *lhs, const gm_oid_t *rhs) { GM_NODISCARD bool gm_oid_is_zero(const gm_oid_t *oid) { if (oid == NULL) { - return true; + return false; } for (size_t index = 0; index < GM_OID_RAWSZ; ++index) { if (oid->id[index] != 0U) { diff --git a/core/tests/unit/test_cache_query.c b/core/tests/unit/test_cache_query.c index 0dd48db5..6e0256d4 100644 --- a/core/tests/unit/test_cache_query.c +++ b/core/tests/unit/test_cache_query.c @@ -16,6 +16,7 @@ #include "gitmind/types.h" #include "gitmind/util/oid.h" #include "gitmind/security/string.h" +#include "gitmind/util/memory.h" #include "gitmind/adapters/fs/posix_temp_adapter.h" #include "gitmind/adapters/git/libgit2_repository_port.h" @@ -87,17 +88,26 @@ int main(void) { assert(fs_result.ok); /* Create two edges A->B and A->C */ - gm_edge_t edges[2]; memset(edges, 0, sizeof edges); + gm_edge_t edges[2]; + memset(edges, 0, sizeof edges); uint8_t A[GM_OID_RAWSZ], B[GM_OID_RAWSZ], C[GM_OID_RAWSZ]; memset(A, 0x11, sizeof A); memset(B, 0x22, sizeof B); memset(C, 0x33, sizeof C); assert(gm_oid_from_raw(&edges[0].src_oid, A, sizeof A) == GM_OK); assert(gm_oid_from_raw(&edges[0].tgt_oid, B, sizeof B) == GM_OK); - edges[0].rel_type = GM_REL_IMPLEMENTS; edges[0].confidence = 0x3C00; strcpy(edges[0].src_path, "A"); strcpy(edges[0].tgt_path, "B"); - (void)gm_ulid_generate(edges[0].ulid); + edges[0].rel_type = GM_REL_IMPLEMENTS; + edges[0].confidence = 0x3C00; + assert(gm_strcpy_safe(edges[0].src_path, sizeof edges[0].src_path, "A") == GM_OK); + assert(gm_strcpy_safe(edges[0].tgt_path, sizeof edges[0].tgt_path, "B") == GM_OK); + gm_result_ulid_t ulr0 = gm_ulid_generate(edges[0].ulid); + assert(ulr0.ok); assert(gm_oid_from_raw(&edges[1].src_oid, A, sizeof A) == GM_OK); assert(gm_oid_from_raw(&edges[1].tgt_oid, C, sizeof C) == GM_OK); - edges[1].rel_type = GM_REL_IMPLEMENTS; edges[1].confidence = 0x3C00; strcpy(edges[1].src_path, "A"); strcpy(edges[1].tgt_path, "C"); - (void)gm_ulid_generate(edges[1].ulid); + edges[1].rel_type = GM_REL_IMPLEMENTS; + edges[1].confidence = 0x3C00; + assert(gm_strcpy_safe(edges[1].src_path, sizeof edges[1].src_path, "A") == GM_OK); + assert(gm_strcpy_safe(edges[1].tgt_path, sizeof edges[1].tgt_path, "C") == GM_OK); + gm_result_ulid_t ulr1 = gm_ulid_generate(edges[1].ulid); + assert(ulr1.ok); rc = gm_journal_append(&ctx, edges, 2); assert(rc == GM_OK); diff --git a/include/gitmind.h b/include/gitmind.h index 2b977eb6..2901c85f 100644 --- a/include/gitmind.h +++ b/include/gitmind.h @@ -28,6 +28,7 @@ extern "C" { #include "gitmind/edge_attributed.h" #include "gitmind/journal.h" #include "gitmind/cache.h" +#include "gitmind/util/oid.h" /* * Feature toggles From 28cf980690cc9f5d58c5dfdfb90f1fb033d97638 Mon Sep 17 00:00:00 2001 From: "P.R. PhiedBach" Date: Mon, 29 Sep 2025 12:12:55 +0000 Subject: [PATCH 8/8] opus(PR#173): seed rehearsal score (e0243058aac14ff3a8c83af2f6d4dcfe97dd2804) --- ...0243058aac14ff3a8c83af2f6d4dcfe97dd2804.md | 710 ++++++++++++++++++ 1 file changed, 710 insertions(+) create mode 100644 docs/code-reviews/PR173/e0243058aac14ff3a8c83af2f6d4dcfe97dd2804.md diff --git a/docs/code-reviews/PR173/e0243058aac14ff3a8c83af2f6d4dcfe97dd2804.md b/docs/code-reviews/PR173/e0243058aac14ff3a8c83af2f6d4dcfe97dd2804.md new file mode 100644 index 00000000..cdddd729 --- /dev/null +++ b/docs/code-reviews/PR173/e0243058aac14ff3a8c83af2f6d4dcfe97dd2804.md @@ -0,0 +1,710 @@ +--- +title: e0243058aac14ff3a8c83af2f6d4dcfe97dd2804.md +description: Preserved review artifacts and rationale. +audience: [contributors] +domain: [quality] +tags: [review] +status: archive +--- + +# Code Review Feedback + +| Date | Agent | SHA | Branch | PR | +|------|-------|-----|--------|----| +| 2025-09-29 | CodeRabbit (and reviewers) | `e0243058aac14ff3a8c83af2f6d4dcfe97dd2804` | [feat/edge-port-followup](https://github.com/neuroglyph/git-mind/tree/feat/edge-port-followup "neuroglyph/git-mind:feat/edge-port-followup") | [PR#173](https://github.com/neuroglyph/git-mind/pull/173) | + +## CODE REVIEW FEEDBACK + +### core/include/gitmind/util/oid.h:7 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🔴 Critical_ + +
+🧩 Analysis chain + +**Verify umbrella exposure in include/gitmind.h.** + +Public headers must be umbrella‑safe and reachable via the umbrella. Please confirm this header is re‑exported. + +--- + +🏁 Script executed: + +```shell +#!/bin/bash +# Expect: include/gitmind.h exists and references util/oid.h +fd -a gitmind.h include | xargs -I{} rg -n 'gitmind/util/oid\.h' {} +# Also check for duplicates/different paths: +rg -nP --glob 'include/**' '\butil/oid\.h\b' +``` + +Length of output: 0 + +--- + +🏁 Script executed: + +```shell +#!/usr/bin/env bash +# Locate all gitmind.h files and check for util/oid.h references +find . -type f -name gitmind.h | while read file; do + echo "---- $file ----" + grep -Hn "util/oid\.h" "$file" || echo "no reference" +done +``` + +Length of output: 42 + +--- + + + +
+ +**Include util/oid.h in the umbrella header** +Add the following to `include/gitmind.h` so that `core/include/gitmind/util/oid.h` is re-exported by the umbrella API: +```diff +--- a/include/gitmind.h ++++ b/include/gitmind.h +@@ /* somewhere among other includes */ ++#include +``` + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion +++ b/include/gitmind.h +@@ /* somewhere among other umbrella-header includes */ + #include +#include + #include +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In core/include/gitmind/util/oid.h at line 7, the util/oid header is not being +re-exported by the umbrella API; open include/gitmind.h and add an #include +"gitmind/util/oid.h" (placed with the other util/includes or alphabetical group) +so that core/include/gitmind/util/oid.h is exposed via the umbrella header; +update any include guards or ordering if necessary to preserve compile order. +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021216 + +{response} + +### core/src/edge/attributed.c:285 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🔴 Critical_ + +**Fix OID backfill length mismatch (potential OOB read)** + +You pass GM_OID_RAWSZ while sourcing from out.src_sha/out.tgt_sha (GM_SHA1_SIZE). That can read past the SHA buffer or fail. Zero‑pad into a GM_OID_RAWSZ scratch first. + +```diff +- if (gm_oid_is_zero(&out.src_oid)) { +- (void)gm_oid_from_raw(&out.src_oid, out.src_sha, GM_OID_RAWSZ); +- } +- if (gm_oid_is_zero(&out.tgt_oid)) { +- (void)gm_oid_from_raw(&out.tgt_oid, out.tgt_sha, GM_OID_RAWSZ); +- } ++ if (gm_oid_is_zero(&out.src_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, out.src_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&out.src_oid, tmp, GM_OID_RAWSZ); ++ } ++ if (gm_oid_is_zero(&out.tgt_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, out.tgt_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&out.tgt_oid, tmp, GM_OID_RAWSZ); ++ } +``` +As per coding guidelines (zero outputs on error paths; use gm_memcpy_span). Based on learnings. + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion + if (gm_oid_is_zero(&out.src_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, out.src_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&out.src_oid, tmp, GM_OID_RAWSZ); + } + if (gm_oid_is_zero(&out.tgt_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, out.tgt_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&out.tgt_oid, tmp, GM_OID_RAWSZ); + } +``` + +
+ + + + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021226 + +{response} + +### core/src/edge/edge.c:497 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🔴 Critical_ + +**Fix OID backfill length mismatch (potential OOB read)** + +As in attributed.c, passing GM_OID_RAWSZ while sourcing from GM_SHA1_SIZE buffers risks OOB. Zero‑pad into a GM_OID_RAWSZ scratch first. + +```diff +- if (gm_oid_is_zero(&edge.src_oid)) { +- (void)gm_oid_from_raw(&edge.src_oid, edge.src_sha, GM_OID_RAWSZ); +- } +- if (gm_oid_is_zero(&edge.tgt_oid)) { +- (void)gm_oid_from_raw(&edge.tgt_oid, edge.tgt_sha, GM_OID_RAWSZ); +- } ++ if (gm_oid_is_zero(&edge.src_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, edge.src_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&edge.src_oid, tmp, GM_OID_RAWSZ); ++ } ++ if (gm_oid_is_zero(&edge.tgt_oid)) { ++ uint8_t tmp[GM_OID_RAWSZ]; ++ gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); ++ gm_memcpy_span(tmp, sizeof tmp, edge.tgt_sha, GM_SHA1_SIZE); ++ (void)gm_oid_from_raw(&edge.tgt_oid, tmp, GM_OID_RAWSZ); ++ } +``` +As per coding guidelines (safe memory ops; zero on error). + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion + if (gm_oid_is_zero(&edge.src_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, edge.src_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&edge.src_oid, tmp, GM_OID_RAWSZ); + } + if (gm_oid_is_zero(&edge.tgt_oid)) { + uint8_t tmp[GM_OID_RAWSZ]; + gm_memset_safe(tmp, sizeof tmp, 0, sizeof tmp); + gm_memcpy_span(tmp, sizeof tmp, edge.tgt_sha, GM_SHA1_SIZE); + (void)gm_oid_from_raw(&edge.tgt_oid, tmp, GM_OID_RAWSZ); + } +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In core/src/edge/edge.c around lines 492 to 497, the code calls gm_oid_from_raw +using edge.src_sha/edge.tgt_sha buffers sized GM_SHA1_SIZE but passes +GM_OID_RAWSZ which can read past the source buffer; to fix, allocate a +GM_OID_RAWSZ-byte scratch array, zero it, copy GM_SHA1_SIZE bytes from the SHA +buffer into the scratch, then call gm_oid_from_raw with the scratch and +GM_OID_RAWSZ; ensure the scratch is zeroed before use and that any failure from +gm_oid_from_raw leaves the oid zeroed (follow existing safe-memory/error-zeroing +patterns). +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021236 + +{response} + +### core/src/util/oid.c:17 — coderabbitai[bot] + +```text +_🛠️ Refactor suggestion_ | _🟠 Major_ + +
+🧩 Analysis chain + +**Repo-wide check: ensure no straggler `git_oid_cmp`/raw memcmp remain** + +Run a quick scan to confirm all equality moves funnel through gm_oid_equal. + +--- + +🏁 Script executed: + +```shell +#!/bin/bash +# Find legacy equality patterns that should be gm_oid_equal +rg -nP --type=c --type=h -C2 '\bgit_oid_cmp\s*\(|\bmemcmp\s*\(\s*[^,]*->id\s*,\s*[^,]*->id\s*,\s*GM_OID_RAWSZ\s*\)' +``` + +Length of output: 201 + +--- + + + +
+ +**Replace raw memcmp in OID comparison with gm_oid_equal** + +* In `core/src/util/oid.c:79`, replace + `return memcmp(lhs->id, rhs->id, GM_OID_RAWSZ) == 0;` + with + `return gm_oid_equal(lhs, rhs);` + +
+🤖 Prompt for AI Agents + +``` +In core/src/util/oid.c around lines 4 to 17 and specifically at line ~79, +replace the raw memcmp comparison `memcmp(lhs->id, rhs->id, GM_OID_RAWSZ) == 0` +with the helper `gm_oid_equal(lhs, rhs)`; update the return to `return +gm_oid_equal(lhs, rhs);` so the OID equality uses the centralized function (no +other changes needed if oid.h is already included). +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021242 + +{response} + +### core/tests/unit/test_cache_query.c:99 — coderabbitai[bot] + +```text +_🛠️ Refactor suggestion_ | _🟠 Major_ + +**Use gm_strcpy_safe in tests (no raw strcpy)** + +Per project guidelines, tests also use safety wrappers. Replace both strcpy calls. + +Apply: + +```diff +- edges[0].rel_type = GM_REL_IMPLEMENTS; edges[0].confidence = 0x3C00; strcpy(edges[0].src_path, "A"); strcpy(edges[0].tgt_path, "B"); ++ edges[0].rel_type = GM_REL_IMPLEMENTS; ++ edges[0].confidence = 0x3C00; ++ (void)gm_strcpy_safe(edges[0].src_path, GM_PATH_MAX, "A"); ++ (void)gm_strcpy_safe(edges[0].tgt_path, GM_PATH_MAX, "B"); +@@ +- edges[1].rel_type = GM_REL_IMPLEMENTS; edges[1].confidence = 0x3C00; strcpy(edges[1].src_path, "A"); strcpy(edges[1].tgt_path, "C"); ++ edges[1].rel_type = GM_REL_IMPLEMENTS; ++ edges[1].confidence = 0x3C00; ++ (void)gm_strcpy_safe(edges[1].src_path, GM_PATH_MAX, "A"); ++ (void)gm_strcpy_safe(edges[1].tgt_path, GM_PATH_MAX, "C"); +``` + +Include header if not already: +```c +#include "gitmind/security/string.h" +``` +As per coding guidelines. + +
+🤖 Prompt for AI Agents + +``` +In core/tests/unit/test_cache_query.c around lines 93 to 99, the test uses raw +strcpy which violates project safety guidelines; replace both +strcpy(edges[0].src_path, "A") / strcpy(edges[0].tgt_path, "B") and the pair for +edges[1] with gm_strcpy_safe(dest, sizeof dest, "literal") calls, and ensure the +file includes the safety header by adding #include "gitmind/security/string.h" +at the top if it isn't already present. +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021247 + +{response} + +### docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md:10 — coderabbitai[bot] + +```text +_🛠️ Refactor suggestion_ | _🟠 Major_ + +**Align title/H1, add ToC, and insert SPDX header** + +To meet docs guidelines: make H1 match the title, add a "## Table of Contents", and place SPDX after front matter. + +As per coding guidelines + +```diff + --- +-title: 7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md ++title: Code Review Feedback + description: Preserved review artifacts and rationale. + audience: [contributors] + domain: [quality] + tags: [review] + status: archive + --- + +-# Code Review Feedback ++ ++ ++# Code Review Feedback ++ ++## Table of Contents ++- Overview ++- Commits Reviewed ++- Notes ++- Finishing Touches +``` + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion +--- +title: Code Review Feedback +description: Preserved review artifacts and rationale. +audience: [contributors] +domain: [quality] +tags: [review] +status: archive +--- + + + +# Code Review Feedback + +## Table of Contents +- Overview +- Commits Reviewed +- Notes +- Finishing Touches +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md around +lines 1 to 10, the document needs to follow docs guidelines: make the H1 match +the title, add a "## Table of Contents" section, and insert an SPDX header +immediately after the YAML front matter; update the top-level heading to exactly +match the title line, add a "## Table of Contents" line beneath the H1, and add +a standard SPDX license identifier line (e.g., "SPDX-License-Identifier: MIT") +directly after the closing front-matter delimiter. +``` + +
+ + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021252 + +{response} + +### docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md:419 — coderabbitai[bot] + +```text +_⚠️ Potential issue_ | _🟡 Minor_ + +**Drop leftover `{response}` placeholder** + +The placeholder renders verbatim and is confusing in a static artifact. Remove it. + + +```diff +- {response} +- +``` + + + +
+📝 Committable suggestion + +> ‼️ **IMPORTANT** +> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. + +```suggestion +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#issuecomment-3345476880 + +``` + +
+ + + +
+🤖 Prompt for AI Agents + +``` +In docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md around +lines 122 to 125, there is a leftover literal "{response}" placeholder that +renders verbatim and is confusing; remove the "{response}" token and any +surrounding placeholder markers so the file contains only the intended static +text (or replace it with the correct static content if one was intended), then +save and run a quick preview to confirm no stray placeholders remain. +``` + +
+ + + + + +✅ Addressed in commit 17ddad1 +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#discussion_r2387021260 + +{response} + +### General comment — coderabbitai[bot] + +```text + + + +> [!NOTE] +> Currently processing new changes in this PR. This may take a few minutes, please wait... +> +>
+> 📥 Commits +> +> Reviewing files that changed from the base of the PR and between eaf10c68312837f2c879203292c0e58b568b83a8 and e0243058aac14ff3a8c83af2f6d4dcfe97dd2804. +> +>
+> +>
+> 📒 Files selected for processing (4) +> +> * `core/include/gitmind/util/oid.h` (2 hunks) +> * `core/src/util/oid.c` (2 hunks) +> * `core/tests/unit/test_cache_query.c` (4 hunks) +> * `include/gitmind.h` (1 hunks) +> +>
+> +> ```ascii +> ____________________________________________ +> < Like a moth to a flame, I'm drawn to bugs. > +> -------------------------------------------- +> \ +> \ (\__/) +> (•ㅅ•) +> /   づ +> ``` + + + + +> [!TIP] +>
+> You can disable the changed files summary in the walkthrough. +> +> Disable the `reviews.changed_files_summary` setting in your project's settings in CodeRabbit to disable the changed files summary in the walkthrough. +> +>
+ + + + +## Walkthrough +Adds a new gm_oid utility API (gm_oid_equal, gm_oid_is_zero, gm_oid_from_raw, gm_oid_from_hex) and migrates core modules and unit tests to use it instead of libgit2 git_oid helpers; updates cache/journal flows for safer init and hex handling; removes many PR172 review artifacts and adds PR173 artifact; updates activity docs. + +## Changes +| Cohort / File(s) | Summary | +| --- | --- | +| **OID utilities API**
`core/include/gitmind/util/oid.h`, `core/src/util/oid.c` | Add gm_oid_equal, gm_oid_is_zero, gm_oid_from_raw, gm_oid_from_hex; implement hex parsing, validation, and defensive checks; retain gm_oid_to_hex. | +| **Cache & query**
`core/src/cache/query.c` | Replace local hex/oid helpers with gm_oid_* APIs; use gm_memset_safe for meta init; use gm_oid_is_zero/gm_oid_from_hex/gm_oid_equal in stale checks. | +| **Journal writer**
`core/src/journal/writer.c` | Use gm_oid_from_hex/gm_oid_to_hex and narrow internal commit_oid param to gm_oid_t; preserve existing commit/parent flow with new OID helpers. | +| **Edge & attributed handling**
`core/src/edge/edge.c`, `core/src/edge/attributed.c` | Replace git_oid_* usage with gm_oid_* for encode/decode, backfill, and comparisons; add error checks on OID parsing. | +| **Domain / edge map**
`core/src/domain/cache/edge_map.c` | Validate bucket_count != 0; replace git_oid_cmp with gm_oid_equal; remove git2/oid.h include and add gitmind/util/oid.h. | +| **Hooks / augment**
`core/src/hooks/augment.c` | Use gm_oid_equal for comparisons; adopt GM_CALLBACK_STOP and GM_OK sentinel checks; add oid util include. | +| **Adapters**
`core/src/adapters/git/libgit2_repository_port.c` | Switch git_oid_equal → gm_oid_equal; include gitmind/util/oid.h. | +| **Unit tests (many files)**
`core/tests/unit/*` (e.g., `test_cache_query.c`, `test_cache_edge_map.c`, `test_edge_cbor_oid.c`, `test_journal_*`, `test_cache_*`, ...) | Replace git_oid_fromraw/compare with gm_oid_from_raw/gm_oid_equal/gm_oid_is_zero; add GM_OK asserts; use safe string helpers and updated headers. | +| **Docs — activity & agents**
`docs/activity/2025-09.md`, `AGENTS.md` | Add 2025‑09‑29 activity entry documenting gm_oid utilities and migrations; update AGENTS.md narrative/housekeeping notes. | +| **Docs — code review artifacts**
`docs/code-reviews/PR172/*`, `docs/code-reviews/PR173/7445bcf00c71b6f768e9eb6b1fd99d2b1c60783f.md` | Remove multiple archived PR172 review artifact files; add PR173 code-review artifact document. | + +## Sequence Diagram(s) +```mermaid +sequenceDiagram + autonumber + actor Caller as CacheUser + participant CQ as cache/query.c + participant OID as gm_oid utils + participant Meta as CacheMeta + + Caller->>CQ: gm_cache_is_stale(repo, branch) + CQ->>Meta: read meta (tip oids) + alt binary tip present + CQ->>OID: gm_oid_is_zero(meta.journal_tip_oid_bin) + alt not zero + CQ->>OID: gm_oid_equal(meta.journal_tip_oid_bin, current_tip.oid) + OID-->>CQ: equal?/not + else zero + CQ->>OID: gm_oid_from_hex(&cached_tip, meta.journal_tip_oid) + OID-->>CQ: GM_OK/ERR + end + else no binary tip + CQ->>OID: gm_oid_from_hex(&cached_tip, meta.journal_tip_oid) + OID-->>CQ: GM_OK/ERR + end + CQ-->>Caller: stale?/fresh status +``` + +```mermaid +sequenceDiagram + autonumber + actor Producer as EdgeEncoder + participant EDGE as edge/edge.c + participant OID as gm_oid utils + + Producer->>EDGE: encode/decode edge + EDGE->>OID: gm_oid_is_zero(src_oid/tgt_oid) + alt OIDs present + EDGE->>OID: gm_oid_equal(...) for comparisons + else fallback + EDGE->>OID: gm_oid_from_raw(&oid, sha_raw, GM_OID_RAWSZ) + OID-->>EDGE: GM_OK/ERR + end + EDGE-->>Producer: result (edge state) +``` + +## Estimated code review effort +🎯 3 (Moderate) | ⏱️ ~30 minutes + +## Possibly related PRs +- neuroglyph/git-mind#165 — Very similar OID-first migration touching gm_oid_* helpers and edge/cache/journal paths. +- neuroglyph/git-mind#171 — Overlapping changes converting callers from git_oid_* to gm_oid_* across core modules and tests. +- neuroglyph/git-mind#172 — Prior PR that introduced related OID utilities and review artifacts; closely intersects doc cleanup and OID surface. + +## Poem +> I hop through hex and tidy bytes, +> I nibble zeros in moonlit nights. +> From raw to oid I dance and test— +> “GM_OK” I whisper, then to rest. +> Thump-thump, the cache and journals beam. 🐇✨ + + + + + +## Pre-merge checks and finishing touches +
+❌ Failed checks (2 warnings) + +| Check name | Status | Explanation | Resolution | +| :----------------: | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Description Check | ⚠️ Warning | The provided description includes a summary and testing instructions but omits the required “Change Areas,” “Risk,” and “Code Review Guidance” sections specified by the repository’s description template, making it incomplete relative to the expected structure. | Please expand the description to include the “Change Areas” checklist with appropriate scopes selected, a “Risk” section indicating whether this introduces behavior or public API changes, and the “Code Review Guidance” section per the template’s requirements. | +| Docstring Coverage | ⚠️ Warning | Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. | You can run `@coderabbitai generate docstrings` to improve docstring coverage. | + +
+
+✅ Passed checks (1 passed) + +| Check name | Status | Explanation | +| :---------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Title Check | ✅ Passed | The title “feat(core/oid): migrate edge/cache to gm helpers” succinctly captures a key aspect of the changeset by highlighting the migration of edge and cache components in the core/oid module to the new gm helper APIs, making it a clear and specific summary of a significant part of this pull request. | + +
+ + + + + +--- + +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 + +- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) +- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) +- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) +- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) + +
+ +Comment `@coderabbitai help` to get the list of available commands and usage tips. + + + + + + + + + +``` + +_Meta_: https://github.com/neuroglyph/git-mind/pull/173#issuecomment-3345476880 + +{response} +