-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add badges + star CTA to README #127
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,9 @@ export interface IngestOptions { | |
| /** Maximum file size for ingestion (10 MB). Files larger than this are skipped. */ | ||
| const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10 MB | ||
|
|
||
| /** Per-file processing timeout (10 seconds). */ | ||
| const FILE_TIMEOUT_MS = 10_000; // 10 seconds per file | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // Progress event helpers (gated on BRAIN_DEBUG=true) | ||
| // --------------------------------------------------------------------------- | ||
|
|
@@ -147,7 +150,7 @@ export async function ingestPath( | |
| // Yield so event loop can handle HTTP requests + tool calls before ingest starts | ||
| await new Promise(r => setTimeout(r, 0)); | ||
|
|
||
| for (const [i, walked] of walkedFiles.entries()) { | ||
| async function processFile(walked: WalkResult, i: number): Promise<void> { | ||
| const filePath = walked.path; | ||
| const language = walked.language; | ||
| const fileStart = Date.now(); | ||
|
|
@@ -164,14 +167,14 @@ export async function ingestPath( | |
| fileStats = await stat(filePath); | ||
| } catch (err) { | ||
| result.errors.push(`Failed to stat ${filePath}: ${String(err)}`); | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| if (fileStats.size > MAX_FILE_SIZE) { | ||
| result.errors.push( | ||
| `Skipped ${filePath}: file size ${fileStats.size} exceeds 10MB cap`, | ||
| ); | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // Read file as raw buffer — binary-safe hashing (avoids encoding issues) | ||
|
|
@@ -181,13 +184,13 @@ export async function ingestPath( | |
| } catch (err) { | ||
| result.errors.push(`Failed to read ${filePath}: ${String(err)}`); | ||
| result.filesProcessed++; | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // Binary content guard: skip files with null bytes (safety net for misnamed binaries) | ||
| if (isBinaryContent(new Uint8Array(buf))) { | ||
| log("debug", "ingest", `Skipped binary content: ${filePath}`); | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // ── Per-file SAVEPOINT for atomic DB writes ──────────────────────── | ||
|
|
@@ -211,7 +214,7 @@ export async function ingestPath( | |
| result.filesSkipped++; | ||
| result.filesProcessed++; | ||
| options?.progressCallback?.({ current: result.filesProcessed, total: walkedFiles.length }); | ||
| continue; | ||
| return; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -237,7 +240,7 @@ export async function ingestPath( | |
| } catch (err) { | ||
| db.exec(`ROLLBACK TO SAVEPOINT ${spFile}`); | ||
| result.errors.push(`Failed to insert file ${filePath}: ${String(err)}`); | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // ── 7. Insert documents table ────────────────────────────────── | ||
|
|
@@ -265,7 +268,7 @@ export async function ingestPath( | |
| } catch (err) { | ||
| db.exec(`ROLLBACK TO SAVEPOINT ${spFile}`); | ||
| result.errors.push(`Failed to insert document ${filePath}: ${String(err)}`); | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // ── 8. Chunk content (symbol extraction happens inside chunker) ── | ||
|
|
@@ -284,7 +287,7 @@ export async function ingestPath( | |
| } catch (err) { | ||
| db.exec(`ROLLBACK TO SAVEPOINT ${spFile}`); | ||
| result.errors.push(`Failed to chunk ${filePath}: ${String(err)}`); | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // ── 9. Insert chunks (includes token_count) ─────────────────────── | ||
|
|
@@ -328,7 +331,7 @@ export async function ingestPath( | |
|
|
||
| if (fileFailed) { | ||
| result.filesProcessed++; | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // ── 10. Embed chunks (vec0) — non-fatal if unavailable ───────── | ||
|
|
@@ -345,7 +348,7 @@ export async function ingestPath( | |
|
|
||
| if (fileFailed) { | ||
| result.filesProcessed++; | ||
| continue; | ||
| return; | ||
| } | ||
|
|
||
| // ── 11. Populate symbols table (global symbol store) ───────────── | ||
|
|
@@ -383,10 +386,27 @@ export async function ingestPath( | |
| if (process.env.BRAIN_DEBUG === "true") { | ||
| log("debug", "ingest", `processed ${result.filesProcessed}/${walkedFiles.length}: ${filePath} (${Date.now() - fileStart}ms)`); | ||
| } | ||
| } | ||
|
|
||
| for (const [i, walked] of walkedFiles.entries()) { | ||
| try { | ||
| await Promise.race([ | ||
|
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. P1: Prompt for AI agents |
||
| processFile(walked, i), | ||
| new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), FILE_TIMEOUT_MS)) | ||
| ]); | ||
| } catch (err) { | ||
| if (err instanceof Error && err.message === 'timeout') { | ||
| emitProgressEvent("ingest.file_timeout", { file: walked.path }); | ||
| result.errors.push(`Timeout processing ${walked.path}: exceeded ${FILE_TIMEOUT_MS}ms`); | ||
| result.filesProcessed++; | ||
| continue; | ||
| } | ||
| throw err; | ||
| } | ||
|
|
||
| // Yield so event loop can handle HTTP requests + tool calls | ||
| await new Promise(r => setTimeout(r, 0)); | ||
| } | ||
| } | ||
|
|
||
| // Checkpoint WAL to keep file manageable after large ingests | ||
| checkpointDatabase(db); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
P3: README now renders duplicate badges because a new badge block was added without removing the existing one.
Prompt for AI agents