#374 follow-up: the "never wipe a foreign DB" check is too weak — a DB with our five generic table names plus its own data is reset #383

Closed
opened 2026-10-15 15:37:52 +02:00 by buildagent · 1 comment
Member

Found by the 2026-10-15 spec review; this one is mine, from #374.

  • The promise: the v0.38.0 release notes say "A database at --db that code-index did not create is refused and left untouched. It is never wiped."
  • The code: schema.rs ~180 decides a database is ours when it has the five tables schema_version, files, symbols, refs and imports, or one lone empty schema_version.
  • Live repro: a database with those five tables (schema_version = 3) plus a customer_data table holding a row. code-index index --db reset it, and customer_data was gone.

Direction

Ownership must be positive evidence:

  • Refuse a reset if ANY table, index or trigger exists outside the closed set of names some schema version of code-index has created (one constant list, pinned by a test against schema.sql).
  • Also refuse unknown triggers on open (see the security hardening issue).

The newer-schema hint (schema_newer_message, server.rs ~4160) tells users to delete .code-index/. That destroys workspace-id and every durable handle. Use schema::recovery_hint, which deletes index.db only.

Found by the 2026-10-15 spec review; this one is mine, from #374. - **The promise:** the v0.38.0 release notes say "A database at `--db` that code-index did not create is refused and left untouched. It is never wiped." - **The code:** `schema.rs` ~180 decides a database is ours when it has the five tables `schema_version`, `files`, `symbols`, `refs` and `imports`, or one lone empty `schema_version`. - **Live repro:** a database with those five tables (`schema_version` = 3) plus a `customer_data` table holding a row. `code-index index --db` reset it, and `customer_data` was gone. ## Direction Ownership must be positive evidence: - Refuse a reset if ANY table, index or trigger exists outside the closed set of names some schema version of code-index has created (one constant list, pinned by a test against `schema.sql`). - Also refuse unknown triggers on open (see the security hardening issue). ## Related The newer-schema hint (`schema_newer_message`, server.rs ~4160) tells users to delete `.code-index/`. That destroys `workspace-id` and every durable handle. Use `schema::recovery_hint`, which deletes `index.db` only.
Author
Member

Released in v0.40.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.40.0, PR #388, merge a48fb945): an index is reset only when every table, index, trigger and view in it is one code-index created (anything else is refused and left byte-identical); SQLite never trusts the opened database's schema; .code-index/ must be a real directory owned by the user with no links inside; state files are written durably. The Windows CI round found one more race in the link walk (a delete-pending file reads as "access denied"); fixed in 960f4704 before the merge.

Released in v0.40.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.40.0, PR #388, merge a48fb945): an index is reset only when every table, index, trigger and view in it is one code-index created (anything else is refused and left byte-identical); SQLite never trusts the opened database's schema; `.code-index/` must be a real directory owned by the user with no links inside; state files are written durably. The Windows CI round found one more race in the link walk (a delete-pending file reads as "access denied"); fixed in 960f4704 before the merge.
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#383
No description provided.