MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / try_artifact_bootstrap

Function try_artifact_bootstrap

src/mcp/mcp.c:10748–10776  ·  view source on GitHub ↗

Bootstrap from artifact if no local DB exists for this project. */

Source from the content-addressed store, hash-verified

10746
10747/* Bootstrap from artifact if no local DB exists for this project. */
10748static void try_artifact_bootstrap(const char *project_name, const char *repo_path) {
10749 char db_buf[CBM_SZ_1K];
10750 project_db_path(project_name, db_buf, sizeof(db_buf));
10751 if (cbm_file_size(db_buf) < 0 && cbm_artifact_exists(repo_path)) {
10752 cbm_log_info("index.artifact_bootstrap", "project", project_name);
10753 /* An imported artifact is trusted for graph CONTENT as-is — nothing
10754 * verifies that its nodes/edges describe the code they claim to. What
10755 * has been limiting the blast radius is mechanical, not a check: every
10756 * imported row carries the EXPORTER's mtime, so the first incremental
10757 * run re-parses ~everything and auto-scrubs a poisoned artifact at a
10758 * clone time the producer cannot predict. That exposure is transient
10759 * and self-healing.
10760 *
10761 * cbm_artifact_reconcile_hashes deliberately trades part of that away
10762 * for the speed the artifact is supposed to deliver (#885): rows it
10763 * restamps are no longer re-parsed, so poisoned nodes for those files
10764 * persist until the file changes — a DURABLE exposure gated on a
10765 * producer-written marker. It stays acceptable only because the marker
10766 * alone never suffices: each restamped row must additionally be proven
10767 * unchanged by the LOCAL git against a commit present in this clone.
10768 * Read the trade-off note in artifact.h before widening it.
10769 *
10770 * Best-effort: a -1 return leaves every row foreign and falls back to
10771 * today's behavior, so a failure here can never fail the import. */
10772 if (cbm_artifact_import(repo_path, db_buf) == 0) {
10773 (void)cbm_artifact_reconcile_hashes(repo_path, db_buf, project_name);
10774 }
10775 }
10776}
10777
10778/* Cap on excluded dir paths listed in the response — keep it compact on large
10779 * repos (node_modules / vendor / etc. can produce many skip points). The full

Callers 1

handle_index_repositoryFunction · 0.85

Calls 5

project_db_pathFunction · 0.85
cbm_file_sizeFunction · 0.85
cbm_artifact_existsFunction · 0.85
cbm_artifact_importFunction · 0.85

Tested by

no test coverage detected