Skip to content

feat(obd_ai): add foundation layer and approved command catalog - #10

Open
virtuscyber wants to merge 1 commit into
masterfrom
feature/1-obd-ai-foundation
Open

virtuscyber wants to merge 1 commit into
masterfrom
feature/1-obd-ai-foundation

Conversation

@virtuscyber

Copy link
Copy Markdown
Owner

Refs #1

This opens the foundation lane for the LLM-safe OBD diagnostics stack.

Includes:

  • OBDAISession foundation
  • approved command catalog and safety filtering
  • initial package surface for follow-on lanes

Stack order: #1 -> #2 -> #3 -> #4 -> #5

@augmentcode

augmentcode Bot commented Apr 11, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR introduces a new obd_ai foundation layer to provide LLM-safe, read-only access patterns on top of the existing obd library.

Changes:

  • Added the obd_ai package surface and exports (obd_ai/__init__.py)
  • Implemented an immutable ApprovedCommandCatalog that maps curated public keys to concrete obd.commands.* instances (obd_ai/catalog.py)
  • Defined an MVP read-only approved command set (RPM, speed, temps, DTC reads, VIN, etc.) and a default catalog singleton
  • Added OBDAISession as a constrained wrapper around an obd.OBD connection, exposing only catalog-approved queries (obd_ai/session.py)
  • Added OBDAISessionManager to create/wrap sessions and support dependency injection via an obd_factory for testing
  • Added unit tests covering catalog mapping/immutability and session delegation/safety checks (tests/test_obd_ai_catalog.py, tests/test_obd_ai_session.py)

Technical Notes: The catalog is enforced via key-based lookups and uses MappingProxyType + frozen dataclasses to keep the approved surface read-only.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

assert "stored_trouble_codes" in catalog
assert "pending_trouble_codes" in catalog
assert "clear_trouble_codes" not in catalog
assert "CLEAR_DTC" not in catalog

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/test_obd_ai_catalog.py:23 — "CLEAR_DTC" not in catalog is checking membership by approved key, but ApprovedCommandCatalog.__contains__ only looks at approved keys (e.g., clear_trouble_codes), not OBD command names. As written, this assertion doesn’t actually validate that the write command is excluded and may give a false sense of safety coverage.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

1 participant