feat: refactor preflight — safe_delete + check_rename #25

Closed
opened 2026-07-20 22:38:07 +02:00 by buildagent · 1 comment
Member

Rank 4 of the 2026-07-20 index-data brainstorm (_prdoc/records/brainstorm-2026-07-20-index-data-catalog.md).

What: two checked-transaction tools for the riskiest agent edits. safe_delete(symbol): typed refs + name fallbacks + trigram-FTS pass for string-embedded references + newly-orphaned-callee cascade preview. check_rename(old, new): collision and ambiguity-injection detection before compile time — critical for the 4 dynamic languages with no compiler backstop.

Why — the killer case: roles_is_zero (daemon local_index.rs) has ref_count=0 and zero edges — every ref-based detector calls it dead — but FTS finds it inside #[serde(skip_serializing_if = "roles_is_zero")]; deleting it compiles and silently breaks serialization. Rename side: new has 18 same-name symbols, parse 11 — collision injection is a real hazard. Validated: try_resolve→resolve clean (0 collisions, 3-ref edit manifest); Writer::upsert_file verdict "safe, doc update at writer.rs:3" (exactly what v0.5.19 did manually).

Cost: small — 3-4 indexed queries per call (refs by target, refs by name, files_fts MATCH, symbol_edges CTE); no new data.

Rank 4 of the 2026-07-20 index-data brainstorm (`_prdoc/records/brainstorm-2026-07-20-index-data-catalog.md`). **What**: two checked-transaction tools for the riskiest agent edits. `safe_delete(symbol)`: typed refs + name fallbacks + **trigram-FTS pass for string-embedded references** + newly-orphaned-callee cascade preview. `check_rename(old, new)`: collision and ambiguity-injection detection before compile time — critical for the 4 dynamic languages with no compiler backstop. **Why — the killer case**: `roles_is_zero` (daemon local_index.rs) has ref_count=0 and zero edges — every ref-based detector calls it dead — but FTS finds it inside `#[serde(skip_serializing_if = "roles_is_zero")]`; deleting it compiles and silently breaks serialization. Rename side: `new` has 18 same-name symbols, `parse` 11 — collision injection is a real hazard. Validated: `try_resolve→resolve` clean (0 collisions, 3-ref edit manifest); `Writer::upsert_file` verdict "safe, doc update at writer.rs:3" (exactly what v0.5.19 did manually). **Cost**: small — 3-4 indexed queries per call (refs by target, refs by name, files_fts MATCH, symbol_edges CTE); no new data.
Author
Member

Shipped in v0.6.0 (I030 Track B) as safe_delete + check_rename. Evidence tools with stable severity-ordered reason codes and a contractual never-say-"safe": resolved refs with prod/test split, string evidence via trigram-FTS candidates word-boundary-verified against stored content (the defining-file serde case surfaces — unit-tested on the roles_is_zero shape), dark-channel disclosure for sub-3-char names, newly-orphaned callees, scoped collisions (PHP case-insensitive), ambiguity-injection counts, full edit manifests, every cap honest. Bench: delete-prep = 1 call / 1.2KB surfacing 6 refs + 8 string files on this repo.

Shipped in **v0.6.0** (I030 Track B) as `safe_delete` + `check_rename`. Evidence tools with stable severity-ordered reason codes and a contractual never-say-"safe": resolved refs with prod/test split, string evidence via trigram-FTS candidates **word-boundary-verified** against stored content (the defining-file serde case surfaces — unit-tested on the `roles_is_zero` shape), dark-channel disclosure for sub-3-char names, newly-orphaned callees, scoped collisions (PHP case-insensitive), ambiguity-injection counts, full edit manifests, every cap honest. Bench: delete-prep = 1 call / 1.2KB surfacing 6 refs + 8 string files on this repo.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
h-dv/code-index#25
No description provided.