Skip to content

fix(store): ADR sidecar follow-ups from #2315 review - #2864

Merged
DeusData merged 1 commit into
mainfrom
fix/adr-sidecar-followups
Oct 31, 2026
Merged

DeusData merged 1 commit into
mainfrom
fix/adr-sidecar-followups

Conversation

@DeusData

Copy link
Copy Markdown
Owner

Summary

Follow-up to #2315: the three small points we said we would handle ourselves
in the 2026-09-28 review. No behaviour change beyond the new log line.

  1. A failed ADR restore on import is no longer silent (src/pipeline/artifact.c).
    After the imported graph DB is installed, cbm_artifact_import restores the
    artifact ADR into the .adr.db sidecar. A failed reopen and a failed
    cbm_store_adr_restore_from_graph_if_absent were both discarded, so a team
    ADR that never arrived left no trace. The restore now lives in
    artifact_import_restore_adr and logs
    level=warn msg=artifact.import err=adr_restore detail= path=.
    The import still returns 0: the graph DB is already installed and the
    restore stays best-effort. adr_restore_if_absent now sets the store error
    for its begin, copy and commit failures, so the detail names the step.
  2. Misplaced doc comment (src/store/store.c). The comment that describes
    adr_copy_legacy_once sat above adr_copy_rows, stacked on top of the comment
    that documents adr_copy_rows. It now sits above adr_copy_legacy_once.
  3. Dead marker insert (src/store/store.c). adr_restore_if_absent ran
    INSERT OR IGNORE INTO adr_meta (migrated), but its handle always comes from
    adr_conn_write, which hands out a sidecar handle only after
    adr_copy_legacy_once has committed that marker, and nothing deletes it.
    The insert always hit the existing key (its result was discarded too),
    so it is removed.

Test plan

  • New artifact_import_logs_failed_adr_restore: a directory at .adr.db
    (the hook-free trick from fix(pipeline): preserve concurrent manage_adr write across reindex swap #2315) makes the sidecar open fail. Asserts the
    import still returns 0, the graph DB is installed, and the warn line
    carries the store reason. Red without the artifact.c change, green with it.
  • artifact_export_roundtrip_keeps_adr now also asserts that the fresh
    destination sidecar is marked migrated after an import, the invariant
    item 3 relies on.
  • macOS: artifact 30/30, store_arch and the other store suites, pipeline 436,
    mcp 399, incremental 164, httpd 95, cli 373, daemon_application 91 - all
    green (only the existing Windows-only platform skips).
  • clang-format (Homebrew LLVM) clean on the touched src files, cppcheck 2.20
    clean, memory-core ratchet unchanged (no file grew), NOLINT gate clean.

Refs #2315. Follow-up to #2315 by @0xb007ab1e - thank you again for the
sidecar design and for carrying it through every review round.

Three small items promised in the #2315 review; behaviour is otherwise
unchanged.

1. A failed ADR restore on artifact import is no longer silent
   (src/pipeline/artifact.c). The import dropped both a failed reopen of
   the installed DB and the status of
   cbm_store_adr_restore_from_graph_if_absent, so a team ADR that never
   reached the sidecar left no trace. The restore moves into
   artifact_import_restore_adr, which logs
   level=warn msg=artifact.import err=adr_restore detail=<store error>
   path=<db> on either failure. The import still returns 0: the graph DB
   is already installed when the restore runs, and the restore stays
   best-effort as documented. adr_restore_if_absent now sets the store
   error for its begin, copy and commit failures, so the logged detail
   names the failing step.

2. The doc comment of adr_copy_legacy_once sat above adr_copy_rows,
   stacked on top of the comment that documents adr_copy_rows, which left
   adr_copy_legacy_once undocumented. It now sits above
   adr_copy_legacy_once (src/store/store.c).

3. adr_restore_if_absent no longer inserts the migrated marker. That
   INSERT OR IGNORE could never change state. Its only caller,
   cbm_store_adr_restore_from_graph_if_absent, takes the sidecar handle
   from adr_conn_write, which hands out a handle (cached or fresh) only
   after adr_copy_legacy_once returned OK, and that function returns OK
   only when the marker row is already committed (fast path, or the
   re-check under the write lock) or it just inserted and committed it.
   No code deletes an adr_meta row, so the insert hit the existing
   primary key every time, and its result was discarded anyway.

Tests: artifact_import_logs_failed_adr_restore puts a directory at
<db>.adr.db (the hook-free trick from the #2315 pipeline test), then
asserts the import still succeeds, the graph DB is installed, and the
warn line carries the store reason. It is red without the artifact.c
change. artifact_export_roundtrip_keeps_adr now also asserts that the
fresh destination sidecar is marked migrated after the import, which
pins the invariant item 3 relies on.

Refs #2315

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData
DeusData merged commit c07cb8e into main Oct 31, 2026
28 checks passed
@DeusData
DeusData deleted the fix/adr-sidecar-followups branch October 31, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant