Skip to content

Commit 1b61951

Browse files
committed
chore: add benchmark npm script and stale embeddings warning
Add `npm run benchmark` script to make benchmark execution discoverable instead of requiring manual `node --import ./scripts/ts-resolve-loader.js` invocation. Warn users when embeddings predate the last graph rebuild so they know to re-run `codegraph embed` for fresh search results. Impact: 1 functions changed, 8 affected
1 parent 9e5acc7 commit 1b61951

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});require('fs').rmSync('.tsbuildinfo',{force:true})\"",
4444
"prepare": "npm run build:wasm && npm run build && husky && npm run deps:tree",
4545
"deps:tree": "node scripts/node-ts.js scripts/gen-deps.ts",
46+
"benchmark": "node --experimental-strip-types --import ./scripts/ts-resolve-loader.js scripts/benchmark.ts",
4647
"release": "commit-and-tag-version",
4748
"release:dry-run": "commit-and-tag-version --dry-run",
4849
"version": "node scripts/node-ts.js scripts/sync-native-versions.ts && git add package.json crates/codegraph-core/Cargo.toml"

src/domain/graph/builder/stages/finalize.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,34 @@ export async function finalize(ctx: PipelineContext): Promise<void> {
8383
}
8484
}
8585

86+
// Stale embeddings warning (built before last graph rebuild)
87+
if (hasEmbeddings) {
88+
try {
89+
const embedBuiltAt = (
90+
db.prepare("SELECT value FROM embedding_meta WHERE key = 'built_at'").get() as
91+
| { value: string }
92+
| undefined
93+
)?.value;
94+
if (embedBuiltAt) {
95+
const embedTime = new Date(embedBuiltAt).getTime();
96+
const now = Date.now();
97+
if (embedTime < now && !Number.isNaN(embedTime)) {
98+
const prevBuildAt = getBuildMeta(db, 'built_at');
99+
if (prevBuildAt) {
100+
const prevBuildTime = new Date(prevBuildAt).getTime();
101+
if (embedTime < prevBuildTime) {
102+
warn(
103+
'Embeddings were built before the last graph rebuild. Run "codegraph embed" to update.',
104+
);
105+
}
106+
}
107+
}
108+
}
109+
} catch {
110+
/* ignore - embedding_meta table may not exist */
111+
}
112+
}
113+
86114
// Unused exports warning
87115
try {
88116
const unusedCount = (

0 commit comments

Comments
 (0)