Repository navigation
chore(core/migration): remove legacy src/ duplicates; convert include/gitmind.h to pure umbrella; flatten CLI path to apps/cli/ #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bfaec2e
2c614d3
2bc9c75
187afcf
140412a
5fccc48
58be14d
bd178ec
7331481
7fef97d
f18ebf3
f4ee7ff
ef52094
38a489f
1b71390
4fe31a5
a03f926
098bfd0
48a7d4a
2ab2f39
6a94e02
1c69b5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,9 +9,9 @@ | |||||||||
| #include <stdint.h> | ||||||||||
|
|
||||||||||
| #include <git2/types.h> | ||||||||||
| #include <git2/oid.h> | ||||||||||
|
|
||||||||||
|
Comment on lines
11
to
13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not expose libgit2 from public headers; include project types. gm_oid_t comes from gitmind/types.h; avoid leaking <git2/oid.h> in public API. Apply this diff: -#include <git2/types.h>
-#include <git2/oid.h>
+#include <git2/types.h>
+#include "gitmind/types.h"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| #include "gitmind/context.h" | ||||||||||
| #include "gitmind/result.h" | ||||||||||
|
|
||||||||||
| #ifdef __cplusplus | ||||||||||
| extern "C" { | ||||||||||
|
|
@@ -30,7 +30,7 @@ extern "C" { | |||||||||
| #define GM_CACHE_SHARD_BITS 8 /* 2 hex chars = 256 shards */ | ||||||||||
| #define GM_CACHE_REF_PREFIX "refs/gitmind/cache/" | ||||||||||
| #define GM_CACHE_BRANCH_NAME_SIZE 64 /* Maximum branch name length */ | ||||||||||
| #define GM_CACHE_OID_STRING_SIZE 41 /* Git OID as string + null terminator */ | ||||||||||
| #define GM_CACHE_OID_STRING_SIZE (GIT_OID_HEXSZ + 1) /* OID hex + NUL */ | ||||||||||
|
|
||||||||||
| /* Cache result containing edge IDs matching a query */ | ||||||||||
| typedef struct { | ||||||||||
|
|
@@ -65,24 +65,24 @@ int gm_cache_init(void); | |||||||||
| int gm_cache_rebuild(gm_context_t *ctx, const char *branch, bool force_full); | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Query edges by source SHA (forward traversal) | ||||||||||
| * Query edges by source OID (forward traversal) | ||||||||||
| * @param ctx Git-mind context containing repository | ||||||||||
| * @param src_sha Source SHA bytes (20 bytes) | ||||||||||
| * @param src_oid Source object ID | ||||||||||
| * @param result Output result structure | ||||||||||
| * @return GM_OK on success, error code on failure | ||||||||||
| */ | ||||||||||
| int gm_cache_query_fanout(gm_context_t *ctx, const char *branch, const uint8_t *src_sha, | ||||||||||
| int gm_cache_query_fanout(gm_context_t *ctx, const char *branch, const gm_oid_t *src_oid, | ||||||||||
| gm_cache_result_t *result); | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Query edges by target SHA (reverse traversal) | ||||||||||
| * Query edges by target OID (reverse traversal) | ||||||||||
| * @param ctx Git-mind context containing repository | ||||||||||
| * @param branch Branch name to query | ||||||||||
| * @param tgt_sha Target SHA bytes (20 bytes) | ||||||||||
| * @param tgt_oid Target object ID | ||||||||||
| * @param result Output result structure | ||||||||||
| * @return GM_OK on success, error code on failure | ||||||||||
| */ | ||||||||||
| int gm_cache_query_fanin(gm_context_t *ctx, const char *branch, const uint8_t *tgt_sha, | ||||||||||
| int gm_cache_query_fanin(gm_context_t *ctx, const char *branch, const gm_oid_t *tgt_oid, | ||||||||||
| gm_cache_result_t *result); | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||
| /* SPDX-License-Identifier: LicenseRef-MIND-UCAL-1.0 */ | ||||||||||||||
| /* © 2025 J. Kirby Ross / Neuroglyph Collective */ | ||||||||||||||
|
|
||||||||||||||
| #ifndef GITMIND_CBOR_KEYS_H | ||||||||||||||
| #define GITMIND_CBOR_KEYS_H | ||||||||||||||
|
|
||||||||||||||
| /* Common CBOR keys for edge encodings */ | ||||||||||||||
|
|
||||||||||||||
| /* Legacy/basic edge fields */ | ||||||||||||||
| #define GM_CBOR_KEY_SRC_SHA 0 | ||||||||||||||
| #define GM_CBOR_KEY_TGT_SHA 1 | ||||||||||||||
| #define GM_CBOR_KEY_REL_TYPE 2 | ||||||||||||||
| #define GM_CBOR_KEY_CONFIDENCE 3 | ||||||||||||||
| #define GM_CBOR_KEY_TIMESTAMP 4 | ||||||||||||||
| #define GM_CBOR_KEY_SRC_PATH 5 | ||||||||||||||
| #define GM_CBOR_KEY_TGT_PATH 6 | ||||||||||||||
| #define GM_CBOR_KEY_ULID 7 | ||||||||||||||
|
|
||||||||||||||
| /* OID-first additions (raw bytes of length GM_OID_RAWSZ) */ | ||||||||||||||
| #define GM_CBOR_KEY_SRC_OID 8 | ||||||||||||||
| #define GM_CBOR_KEY_TGT_OID 9 | ||||||||||||||
|
|
||||||||||||||
| /* Attributed extras */ | ||||||||||||||
| #define GM_CBOR_KEY_SOURCE_TYPE 10 | ||||||||||||||
| #define GM_CBOR_KEY_AUTHOR 11 | ||||||||||||||
| #define GM_CBOR_KEY_SESSION 12 | ||||||||||||||
| #define GM_CBOR_KEY_FLAGS 13 | ||||||||||||||
| #define GM_CBOR_KEY_LANE 14 | ||||||||||||||
|
|
||||||||||||||
| /* Field counts for writers */ | ||||||||||||||
| #define GM_CBOR_EDGE_FIELDS_TOTAL 10 /* legacy 8 + 2 OID fields */ | ||||||||||||||
| #define GM_CBOR_ATTR_EDGE_FIELDS_TOTAL 15 /* edge total + 5 attribution fields */ | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+30
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Derive field-count macros from highest key to prevent drift. Avoid hand-maintaining totals; make them follow the last key automatically. -#define GM_CBOR_EDGE_FIELDS_TOTAL 10 /* legacy 8 + 2 OID fields */
-#define GM_CBOR_ATTR_EDGE_FIELDS_TOTAL 15 /* edge total + 5 attribution fields */
+#define GM_CBOR_EDGE_FIELDS_TOTAL (GM_CBOR_KEY_TGT_OID + 1)
+#define GM_CBOR_ATTR_EDGE_FIELDS_TOTAL (GM_CBOR_KEY_LANE + 1)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| #endif /* GITMIND_CBOR_KEYS_H */ | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,7 +32,7 @@ | |||||||||
| /* Cache system constants */ | ||||||||||
| #define BITS_PER_HEX_CHAR 4 | ||||||||||
| #define HEX_CHARS_PER_BYTE 2 | ||||||||||
| #define SHA_HEX_SIZE (GM_SHA1_SIZE * HEX_CHARS_PER_BYTE + 1) | ||||||||||
| #define SHA_HEX_SIZE (GM_OID_RAWSZ * HEX_CHARS_PER_BYTE + 1) | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Rename to OID-centric macro; keep backward-compat alias. The size now depends on OID raw size. Rename for clarity and define a compat alias to avoid confusion during migration. -#define SHA_HEX_SIZE (GM_OID_RAWSZ * HEX_CHARS_PER_BYTE + 1)
+#define OID_HEX_SIZE (GM_OID_RAWSZ * HEX_CHARS_PER_BYTE + 1)
+/* Back-compat: remove after all callsites migrate */
+#define SHA_HEX_SIZE OID_HEX_SIZE📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| #define ZERO_SHA_STRING "0000000000000000000000000000000000000000" | ||||||||||
|
Comment on lines
+35
to
36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusiveZERO_SHA_STRING is SHA‑1 length; breaks with SHA‑256 OIDs. Using a fixed 40-‘0’ string is inconsistent with OID‑agnostic sizing and risks truncation/semantics drift. Prefer generating zero OID strings at use sites based on GIT_OID_HEXSZ (see suggested fix in builder.c). Replace hard-coded ZERO_SHA_STRING with OID-size-aware generation ZERO_SHA_STRING is a hard-coded 40-'0' SHA‑1 value and contradicts the OID-agnostic SHA_HEX_SIZE macro; this will break for larger OIDs (e.g., SHA‑256). File: core/include/gitmind/constants.h, lines 35–36. Action: remove the fixed ZERO_SHA_STRING and instead generate zero OID strings from SHA_HEX_SIZE (or compute from GM_OID_RAWSZ * HEX_CHARS_PER_BYTE) at use sites, or provide a small helper that returns a null-terminated zero OID string of the correct length. 🤖 Prompt for AI Agents |
||||||||||
| #define EDGE_MAP_BUCKETS 1024 | ||||||||||
| #define DIR_PERMS_NORMAL 0755 | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,8 +30,10 @@ typedef struct gm_context gm_context_t; | |
| * Edge structure representing a directed relationship between two git objects | ||
| */ | ||
| typedef struct gm_edge { | ||
| uint8_t src_sha[GM_SHA1_SIZE]; /**< Source object SHA-1 */ | ||
| uint8_t tgt_sha[GM_SHA1_SIZE]; /**< Target object SHA-1 */ | ||
| uint8_t src_sha[GM_SHA1_SIZE]; /**< Source object SHA-1 (legacy) */ | ||
| uint8_t tgt_sha[GM_SHA1_SIZE]; /**< Target object SHA-1 (legacy) */ | ||
| gm_oid_t src_oid; /**< Source object OID (preferred) */ | ||
| gm_oid_t tgt_oid; /**< Target object OID (preferred) */ | ||
|
Comment on lines
+33
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainPublic struct growth: confirm ABI policy or gate behind version bump Adding fields to a public struct changes its size/layout and breaks ABI for consumers. If ABI stability is required, either bump the SONAME/major version and document the break or make Run to find potential size-sensitive usage: 🏁 Script executed: #!/bin/bash
rg -nP '\bsizeof\s*\(\s*gm_edge_t\s*\)|gm_edge_encode_cbor|gm_edge_decode_cbor|memcpy\s*\([^,]+,\s*&\s*\w*edge' -C2Length of output: 14211 Public-ABI break: gm_edge_t enlarged — bump SONAME or make opaque Adding fields changes sizeof(gm_edge_t) and will break callers and code that assume a fixed-size POD (memcpy/memset/alloc). Evidence in tree: core/src/edge/edge.c:45 (memset(..., sizeof(gm_edge_t))), docs/architecture/attribution-integration-guide.md:119-121 (memcpy(&edge,&legacy_edge,sizeof(gm_edge_t))), core/src/journal/writer.c:298 (journal_append_generic(..., sizeof(gm_edge_t), ...)), core/src/hooks/augment.c:119 (malloc(... * sizeof(gm_edge_t))), core/src/cache/query.c:206-209,281-283 (memcpy/malloc), and the public header core/include/gitmind/edge.h. Action required: either bump the SONAME/major version and publish a migration note, or make gm_edge_t opaque and add accessors—then update all memcpy/memset/sizeof/alloc sites, tests, and docs to use the new API. 🤖 Prompt for AI Agents |
||
| uint16_t rel_type; /**< Relationship type */ | ||
| uint16_t confidence; /**< Confidence (IEEE-754 half float) */ | ||
| uint64_t timestamp; /**< Creation time (Unix millis) */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Timestamp units mismatch (docs vs. impl) Comment says “Unix millis”, but augment.c initializes via 🤖 Prompt for AI Agents |
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,8 +38,10 @@ typedef enum { | |||||||||||||
| */ | ||||||||||||||
| typedef struct gm_edge_attributed { | ||||||||||||||
| /* Base edge fields */ | ||||||||||||||
| uint8_t src_sha[GM_SHA1_SIZE]; /**< Source object SHA-1 */ | ||||||||||||||
| uint8_t tgt_sha[GM_SHA1_SIZE]; /**< Target object SHA-1 */ | ||||||||||||||
| uint8_t src_sha[GM_SHA1_SIZE]; /**< Source object SHA-1 (legacy) */ | ||||||||||||||
| uint8_t tgt_sha[GM_SHA1_SIZE]; /**< Target object SHA-1 (legacy) */ | ||||||||||||||
| gm_oid_t src_oid; /**< Source object OID (preferred) */ | ||||||||||||||
| gm_oid_t tgt_oid; /**< Target object OID (preferred) */ | ||||||||||||||
| uint16_t rel_type; /**< Relationship type */ | ||||||||||||||
|
Comment on lines
+41
to
45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Add lane aliases used by tests to avoid enum drift. Tests reference GM_LANE_DEFAULT and GM_LANE_ANALYSIS; add synonyms to keep API stable. Apply: typedef enum {
GM_LANE_PRIMARY = 0, /**< Primary knowledge lane */
GM_LANE_EXPLORATION = 1,/**< Exploratory connections */
GM_LANE_REVIEW = 2, /**< Under review */
- GM_LANE_ARCHIVED = 3 /**< Archived/deprecated */
+ GM_LANE_ARCHIVED = 3, /**< Archived/deprecated */
+ /* Aliases for compatibility */
+ GM_LANE_DEFAULT = GM_LANE_PRIMARY,
+ GM_LANE_ANALYSIS = GM_LANE_EXPLORATION
} gm_lane_type_t;
🤖 Prompt for AI Agents |
||||||||||||||
| uint16_t confidence; /**< Confidence (IEEE-754 half float) */ | ||||||||||||||
| uint64_t timestamp; /**< Creation time (Unix millis) */ | ||||||||||||||
|
Comment on lines
45
to
47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Docs: confidence field isn’t IEEE‑754 f16. Update comments to reflect fixed‑point scaling (1.0→0x3C00) or switch implementation to true half‑float. Recommend doc update for now. Apply: - uint16_t confidence; /**< Confidence (IEEE-754 half float) */
+ uint16_t confidence; /**< Confidence (fixed-point; 1.0 -> 0x3C00) */📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
@@ -119,6 +121,40 @@ gm_result_void_t gm_edge_attributed_format(const gm_edge_attributed_t *edge, | |||||||||||||
| gm_result_void_t gm_edge_attributed_format_with_attribution( | ||||||||||||||
| const gm_edge_attributed_t *edge, char *buffer, size_t len); | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Encode attributed edge to CBOR (OID-first; includes legacy fields for compat). | ||||||||||||||
| * | ||||||||||||||
| * @param edge Edge to encode | ||||||||||||||
| * @param buffer Output buffer | ||||||||||||||
| * @param len In: buffer size, Out: bytes written | ||||||||||||||
| * @return Result indicating success or error | ||||||||||||||
| */ | ||||||||||||||
| gm_result_void_t gm_edge_attributed_encode_cbor(const gm_edge_attributed_t *edge, | ||||||||||||||
| uint8_t *buffer, size_t *len); | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Decode attributed edge from CBOR. | ||||||||||||||
| * | ||||||||||||||
| * @param buffer CBOR data | ||||||||||||||
| * @param len Buffer length | ||||||||||||||
| * @return Result with decoded edge on success | ||||||||||||||
| */ | ||||||||||||||
| gm_result_edge_attributed_t gm_edge_attributed_decode_cbor(const uint8_t *buffer, | ||||||||||||||
| size_t len); | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Decode attributed edge from CBOR and return bytes consumed. | ||||||||||||||
| * | ||||||||||||||
| * @param buffer CBOR data | ||||||||||||||
| * @param len Buffer length | ||||||||||||||
| * @param edge_out Output edge | ||||||||||||||
| * @param consumed Bytes consumed | ||||||||||||||
| * @return GM_OK on success or error code | ||||||||||||||
| */ | ||||||||||||||
| int gm_edge_attributed_decode_cbor_ex(const uint8_t *buffer, size_t len, | ||||||||||||||
| gm_edge_attributed_t *edge_out, | ||||||||||||||
| size_t *consumed); | ||||||||||||||
|
|
||||||||||||||
| #ifdef __cplusplus | ||||||||||||||
| } | ||||||||||||||
| #endif | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,21 +1,33 @@ | ||||||||||||||||||||||||||||||||||||||
| /* SPDX-License-Identifier: LicenseRef-MIND-UCAL-1.0 */ | ||||||||||||||||||||||||||||||||||||||
| /* © 2025 J. Kirby Ross / Neuroglyph Collective */ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #ifndef GM_AUGMENT_H | ||||||||||||||||||||||||||||||||||||||
| #define GM_AUGMENT_H | ||||||||||||||||||||||||||||||||||||||
| #ifndef GITMIND_AUGMENT_H | ||||||||||||||||||||||||||||||||||||||
| #define GITMIND_AUGMENT_H | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #include "gitmind.h" | ||||||||||||||||||||||||||||||||||||||
| #include "gitmind/context.h" | ||||||||||||||||||||||||||||||||||||||
| #include "gitmind/edge.h" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #include <stdbool.h> | ||||||||||||||||||||||||||||||||||||||
| #include <stddef.h> | ||||||||||||||||||||||||||||||||||||||
| #include <stdint.h> | ||||||||||||||||||||||||||||||||||||||
| #include <git2/types.h> | ||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Public API: use git_oid (hash‑agnostic) and gm_ prefix; add required libgit2 headers. Avoid hard‑coding 20‑byte SHA‑1 and follow project naming. Switch to git_oid, add the missing libgit2 headers, and prefix functions with gm_. Apply: #include <stdint.h>
#include <git2/types.h>
+#include <git2/oid.h>
+#include <git2/repository.h>
@@
-/* Get blob SHA for a file at a specific commit
+/* Get blob OID for a file at a specific commit
@@
- * @param sha_out Output buffer for 20-byte SHA-1
+ * @param oid_out Output object id (git_oid)
@@
-int get_blob_sha(git_repository *repo, const char *commit_ref,
- const char *file_path, uint8_t *sha_out);
+int gm_get_blob_oid(git_repository *repo, const char *commit_ref,
+ const char *file_path, git_oid *oid_out);
@@
-/* Find recent edges with given source blob
+/* Find recent edges with given source blob
@@
- * @param src_sha Source blob SHA to search for
+ * @param src_oid Source blob OID to search for
@@
-int find_edges_by_source(gm_context_t *ctx, const uint8_t *src_sha,
- gm_edge_t **edges_out, size_t *count_out);
+int gm_find_edges_by_source(gm_context_t *ctx, const git_oid *src_oid,
+ gm_edge_t **edges_out, size_t *count_out);
@@
-/* Create AUGMENTS edge between two blob versions
+/* Create AUGMENTS edge between two blob versions
@@
- * @param old_sha Old blob SHA (source)
- * @param new_sha New blob SHA (target)
+ * @param old_oid Old blob OID (source)
+ * @param new_oid New blob OID (target)
@@
-int create_augments_edge(gm_context_t *ctx, const uint8_t *old_sha,
- const uint8_t *new_sha, const char *file_path);
+int gm_create_augments_edge(gm_context_t *ctx, const git_oid *old_oid,
+ const git_oid *new_oid, const char *file_path);
@@
-int process_changed_file(gm_context_t *ctx, git_repository *repo,
- const char *file_path);
+int gm_process_changed_file(gm_context_t *ctx, git_repository *repo,
+ const char *file_path);
@@
-int is_merge_commit(git_repository *repo, bool *is_merge);
+int gm_is_merge_commit(git_repository *repo, bool *is_merge);Optionally keep backward compatibility with deprecated aliases (outside this hunk): /* Deprecated: remove after one release */
#define get_blob_sha(repo, ref, path, sha_out) \
gm_get_blob_oid((repo), (ref), (path), (sha_out))
#define find_edges_by_source(ctx, sha, edges_out, count_out) \
gm_find_edges_by_source((ctx), (sha), (edges_out), (count_out))
#define create_augments_edge(ctx, old_sha, new_sha, path) \
gm_create_augments_edge((ctx), (old_sha), (new_sha), (path))
#define process_changed_file gm_process_changed_file
#define is_merge_commit gm_is_merge_commitAlso applies to: 28-38, 41-49, 50-59, 61-70, 71-77
Comment on lines
+7
to
13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Avoid transitive includes; add required headers. Include gm types (for gm_oid_t size) and string.h (needed by the deprecated adapters); prefer explicit libgit2 header for repository. Apply: #include "gitmind/context.h"
#include "gitmind/edge.h"
+#include "gitmind/types.h"
@@
#include <stdint.h>
#include <git2/types.h>
+#include <git2/repository.h>
+#include <string.h>🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| #ifdef __cplusplus | ||||||||||||||||||||||||||||||||||||||
| extern "C" { | ||||||||||||||||||||||||||||||||||||||
| // keep C linkage open until end | ||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /* Constants */ | ||||||||||||||||||||||||||||||||||||||
| #define MAX_CHANGED_FILES 50 /* Skip if more files changed */ | ||||||||||||||||||||||||||||||||||||||
| #define LOOKBACK_LIMIT 200 /* Max edges to scan */ | ||||||||||||||||||||||||||||||||||||||
| #define HOOK_TIMEOUT_MS 500 /* Abort if taking too long */ | ||||||||||||||||||||||||||||||||||||||
| #define MAX_PATH_LENGTH 4096 /* Maximum file path length */ | ||||||||||||||||||||||||||||||||||||||
| /* Constants (public, prefixed) */ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #define GM_AUGMENT_MAX_CHANGED_FILES 50 /* Skip if more files changed */ | ||||||||||||||||||||||||||||||||||||||
| #define GM_AUGMENT_LOOKBACK_LIMIT 200 /* Max edges to scan */ | ||||||||||||||||||||||||||||||||||||||
| #define GM_AUGMENT_HOOK_TIMEOUT_MS 500 /* Abort if taking too long */ | ||||||||||||||||||||||||||||||||||||||
| #define GM_AUGMENT_MAX_PATH_LENGTH 4096 /* Maximum file path length */ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Unify path-length constant with global limit. Prevent drift from GM_PATH_MAX used in core/src. Apply: -#define GM_AUGMENT_MAX_PATH_LENGTH 4096 /* Maximum file path length */
+#define GM_AUGMENT_MAX_PATH_LENGTH GM_PATH_MAX /* Keep in sync with global path limit */📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| /* Backward-compat (deprecated): old macro names */ | ||||||||||||||||||||||||||||||||||||||
| #define MAX_CHANGED_FILES GM_AUGMENT_MAX_CHANGED_FILES | ||||||||||||||||||||||||||||||||||||||
| #define LOOKBACK_LIMIT GM_AUGMENT_LOOKBACK_LIMIT | ||||||||||||||||||||||||||||||||||||||
| #define HOOK_TIMEOUT_MS GM_AUGMENT_HOOK_TIMEOUT_MS | ||||||||||||||||||||||||||||||||||||||
| #define MAX_PATH_LENGTH GM_AUGMENT_MAX_PATH_LENGTH | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Guard legacy macro aliases to avoid redefinition. Apply: /* Backward-compat (deprecated): old macro names */
-#define MAX_CHANGED_FILES GM_AUGMENT_MAX_CHANGED_FILES
-#define LOOKBACK_LIMIT GM_AUGMENT_LOOKBACK_LIMIT
-#define HOOK_TIMEOUT_MS GM_AUGMENT_HOOK_TIMEOUT_MS
-#define MAX_PATH_LENGTH GM_AUGMENT_MAX_PATH_LENGTH
+#ifndef MAX_CHANGED_FILES
+#define MAX_CHANGED_FILES GM_AUGMENT_MAX_CHANGED_FILES
+#endif
+#ifndef LOOKBACK_LIMIT
+#define LOOKBACK_LIMIT GM_AUGMENT_LOOKBACK_LIMIT
+#endif
+#ifndef HOOK_TIMEOUT_MS
+#define HOOK_TIMEOUT_MS GM_AUGMENT_HOOK_TIMEOUT_MS
+#endif
+#ifndef MAX_PATH_LENGTH
+#define MAX_PATH_LENGTH GM_AUGMENT_MAX_PATH_LENGTH
+#endif📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /* Get blob SHA for a file at a specific commit | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -25,19 +37,19 @@ | |||||||||||||||||||||||||||||||||||||
| * @param sha_out Output buffer for 20-byte SHA-1 | ||||||||||||||||||||||||||||||||||||||
| * @return 0 on success, error code otherwise | ||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||
| int get_blob_sha(git_repository *repo, const char *commit_ref, | ||||||||||||||||||||||||||||||||||||||
| const char *file_path, uint8_t *sha_out); | ||||||||||||||||||||||||||||||||||||||
| int gm_hook_get_blob_sha(git_repository *repo, const char *commit_ref, | ||||||||||||||||||||||||||||||||||||||
| const char *file_path, gm_oid_t *sha_out); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /* Find recent edges with given source blob | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * @param ctx git-mind context | ||||||||||||||||||||||||||||||||||||||
| * @param src_sha Source blob SHA to search for | ||||||||||||||||||||||||||||||||||||||
| * @param edges_out Output array of matching edges (caller must free) | ||||||||||||||||||||||||||||||||||||||
| * @param edges_out Output array of matching edges (caller must free with free()) | ||||||||||||||||||||||||||||||||||||||
| * @param count_out Number of edges found | ||||||||||||||||||||||||||||||||||||||
| * @return 0 on success, error code otherwise | ||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||
| int find_edges_by_source(gm_context_t *ctx, const uint8_t *src_sha, | ||||||||||||||||||||||||||||||||||||||
| gm_edge_t **edges_out, size_t *count_out); | ||||||||||||||||||||||||||||||||||||||
| int gm_hook_find_edges_by_source(gm_context_t *ctx, const gm_oid_t *src_oid, | ||||||||||||||||||||||||||||||||||||||
| gm_edge_t **edges_out, size_t *count_out); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /* Create AUGMENTS edge between two blob versions | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -47,8 +59,8 @@ int find_edges_by_source(gm_context_t *ctx, const uint8_t *src_sha, | |||||||||||||||||||||||||||||||||||||
| * @param file_path Path to file (for human readability) | ||||||||||||||||||||||||||||||||||||||
| * @return 0 on success, error code otherwise | ||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||
| int create_augments_edge(gm_context_t *ctx, const uint8_t *old_sha, | ||||||||||||||||||||||||||||||||||||||
| const uint8_t *new_sha, const char *file_path); | ||||||||||||||||||||||||||||||||||||||
| int gm_hook_create_augments_edge(gm_context_t *ctx, const gm_oid_t *old_oid, | ||||||||||||||||||||||||||||||||||||||
| const gm_oid_t *new_oid, const char *file_path); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /* Process a single changed file | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -57,15 +69,33 @@ int create_augments_edge(gm_context_t *ctx, const uint8_t *old_sha, | |||||||||||||||||||||||||||||||||||||
| * @param file_path Path to changed file | ||||||||||||||||||||||||||||||||||||||
| * @return 0 on success, error code otherwise | ||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||
| int process_changed_file(gm_context_t *ctx, git_repository *repo, | ||||||||||||||||||||||||||||||||||||||
| const char *file_path); | ||||||||||||||||||||||||||||||||||||||
| int gm_hook_process_changed_file(gm_context_t *ctx, git_repository *repo, | ||||||||||||||||||||||||||||||||||||||
| const char *file_path); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /* Check if this is a merge commit | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * @param repo Git repository | ||||||||||||||||||||||||||||||||||||||
| * @param is_merge Output: true if merge commit | ||||||||||||||||||||||||||||||||||||||
| * @return 0 on success, error code otherwise | ||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||
| int is_merge_commit(git_repository *repo, bool *is_merge); | ||||||||||||||||||||||||||||||||||||||
| int gm_hook_is_merge_commit(git_repository *repo, bool *is_merge); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /* Backward-compatibility macros (deprecated) */ | ||||||||||||||||||||||||||||||||||||||
| #define get_blob_sha gm_hook_get_blob_sha | ||||||||||||||||||||||||||||||||||||||
| #define find_edges_by_source gm_hook_find_edges_by_source | ||||||||||||||||||||||||||||||||||||||
| #define create_augments_edge gm_hook_create_augments_edge | ||||||||||||||||||||||||||||||||||||||
| #define process_changed_file gm_hook_process_changed_file | ||||||||||||||||||||||||||||||||||||||
| #define is_merge_commit gm_hook_is_merge_commit | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+83
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deprecated macro remaps are unsafe: signatures changed These macros map old names to new functions but the parameter types differ ( -/* Backward-compatibility macros (deprecated) */
-#define get_blob_sha gm_hook_get_blob_sha
-#define find_edges_by_source gm_hook_find_edges_by_source
-#define create_augments_edge gm_hook_create_augments_edge
-#define process_changed_file gm_hook_process_changed_file
-#define is_merge_commit gm_hook_is_merge_commit
+/* Backward-compatibility adapters (deprecated: remove next release) */
+#include <string.h>
+#include <git2/oid.h>
+static inline int get_blob_sha(git_repository *repo, const char *commit_ref,
+ const char *file_path, uint8_t *sha_out) {
+ gm_oid_t oid;
+ int rc = gm_hook_get_blob_sha(repo, commit_ref, file_path, &oid);
+ if (rc != 0) return rc;
+ /* git_oid is raw bytes; copy out */
+ memcpy(sha_out, &oid, GM_OID_RAWSZ);
+ return 0;
+}
+static inline int find_edges_by_source(gm_context_t *ctx, const uint8_t *src_sha,
+ gm_edge_t **edges_out, size_t *count_out) {
+ gm_oid_t oid;
+ memcpy(&oid, src_sha, GM_OID_RAWSZ);
+ return gm_hook_find_edges_by_source(ctx, &oid, edges_out, count_out);
+}
+static inline int create_augments_edge(gm_context_t *ctx, const uint8_t *old_sha,
+ const uint8_t *new_sha, const char *file_path) {
+ gm_oid_t old_oid, new_oid;
+ memcpy(&old_oid, old_sha, GM_OID_RAWSZ);
+ memcpy(&new_oid, new_sha, GM_OID_RAWSZ);
+ return gm_hook_create_augments_edge(ctx, &old_oid, &new_oid, file_path);
+}
+/* Names without signature changes can stay as aliases */
+#define process_changed_file gm_hook_process_changed_file
+#define is_merge_commit gm_hook_is_merge_commit
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| /* Preferred names (aliases) */ | ||||||||||||||||||||||||||||||||||||||
| #define gm_augment_get_blob_sha gm_hook_get_blob_sha | ||||||||||||||||||||||||||||||||||||||
| #define gm_augment_find_edges_by_source gm_hook_find_edges_by_source | ||||||||||||||||||||||||||||||||||||||
| #define gm_augment_create_augments_edge gm_hook_create_augments_edge | ||||||||||||||||||||||||||||||||||||||
| #define gm_augment_process_changed_file gm_hook_process_changed_file | ||||||||||||||||||||||||||||||||||||||
| #define gm_augment_is_merge_commit gm_hook_is_merge_commit | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #ifdef __cplusplus | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #endif /* GM_AUGMENT_H */ | ||||||||||||||||||||||||||||||||||||||
| #endif /* GITMIND_AUGMENT_H */ | ||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| #include <stddef.h> | ||
| #include <stdint.h> | ||
| #include <git2/oid.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
|
|
@@ -19,6 +20,10 @@ extern "C" { | |
| /* Size constants */ | ||
| #define GM_SHA1_SIZE 20 | ||
| #define GM_SHA256_SIZE 32 | ||
| #ifndef GIT_OID_RAWSZ | ||
| #define GIT_OID_RAWSZ 20 | ||
| #endif | ||
| #define GM_OID_RAWSZ GIT_OID_RAWSZ | ||
| #define GM_PATH_MAX 256 | ||
|
Comment on lines
+23
to
27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Guarded fallback for GIT_OID_RAWSZ is fine; add a compile‑time size check Add a static assert to ensure #define GM_SHA256_SIZE 32
#ifndef GIT_OID_RAWSZ
#define GIT_OID_RAWSZ 20
#endif
#define GM_OID_RAWSZ GIT_OID_RAWSZ
+/* Ensure alias size matches configured raw OID size */
+_Static_assert(sizeof(gm_oid_t) == GM_OID_RAWSZ, "gm_oid_t size mismatch");
🤖 Prompt for AI Agents |
||
| #define GM_ULID_SIZE 26 | ||
| #define GM_FORMAT_BUFFER_SIZE 512 | ||
|
|
@@ -37,6 +42,10 @@ typedef enum { | |
| } gm_rel_type_t; | ||
|
|
||
| /* Include sub-types */ | ||
| /** | ||
| * OID type (SHA-agnostic). Use instead of raw byte arrays in new code. | ||
| */ | ||
| typedef git_oid gm_oid_t; | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Add blank lines around sub-list to satisfy markdownlint (MD032).
Run
make md-fixor insert blank lines before/after the marked bullets.📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
21-21: Lists should be surrounded by blank lines
(MD032, blanks-around-lists)
🤖 Prompt for AI Agents