Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ valk-guard-example/
Workflow install target is configured as:

```text
github.com/valkdb/valk-guard/cmd/valk-guard@latest
github.com/valkdb/valk-guard/cmd/valk-guard.0.0-20260304065917-b9d9468a4ea3@latest
```

Rationale:

- This repository is a demo showcase; tracking latest keeps examples aligned with current built-in behavior.
- If you need strict reproducibility, pin a fixed tag in workflow `VALK_GUARD_INSTALL_REF`.
- This repository is a demo showcase, but CI is pinned to a known-good valk-guard build to keep output shape stable.
- Pinning avoids format drift that can break downstream tooling steps (for example: `Convert to reviewdog format`).
- When upgrading, bump `VALK_GUARD_INSTALL_REF` intentionally and verify the full workflow output.

## Creating Demo PRs (one rule at a time)

Expand Down
17 changes: 17 additions & 0 deletions demo/violations/dist3-vg007-008-101-105/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Dist 3: VG007, VG008, VG101-VG105

This demo bundle intentionally triggers:

- VG007 (destructive DDL)
- VG008 (non-concurrent index)
- VG101 (model column missing in migration)
- VG102 (required migration column missing in model)
- VG103 (model/migration type mismatch)
- VG104 (explicit model table not found)
- VG105 (unknown projection column)

Coverage in this bundle:

- SQL migrations and SQL queries
- Python ORM models (schema drift)
- Python non-ORM query execution
32 changes: 32 additions & 0 deletions demo/violations/dist3-vg007-008-101-105/python/orm_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import DeclarativeBase


class Base(DeclarativeBase):
pass


class VG101User(Base):
__tablename__ = "vg101_users"

id = Column(Integer, primary_key=True)
ghost_col = Column(String(64))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚫 [valk-guard] reported by reviewdog 🐶
VG101: model "vg101_users" references column "ghost_col" not found in table "vg101_users" schema; check migration DDL or update model mapping



class VG102Account(Base):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ [valk-guard] reported by reviewdog 🐶
VG102: table "vg102_accounts" has NOT NULL column "required_code" but model "vg102_accounts" does not define it; add the field or make the migration column nullable/defaulted

__tablename__ = "vg102_accounts"

id = Column(Integer, primary_key=True)


class VG103Order(Base):
__tablename__ = "vg103_orders"

id = Column(Integer, primary_key=True)
total = Column(String(32))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ [valk-guard] reported by reviewdog 🐶
VG103: column "total" type mismatch: model has "String(32)" but migration has "NUMERIC(10,2)"; align model type or migration column type



class VG104AuditEvent(Base):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚫 [valk-guard] reported by reviewdog 🐶
VG104: table "vg104_audit_events" referenced by model has no CREATE TABLE in migrations; add migration DDL or fix TableName()

__tablename__ = "vg104_audit_events"

id = Column(Integer, primary_key=True)
6 changes: 6 additions & 0 deletions demo/violations/dist3-vg007-008-101-105/python/raw_queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from sqlalchemy import text
from sqlalchemy.orm import Session


def raw_unknown_projection_column(session: Session):
return session.execute(text("SELECT vg105_users.ghost_col FROM vg105_users LIMIT 1")).all()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚫 [valk-guard] reported by reviewdog 🐶
VG105: projection column "ghost_col" not found in table "vg105_users" schema; check SELECT list and schema/model mappings | Query: SELECT vg105_users.ghost_col FROM vg105_users LIMIT 1

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE vg101_users;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚫 [valk-guard] reported by reviewdog 🐶
VG007: destructive DDL detected: DROP TABLE vg101_users | Query: DROP TABLE vg101_users

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX idx_vg105_users_email_bad ON vg105_users(email);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ [valk-guard] reported by reviewdog 🐶
VG008: CREATE INDEX idx_vg105_users_email_bad without CONCURRENTLY may block writes; add CONCURRENTLY | Query: CREATE INDEX idx_vg105_users_email_bad ON vg105_users(email)

18 changes: 18 additions & 0 deletions demo/violations/dist3-vg007-008-101-105/sql/vg_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE vg101_users (
id INTEGER PRIMARY KEY
);

CREATE TABLE vg102_accounts (
id INTEGER PRIMARY KEY,
required_code TEXT NOT NULL
);

CREATE TABLE vg103_orders (
id INTEGER PRIMARY KEY,
total NUMERIC(10,2) NOT NULL
);

CREATE TABLE vg105_users (
id INTEGER PRIMARY KEY,
email TEXT NOT NULL
);