fix(6477): a body uses a canon by name only when the name can resolve to it
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 43s
CI & Build / integration (push) Successful in 1m36s
CI & Build / Python tests (push) Successful in 2m7s
CI & Build / Build & push image (push) Successful in 42s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 43s
CI & Build / integration (push) Successful in 1m36s
CI & Build / Python tests (push) Successful in 2m7s
CI & Build / Build & push image (push) Successful in 42s
The proposer's reference basis, and every uses edge it writes, counted any word-bounded mention of a canon's symbol. Three holes made that wrong at scale (snippet #5448, symbol `file`, held 2,161 uses edges): - Go, Rust, Kotlin, Swift, Dart, C, C#, Ruby and PHP were outside the language-family maps, so their canons read as "unknown, no gate" and were matched in every Python, TS and CSS body. - Canons in other projects were matched by name, though one repo never calls a function defined in another's. - A plain word (`file`, `seen`) or a module's own helper (`_run`) matched wherever it appeared. names_canon is now the one by-name test, used by match_canon, reference_canons and the write-path hint: same project, not a name the file defines itself (unless the canon is recorded there), no generic verb with or without a leading underscore, and a bare lowercase word only where it is called. The write path keeps the payload's own names in play, since a redefinition of a pulled canon is the copy it exists to flag. Repair: record_uses only adds, so replace_reference_uses now makes a row's machine-written reference edges exactly what the current rule finds, leaving judged and hook edges alone. _PROPOSER_VERSION 7 re-reads every row on its project's next refresh. Migration 0125 deletes the cross-project reference edges already stored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""drop machine-written uses edges that cross projects
|
||||
|
||||
Revision ID: 0125
|
||||
Revises: 0124
|
||||
Create Date: 2026-10-26
|
||||
|
||||
A `uses` edge with basis `reference` is the proposer's by-name reading: the
|
||||
shape's body names a canon's symbol. A body never calls a function defined in
|
||||
another project's repository, so such an edge across projects is a common
|
||||
word matched, not a call. The proposer no longer writes them, and this removes
|
||||
the ones it wrote before. Edges a person or an audit judged keep their own
|
||||
basis and are left alone. Rows within one project are re-read on the next
|
||||
coverage refresh, which replaces their reference edges under the same rule.
|
||||
|
||||
Downgrade restores nothing: the removed edges were never facts.
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
revision = "0125"
|
||||
down_revision = "0124"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
"DELETE FROM code_shape_uses u USING code_shapes s, notes n "
|
||||
"WHERE u.shape_id = s.id AND u.snippet_id = n.id "
|
||||
"AND u.basis = 'reference' "
|
||||
"AND n.project_id IS NOT NULL AND n.project_id <> s.project_id"
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
Reference in New Issue
Block a user