sqlite: SAFETY comments on the substrate UDF get_connection blocks (D-40)

Review 004 item 15: the unsafe { ctx.get_connection() } UDF blocks
carried no SAFETY justification. Added the concrete soundness
invariant at all ten sites (the eight attach_alkstore_functions
registrations, the notify registration, the test-module savepoint
probe — same class) and registered the comment-only change as
PROVENANCE delta D-40 per ADR-012 §3's diff-fidelity posture.

Task: sqlite-substrate-safety-comments
This commit is contained in:
glm-5.3-flash committed 2026-10-11 11:23:45 +00:00
1 parent 9a9ccf26e0
commit c60193ad5c
4 files changed
+129 -3

No files matched your search

+28 -3
View File
@@ -1,7 +1,7 @@
---
id: sqlite-substrate-safety-comments
name: SAFETY comments on the substrate UDF blocks, riding a PROVENANCE delta (review 004 item 15)
status: pending
status: completed
depends_on: []
scope: narrow
risk: low
@@ -64,8 +64,33 @@ if not, leave them and record why.
## Notes
> To be filled by implementation agent
- Same-class neighbors **included**: `schema.rs:104` (the `notify`
registration in `attach_notify`) and `ops.rs`'s test-module scalar
probe (`a_panicking_savepoint_body_leaves_no_frame_on_the_scalar_path`)
are the identical rusqlite UDF shape — registered on one connection,
invoked only synchronously inside that connection's statement
evaluation — so both joined the delta; all **ten** sites carry the
comment.
- The comment states the concrete invariant, derived from rusqlite
0.40's `Context::get_connection` contract (functions.rs; the issue
#643 analysis behind its unsafety): the rebuilt `ConnectionRef`
could alias a cross-thread access or outlive the callback — neither
reachable here (each connection one-thread-at-a-time: rusqlite
`Connection` is !Sync, the reader pool transfers owned connections,
the writer lease is exclusive; the closure consumes the deref'd
reference only within the callback's lifetime).
- Delta registered as **D-40** in `PROVENANCE.md`, category `hygiene`
(comment-only, zero behavior change) — the deliberate exception to
D-15's comment elision, riding a delta per ADR-012 §3.
## Summary
> To be filled on completion
Added uniform `// SAFETY` comments at all ten `unsafe {
ctx.get_connection() }` UDF sites (the eight review-scoped blocks in
`attach_alkstore_functions`, plus the same-class `notify` registration
and the test-module savepoint-panic probe) and registered the
comment-only change as PROVENANCE delta D-40. Verified: `cargo test`
workspace green (alkstore-sqlite 203 passed, all crates green
unchanged), `cargo clippy --all-targets -- -D warnings` clean,
`cargo fmt --check` clean, `cargo build` green, fuzz gate
(`fuzz/shared`) green — comment-only diff, no behavior change.