feat(8246): the code index links each test to what it guards, and can say redundant or unused
CI & Build / Plugin hooks (push) Successful in 20s
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 41s
CI & Build / Python tests (push) Failing after 2m8s
CI & Build / integration (push) Successful in 2m24s
CI & Build / Build & push image (push) Skipped
CI & Build / Plugin hooks (push) Successful in 20s
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 41s
CI & Build / Python tests (push) Failing after 2m8s
CI & Build / integration (push) Successful in 2m24s
CI & Build / Build & push image (push) Skipped
Every coverage refresh now reads, for each test in a bound repo, which product shapes its body exercises: through module aliases and imports, following test helpers, with mocked names left out and shapes most test files reach dropped as hubs. Tests in different files that guard exactly the same set form a group. The project page lists the groups and a person can mark one test redundant, naming the test that covers it, or keep them all with a reason. Agents get test_guard_groups and review_test_group, and classify_shapes takes the two new removal verdicts, redundant (with covered_by) and unused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
"""code_shape_guards, code_shape_guard_reviews, and the removal verdicts
|
||||
|
||||
Revision ID: 0140
|
||||
Revises: 0139
|
||||
Create Date: 2026-12-01
|
||||
|
||||
What each test guards, read by the coverage sync from the repo archive, so
|
||||
the ledger can show tests that guard the same thing from different files:
|
||||
- code_shape_guards: test shape -> guarded shape, or -> a repo path.
|
||||
Mechanical, rebuilt by every sync, not backed up.
|
||||
- code_shape_guard_reviews: a group judged to be distinct behaviours.
|
||||
- code_shapes.covered_by_id: the shape a `redundant` row is covered by.
|
||||
- code_shapes.test_signals: a test's weak-test signals from the last sync.
|
||||
The statuses `redundant` and `unused` need no schema change: status is a
|
||||
plain text column.
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "0140"
|
||||
down_revision = "0139"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column("code_shapes", sa.Column(
|
||||
"covered_by_id", sa.Integer(),
|
||||
sa.ForeignKey("code_shapes.id", ondelete="SET NULL"), nullable=True,
|
||||
))
|
||||
op.add_column("code_shapes", sa.Column(
|
||||
"test_signals", sa.Text(), nullable=False, server_default="",
|
||||
))
|
||||
op.create_table(
|
||||
"code_shape_guards",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("test_id", sa.Integer(), sa.ForeignKey("code_shapes.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("guarded_id", sa.Integer(), sa.ForeignKey("code_shapes.id", ondelete="CASCADE"), nullable=True),
|
||||
sa.Column("path", sa.Text(), nullable=True),
|
||||
sa.Column("basis", sa.Text(), nullable=False, server_default="static"),
|
||||
)
|
||||
op.create_index("ix_code_shape_guards_test", "code_shape_guards", ["test_id"])
|
||||
op.create_index("ix_code_shape_guards_guarded", "code_shape_guards", ["guarded_id"])
|
||||
op.create_table(
|
||||
"code_shape_guard_reviews",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("project_id", sa.Integer(), sa.ForeignKey("projects.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("group_key", sa.Text(), nullable=False),
|
||||
sa.Column("verdict", sa.Text(), nullable=False, server_default="distinct"),
|
||||
sa.Column("reason", sa.Text(), nullable=False, server_default=""),
|
||||
sa.Column("reviewed_by", sa.Text(), nullable=False),
|
||||
sa.Column("reviewed_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.text("now()")),
|
||||
sa.UniqueConstraint("project_id", "group_key", name="uq_code_shape_guard_reviews_group"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table("code_shape_guard_reviews")
|
||||
op.drop_index("ix_code_shape_guards_guarded", table_name="code_shape_guards")
|
||||
op.drop_index("ix_code_shape_guards_test", table_name="code_shape_guards")
|
||||
op.drop_table("code_shape_guards")
|
||||
op.drop_column("code_shapes", "test_signals")
|
||||
op.drop_column("code_shapes", "covered_by_id")
|
||||
Reference in New Issue
Block a user