feat: repo known files tracking [CM-1329]#4396
Conversation
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
…probe Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
PR SummaryMedium Risk Overview Enrichment fetch now loads root, Write path: the enrichment flush buffer includes well-known-file updates and Reviewed by Cursor Bugbot for commit 85d7e45. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Adds GitHub repository well-known-file inventory and change tracking.
Changes:
- Fetches and classifies files from root,
.github, anddocs. - Adds transactional upsert, soft-delete, and reappearance tracking.
- Introduces the
repo_well_known_filestable and indexes.
Metadata: Rename the PR to feat: track repository well-known files (CM-1329) to match repository conventions.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
wellKnownFiles.ts |
Classifies well-known files. |
updateWellKnownFiles.ts |
Persists inventory changes. |
types.ts |
Adds inventory types. |
runEnrichmentLoop.ts |
Buffers and flushes inventory updates. |
fetchLightRepo.ts |
Fetches repository directory trees. |
V1784905809__repo_well_known_files.sql |
Creates the inventory schema and indexes. |
updateEnrichedRepos.ts |
Context reviewed for enrichment persistence integration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export async function bulkUpsertRepoWellKnownFiles( | ||
| qx: QueryExecutor, | ||
| updates: RepoWellKnownFilesUpdate[], | ||
| ): Promise<void> { |
| export function classifyWellKnownFiles(trees: RepoTrees): WellKnownFileEntry[] { | ||
| const result: WellKnownFileEntry[] = [] | ||
| for (const { key, directory, prefix } of DIRECTORIES) { | ||
| for (const entry of trees[key] ?? []) { | ||
| if (entry.type !== 'blob') continue |
| await qx.result( | ||
| ` | ||
| WITH input AS ( |
This pull request adds support for tracking well-known files (such as
README,SECURITY.md,CONTRIBUTING.md, etc.) in GitHub repositories, both in the enrichment pipeline and in the database. The changes introduce a new database table to inventory these files, update the enrichment worker to extract and classify them, and ensure the data is efficiently upserted and soft-deleted as repositories change.Database changes:
repo_well_known_filesto store inventory of well-known files per repository, including file type, directory, path, and blob OID, with support for soft deletion and change tracking.Enrichment pipeline updates:
fetchLightRepo.tsto fetch the root,.github, anddocsdirectory trees, and removed the previous REST-based check forSECURITY.md. [1] [2]LightRepoResultand added a newRepoWellKnownFilesUpdatetype for batch updates. [1] [2]Batch processing and upsert:
bulkUpsertRepoWellKnownFilesto upsert and soft-delete well-known file records efficiently in the database.Well-known file classification logic:
wellKnownFiles.tswith logic to classify files by type and directory, and to derive the presence of a security file from the directory trees.These changes enable the system to efficiently track, update, and query the presence and state of well-known files across all monitored repositories.