Skip to content

feat(drift): check dependency claims against pyproject.toml - #185

Open
abhinav-phi wants to merge 1 commit into
mex-memory:mainfrom
abhinav-phi:feat/pyproject-dependency-parsing
Open

feat(drift): check dependency claims against pyproject.toml#185
abhinav-phi wants to merge 1 commit into
mex-memory:mainfrom
abhinav-phi:feat/pyproject-dependency-parsing

Conversation

@abhinav-phi

Copy link
Copy Markdown
Contributor

Resolves #3 (pyproject.toml only, per the issue's one-ecosystem-at-a-time note — Cargo.toml and go.mod remain follow-ups).

Problem

loadAllDependencies in src/drift/checkers/dependency.ts read only package.json files, so Python dependency claims — FastAPI, Celery, SQLAlchemy — were reported DEPENDENCY_MISSING whenever the project declared them in pyproject.toml instead.

What

A bounded line-scan parser (no TOML library) covering exactly the shapes a claim checker needs:

  • [project]dependencies = [...] (PEP 621)
  • [project.optional-dependencies] → per-extra arrays
  • [tool.poetry.dependencies] → key-value pairs (Poetry)
  • PEP 508 specs (celery[redis]==5.4.0) parse to the base package name; the raw specifier rides along as version evidence, which keeps the existing substring-based VERSION_MISMATCH logic working unchanged.

Deliberately out of scope: dynamic declarations (dynamic = ["dependencies"]), inline-table arrays spanning lines, and everything else in the file — the checker needs name identity, not a full TOML model. requires-python/python keys are skipped (interpreter constraints, not packages).

Tests

Two new cases in test/checkers.test.ts: claims checked against [project].dependencies (missing one still reported), and optional-dependencies + Poetry tables read with python correctly skipped. Existing 95 checker tests pass; npm run typecheck green.

loadAllDependencies read only package.json files, so Python dependency
claims (FastAPI, Celery, SQLAlchemy...) were reported as
DEPENDENCY_MISSING whenever the project declared them in
pyproject.toml instead.

Add a bounded line-scan parser over the shapes a claim checker needs:
the dependencies array inside [project], per-extra arrays in
[project.optional-dependencies], and key-value pairs in
[tool.poetry.dependencies]. No TOML dependency — the package name is
the identity and the raw version specifier rides along as evidence.
PEP 508 extras (celery[redis]) parse to the base package name.

Per the issue's one-ecosystem-at-a-time guidance, this ships pyproject
only; Cargo.toml and go.mod stay stubs for a follow-up.

Resolves mex-memory#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add real dependency parsing for pyproject.toml, Cargo.toml, go.mod

1 participant