agentleFS
GoogleKnown publishergoogle/osv.dev/AGENTS.md

osv.dev

AGENTS.md3k starsChanged 59 days agoApache-2.0View on GitHub

This file provides guidance for AI coding agents working on the osv.dev repository. It outlines the project structure, setup commands, testing instructions, and coding standards. [!IMPORTANT] Keeping this file up to date: If you (an AI agent) make any major architectural changes, introduce new services, or modify core workflows (like testing or linting), you MUST update this AGENTS.md file to reflect those changes. These models are defined in Python (osv/models.py) and mirrored in Go (go/internal/database/datastore/models.go).

  • Installs packages

Trending

Quiet since August.about the whole repository

Dec 2025: 2 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 1 mentionApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the google/osv.dev repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about google/osv.dev

The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 18

Talked about on GitHub and Bluesky (18 times).

On GitHub · 17

12 more on GitHub

On Bluesky · 1

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

13 rules. About 1 is common, 6 are distinctive, and 6 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When AI agents need to understand the exact format, fields, and semantics of vulnerability records, refer to the local osv-schema submodule:

    line 28
  2. Distinctive:

    Always format and lint your code before proposing changes.

    line 96
  3. Very specific:

    Rule: When running Python scripts, always use poetry run.

    line 128
  4. Very specific:

    Running Go Linters: Run golangci-lint using go run directly within the module directory (go/, vulnfeeds/, or bindings/go/), or run …

    line 132
  5. Very specific:

    Conventional Commits: Commit messages must follow the Conventional Commits specification (e.g., feat:, fix:, docs:, refactor:, chore:).

    line 144
  6. Distinctive:

    Regenerate Expected Test Outputs: If you make changes that alter expected test outputs, regenerate them using:

    line 178
  7. Distinctive:

    Regenerate API query snapshots: If you modify API behaviors, update query snapshots using:

    line 182
  8. Distinctive:

    Always inspect the resulting git diff to ensure the API query output changes are expected.

    line 186
  9. Common:

    Run the local Go website development server against a live flat mock dataset with hot reloading (no GCP credentials or Datastore emulator …

    line 190
  10. Distinctive:

    Run the Go website server against production Datastore:

    line 196
  11. Very specific:

    All Go microservices are compiled using a single, unified multi-target Dockerfile (go/Dockerfile) which shares the workspace compilation …

    line 217
  12. Distinctive:

    Run as a cron job.

    line 247
  13. Very specific:

    Run as a cron job (go/cmd/ubuntubinarymapper/).

    line 281

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

This file provides guidance for AI coding agents working on the osv.dev repository. It outlines the project structure, setup commands, testing instructions, and coding standards.

[!IMPORTANT] Keeping this file up to date: If you (an AI agent) make any major architectural changes, introduce new services, or modify core workflows (like testing or linting), you MUST update this AGENTS.md file to reflect those changes.

Project Overview

This repository (google/osv.dev) contains the backend services, database models, API, and website for the Open Source Vulnerabilities (OSV) database.

Infrastructure & Storage

  • Cloud Platform: The entire system runs on Google Cloud Platform (GCP).
  • Database (Indexes): We currently use Google Cloud Datastore to store and query indexes.
  • Database (Full Records): Full vulnerability records are stored as protocol buffers (protos) in Google Cloud Storage (GCS).
  • Future Architecture: There are long-term plans to migrate the database backend to PostgreSQL, but this is not yet concrete. Rule: Any new Go code interacting with the database must be abstracted behind interfaces to facilitate this eventual migration. Much of this abstraction is already in place—refer to the shared domain interfaces defined under go/internal/models/.

Monorepo Structure

It is structured as a multi-language monorepo:

  • go/: Go services and utilities (importers, exporter, internal libraries). This is the primary target for active migrations from Python.
  • osv/: Core Python library containing models, repository helpers, and ecosystem-specific logic. Note: Some parts are deprecated as we migrate logic to Go.
  • gcp/: GCP deployment configurations, Cloud Functions, and workers.
  • website/: Frontend assets for the osv.dev website (frontend3 using pnpm) and blog posts (blog using Hugo).
  • vulnfeeds/: Vulnerability feed utilities (independent Go module).
  • bindings/: API bindings (contains an independent Go module under bindings/go).

OSV Schema Reference

Vulnerabilities across the entire system conform to the Open Source Vulnerability (OSV) schema. When AI agents need to understand the exact format, fields, and semantics of vulnerability records, refer to the local osv-schema submodule:


Datastore Schema & Entities

We use Google Cloud Datastore to store indices and metadata for fast querying. The primary source of truth for full vulnerability records is GCS (as protobufs), but Datastore holds crucial entities for the API and Website.

These models are defined in Python (osv/models.py) and mirrored in Go (go/internal/database/datastore/models.go).

Key Entities

  1. Vulnerability (Kind: Vulnerability)
    • Purpose: Serves as the main index for vulnerability metadata (source, modified time, aliases, relations).
    • Fields: Stores source_id (e.g., source:path), modified time, and relation lists (alias_raw, related_raw, upstream_raw).
  2. AffectedVersions (Kind: AffectedVersions)
    • Purpose: Used for API matching when querying by package name and version.
    • Fields: Contains ecosystem, name (package name), versions (list of affected versions), and events (introduced/fixed ranges).
    • Optimization: Uses coarse_min and coarse_max for fast range-based filtering.
  3. AffectedCommits (Kind: AffectedCommits)
    • Purpose: Used for API matching when querying by Git commit.
    • Fields: Maps a bug_id (vulnerability ID, note the legacy field name) to a list of affected Git commit hashes (stored as bytes).
    • Schema Quirk: The field for vulnerability ID is bug_id in Datastore but mapped to VulnID in Go.
  4. ListedVulnerability (Kind: ListedVulnerability)
    • Purpose: Optimized specifically for the website's /list page.
    • Fields: Contains summary, ecosystems, packages, severities, and search indices.
    • Rule: This entity is only used by the website and should not be used for API matching logic.
  5. UbuntuPackageMapping (Kind: UbuntuPackageMapping)
    • Purpose: Used by the experimental POST /v1experimental/ubuntu/binary-to-source API endpoint to resolve Ubuntu binary package names to their corresponding source package names.
    • Fields: Keyed by binary package name; stores source_names (unindexed list of corresponding Ubuntu source package names).
    • Note: Defined in Go (go/internal/database/datastore/ubuntu_package_mapping.go) and populated by ubuntubinarymapper.

Setup Commands

The project uses poetry for Python dependency management, pnpm for website frontend, and Standard Go modules for Go.

  • Install Python Dependencies:
    poetry install
  • Install Go Dependencies: There are multiple Go modules in this monorepo. Run go mod download from within the respective directory (go/, vulnfeeds/, or bindings/go/) depending on what you are working on:
    cd go && go mod download
  • Install Website Dependencies (for frontend development):
    cd website/frontend3 && pnpm install
  • Initialize Git Submodules:
    git submodule update --init --recursive
  • Build Protos:
    make build-protos

Code Style & Formatting

Always format and lint your code before proposing changes. The repository provides a unified script to check for style violations with smart incremental checking:

  • Run Linters & Format Checks (Smart Auto-Detect): By default, this automatically checks only the files and Go modules changed relative to master (or full repo if on clean master):
    poetry run tools/lint_and_format.sh
  • Run Full Check on Entire Repo:
    poetry run tools/lint_and_format.sh --all
  • Run on Staged Changes Only:
    poetry run tools/lint_and_format.sh --staged
  • Automatically Fix/Format Files:
    poetry run tools/lint_and_format.sh --fix
  • Lint Specific Files:
    poetry run tools/lint_and_format.sh osv/bug.py go/cmd/worker/main.go

Python Standards

  • Formatter: yapf (config: .style.yapf, runs in parallel via -p)
  • Linter: pylint (config: .pylintrc, runs in parallel via -j 0)
  • Formatting Command: To automatically format Python files, run:
    poetry run yapf -i <path_to_file>.py
    (Or run poetry run tools/lint_and_format.sh --fix)
  • Rule: When running Python scripts, always use poetry run.

Go Standards

  • Linter: golangci-lint
  • Running Go Linters: Run golangci-lint using go run directly within the module directory (go/, vulnfeeds/, or bindings/go/), or run tools/lint_and_format.sh which automatically maps changed files to the enclosing module:
    cd go && go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.0 run ./...
    (Note: Run outside the sandbox so go run can fetch the linter toolchain if not cached).
  • Formatting Command:
    cd go && gofmt -s -w .
  • Rule: Go code must follow standard Go formatting guidelines.

Git Commit Guidelines

  • Conventional Commits: Commit messages must follow the Conventional Commits specification (e.g., feat:, fix:, docs:, refactor:, chore:).

Pull Request (PR) Guidelines

  • PR Metadata: Feel free to append metadata, tracking notes, or categories inside hidden HTML comments at the very end of your PR descriptions (for example, <!-- AI-PR --> or other tags). This keeps the rendered description page clean while preserving useful context in the raw markdown.

Testing & Local Development

To run tests and run services locally, configure the Cloud SDK and install the Firestore emulator:

gcloud auth login
gcloud auth application-default login
gcloud components install cloud-firestore-emulator

Running Test Suites

  • All Tests: make all-tests
  • Go Tests: make go-tests (or run ./run_tests.sh inside go/)
  • Python Library Tests: make lib-tests

Running Specific Tests

To save time during development, you can run specific tests instead of the entire suite:

  • Single Go Test: Navigate to go/ and run go test with -run:
    go test -v ./internal/database/datastore -run TestComputeAffectedVersions
  • Single Python Test: From the root, run using poetry run python -m unittest:
    poetry run python -m unittest osv.bug_test.NormalizeTest.test_normalize

Managing Test Expectations & Snapshots

Many tests use expected outputs saved directly in the source tree:

  • Regenerate Expected Test Outputs: If you make changes that alter expected test outputs, regenerate them using:
    TESTS_GENERATE=1 make all-tests
  • Regenerate API query snapshots: If you modify API behaviors, update query snapshots using:
    make update-api-snapshots
    Always inspect the resulting git diff to ensure the API query output changes are expected.

Local UI & Website Development

  • Website DevServer (Go-native): Run the local Go website development server against a live flat mock dataset with hot reloading (no GCP credentials or Datastore emulator required):
    make run-website-devserver
    • Mock vulnerability records are located in go/cmd/website-devserver/testdata/. Add or edit .json records and .meta.yaml companion files to immediately see changes on page refresh.
  • Run against Cloud Datastore: Run the Go website server against production Datastore:
    make run-website
    Or against staging Datastore:
    make run-website-staging

Local API Server Development (Go-native)

  • To run the public OSV API server locally using the native Go implementation alongside the ESPv2 proxy (which transcodes HTTP/JSON REST requests to gRPC):
    make run-api-server

Go Component Architecture (go/)

The Go component contains the active and migrated services for the OSV database. It is structured with executables in cmd/ and shared libraries in internal/.

Go Monorepo Docker Builds

All Go microservices are compiled using a single, unified multi-target Dockerfile (go/Dockerfile) which shares the workspace compilation setup.

  • Due to the replace directive in go/go.mod pointing to the sibling bindings/ library, Go Docker builds must mount the bindings/ folder into the build context.
  • Since the production Cloud Build steps run inside dir: 'go', they leverage BuildKit's --build-context flag to cleanly map the sibling folder without importing other monorepo files:
    docker build -t osv/importer --target importer --build-context bindings=../bindings -f Dockerfile .
  • For local dev testing, you can use the exact same command inside the go/ directory.

[!IMPORTANT] Python to Go Migration: We are actively migrating core services from Python to Go. For example, the new Go-based worker (go/cmd/worker/) replaces the legacy Python worker (gcp/workers/worker/). Always prefer modifying the Go implementation if both exist, unless instructed otherwise.

Executables (go/cmd/)

  1. api:
    • The public OSV gRPC API server.
    • Defined in go/cmd/api as a thin wrapper calling into the go/internal/api library.
  2. api-devserver:
    • Development orchestrator command for local testing.
    • Spawns the Go API server natively in a background thread while concurrently running the osv-esp (ESPv2) docker container to perform HTTP/JSON to gRPC transcoding.
  3. website:
    • The public OSV website server implemented in Go.
    • Defined in go/cmd/website and deployed to Cloud Run.
  4. website-devserver:
    • Local development server for the Go website frontend.
    • Serves the website using a live flat mock dataset in go/cmd/website-devserver/testdata/ with hot reloading (reads live from disk on every request without requiring GCP credentials or emulator).
  5. importer:
    • Run as a cron job.
    • Reads from each vulnerability data source (defined as SourceRepository in Datastore or mapped in source.yaml / source_test.yaml).
    • Detects new or deleted vulnerability records.
    • Dispatches processing tasks via GCP Pub/Sub to the worker.
  6. worker:
    • Daemon that subscribes to Pub/Sub tasks.
    • Ingests and enriches vulnerability records.
    • Computes affected Git ranges for commit-based querying.
    • Writes the enriched records to the database (GCS/Datastore).
    • Powered by a modular processing pipeline defined in go/internal/worker/pipeline/.
  7. exporter:
    • Exports the entire database to a public GCS bucket.
    • Generates a root all.zip file containing all records.
    • Generates ecosystem-specific all.zip files (e.g., PyPI/all.zip).
    • Outputs individual vulnerability JSON files in their respective ecosystem folders (e.g., PyPI/GHSA-abcd-efgh.json).
  8. relations:
    • Populates relationships between vulnerabilities in the database.
    • Calculates transitive and reflective aliases, reflective related vulnerabilities, and transitive upstream fields.
  9. gitter:
    • Git client daemon/utility to precompute and cache git operations required by other services.
    • Performs intensive Git tasks like computing commit graphs and generating patch IDs.
  10. recoverer:
  • Daemon that subscribes to failed task recovery Pub/Sub messages.
  • Repairs and retries failed GCS writes, reimports missing vulnerability records from sources (via Gitter, GCS bucket, or REST), and handles GCS generation mismatches.
  1. vanir_signatures:
  • Cron job orchestrated in Go (go/cmd/vanir_signatures/ and go/internal/vanir/) that queries modified vulnerabilities, shells out to a minimal Python helper script (generate_signatures.py) to run Vanir signature generation, and writes enriched signatures back to the database.
  1. ubuntubinarymapper:
  • Run as a cron job (go/cmd/ubuntubinarymapper/).
  • Reads Ubuntu/modified_id.csv from the exported GCS bucket (gs://osv-vulnerabilities) with a 1-hour lookback window, downloads modified Ubuntu vulnerability records (via Ubuntu/all.zip or individual Ubuntu/<id>.json files), extracts binary-to-source package name mappings from ecosystem_specific, and persists them to Datastore (UbuntuPackageMapping) alongside a JobData execution checkpoint (or to a local JSON file via -output-json).

Internal Shared Libraries (go/internal/)

  • api/: Shared package containing the core gRPC public server implementation of the OSV API.
  • website/: Shared package implementing HTTP handlers, templates, routing, and search logic for the Go website frontend.
  • worker/: Core engine and subscriber logic for the Go worker.
  • recoverer/: Core engine and handlers for the Go recoverer.
  • vanir/: Orchestration, filtering, and domain mutation logic for Vanir signature generation.
  • database/: Shared Datastore client and repository models (specifically go/internal/database/datastore/).
    • Design Pattern: Models here mirror the Datastore models defined in the Python library (osv/models.py).
    • Consistency Testing: To prevent synchronization drift between Go and Python database models, a database validation test is maintained under go/internal/database/datastore/internal/validate/ (run via run_validate.sh).
    • Schema Quirks (Crucial for Agents): In the Datastore database, the legacy term bug was used for vulnerabilities. Consequently, many Datastore fields still use names like bug_id or bug_ids. In the Go codebase, these are mapped to Go struct fields like VulnID or VulnIDs (e.g., AffectedCommits has VulnID string datastore:"bug_id"). Pay close attention to the datastore: tag when writing queries or defining new fields!
  • gitter/: Client logic to interface with the Gitter caching service.
  • repos/: Shared Git repository management and utilities.

Python Component Architecture (osv/)

The osv folder is a shared Python package. Since the primary API server and some workers are still in Python, this package remains highly active.

  • models.py: Datastore models (e.g., Vulnerability, Repository) used by the Python API.
    • Note on Bug Entity: The Bug entity inside models.py is legacy and retired for core services. It is no longer used by the primary system, except by OSS-Fuzz.
  • bug.py: Helper classes and methods for representing bugs.
  • impact.py: Core engine to calculate the impact of vulnerabilities.
  • ecosystems/: Ecosystem-specific logic (e.g., PyPI, Maven, NPM) for analyzing versions and ranges.

GCP Component Architecture (gcp/)

Contains deployment setups, workers running in GKE, Cloud Functions, and the user-facing website and API.

1. API Server (go/cmd/api/)

  • Status: Active (Go).
  • Serves the public OSV gRPC API server (transcoded to HTTP/JSON REST via ESPv2).
  • Deployment Target: Google Cloud Run (managed via Cloud Deploy pipeline osv-api deploying to osv-grpc-backend).
  • Note: Fully migrated from Python to Go. Protobuf definitions and descriptor files are located under proto/v1/.

2. Website (go/cmd/website/, website/)

  • Status: Active (Go).
  • Fully migrated to Go backend under go/cmd/website/ and go/internal/website/. Frontend assets (Hugo blog, pnpm frontend3) are located under website/.
  • Deployment Target: Google Cloud Run (managed via Cloud Deploy pipeline osv-website).

3. Workers (gcp/workers/)

  • worker (gcp/workers/worker/): Base Environment. Retains shared Poetry dependencies and base Dockerfile for legacy Python workers; legacy worker daemon replaced by Go worker under go/cmd/worker/.
  • ClusterFuzz Worker (gcp/workers/oss_fuzz_worker/, gcp/workers/oss_fuzz_importer/): Barely Maintained. Siloed workloads for OSS-Fuzz integration.
    • Deployment Target: GKE (managed via Cloud Deploy pipeline oss-fuzz-workers).

4. Indexer (gcp/indexer/)

  • Status: Active (Go).
  • Handles indexing, but is not under active development.
  • Deployment Target: GKE (managed via Cloud Deploy pipeline gke-indexer).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.