Skip to content

Op-authoring helper + full backfill of existing memories (phase B, unwired)#526

Merged
skakri merged 1 commit into
mainfrom
feat/oplog-authoring
Jul 9, 2026
Merged

Op-authoring helper + full backfill of existing memories (phase B, unwired)#526
skakri merged 1 commit into
mainfrom
feat/oplog-authoring

Conversation

@skakri

@skakri skakri commented Jul 8, 2026

Copy link
Copy Markdown
Member

Seventh phase-B op-log increment, after #480/#489/#495/#497/#500/#503/#504/#509/#511/#513/#523. Freezes the machinery that turns memories into signed log entries — the minting primitive, the row→op translation, and the one-time full backfill — WITHOUT touching the live memory write path.

What landed

  • store::author_op / store::author_batch — mint entries by allocating the next Lamport from the (stream, device) chain tail, signing, and inserting. author_op is one op in its own IMMEDIATE txn; author_batch is a whole sequence in ONE atomic txn (an interrupted backfill rolls back and re-runs clean) with a single projection re-fold at the end. append's reproject branch is factored into a shared reproject_after_write helper. The primitives take a &LocalDevice, so DeviceSecret stays oplog-private.
  • oplog's first crate-internal API surface — a curated pub(crate) re-export in oplog/mod.rs (the minting fns + the op vocabulary). Every submodule is otherwise private, so this is the ONE seam query::memory reaches through — and the only direction of the dependency (oplog never depends back on query::memory, which the next increment's reverse call would otherwise cycle).
  • query::memory::authoring — translates a memory into NodeCreate [+ NodeStatus when non-active] [+ EdgeAdd per outgoing typed node-edge, in edge_key order]. Code-anchor bindings stay out of the log: they are per-device derived resolution state, re-validated locally, never part of the shared node graph. backfill_memory_oplog authors every one of the active repo's memories into its owner stream — idempotent (a completed atomic batch leaves a non-empty chain, so a re-run is a no-op), scope-gated (a no-op on an unscoped DB), deterministically ordered (created_at_ms, id). The log becomes the complete signed history from genesis.

Still not wired to the live write path — mod oplog stays dead-code-allowed. The next increment calls backfill_memory_oplog + author_op inside each mutation's transaction (making create_memory/update_memory transactional), and reuses memory_to_ops for the mutations themselves.

Tests / gates

  • store: author_op mints a genesis→1→2 chain and projects; author_batch writes N ops in one txn with sequential lamports (empty batch is a no-op; continues a non-empty chain).
  • authoring: memory_to_ops translates content + non-active status + edges in order; end-to-end backfill over a 3-memory fixture (one obsolete, one edge) yields 3 projected nodes + the right status + the edge, and a second backfill is a no-op; unscoped and empty-repo backfills are no-ops.
  • Full workspace suite green (2040 tests), clippy clean on default and --no-default-features, nightly fmt clean.

Fixes #524

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

SCIP oracle — resolution report

Heuristic→compiler edge resolution per corpus. Δ compares resolved-after to the main baseline (only when the corpus profile + tool version match).

corpus tool edges resolved (heuristic → compiler) precision recall monikers Δ vs main
c-libuv scip-clang 12283 37.8% → 47.8% 89.3% 48.7% 679 +0.0pp
cpp-yaml scip-clang 9223 43.2% → 73.1% 83.1% 40.3% 1038 +0.0pp
py-django scip-python 12937 29.8% → 73.5% 93.7% 84.1% 3036 +0.0pp
py-rich scip-python 8383 27.6% → 92.3% 95.0% 81.3% 1098 +0.0pp
rust-time rust-analyzer 11040 37.5% → 58.7% 68.7% 83.6% 510 +0.0pp
ts-rxjs scip-typescript 7875 39.6% → 94.9% 87.3% 77.4% 626 +0.0pp

resolved = Exact/Syntactic + compiler upgrades + resolved-external, over edge candidates with a callee range. precision/recall are the oracle eval metrics.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Branchfeat/oplog-authoring
Testbedubuntu-latest

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

🚨 3 Alerts

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
rag_pipeline::pipeline::index cargo_resolver:resolver_config()Instructions
instructions x 1e9
📈 plot
🚷 threshold
🚨 alert (🔔)
1.67 x 1e9
(+59.50%)Baseline: 1.05 x 1e9
1.07 x 1e9
(156.37%)

rag_pipeline::pipeline::query_cold cargo_resolver:resolver_built_config()Instructions
instructions x 1e6
📈 plot
🚷 threshold
🚨 alert (🔔)
232.30 x 1e6
(+19.23%)Baseline: 194.83 x 1e6
198.73 x 1e6
(116.89%)

rag_pipeline::pipeline::query_warm cargo_resolver:resolver_index()Instructions
instructions x 1e6
📈 plot
🚷 threshold
🚨 alert (🔔)
224.07 x 1e6
(+18.79%)Baseline: 188.62 x 1e6
192.40 x 1e6
(116.46%)

Click to view all benchmark results
BenchmarkEstimated Cyclescycles x 1e6InstructionsBenchmark Result
instructions x 1e6
(Result Δ%)
Upper Boundary
instructions x 1e6
(Limit %)
L1 Hitshits x 1e6LL Hitshits x 1e6RAM Hitshits x 1e3Total read+writereads/writes x 1e6
rag_pipeline::pipeline::index cargo_resolver:resolver_config()📈 view plot
⚠️ NO THRESHOLD
2,542.34 x 1e6📈 view plot
🚷 view threshold
🚨 view alert (🔔)
1,669.90 x 1e6
(+59.50%)Baseline: 1,046.98 x 1e6
1,067.92 x 1e6
(156.37%)

📈 view plot
⚠️ NO THRESHOLD
2,279.33 x 1e6📈 view plot
⚠️ NO THRESHOLD
43.63 x 1e6📈 view plot
⚠️ NO THRESHOLD
1,281.87 x 1e3📈 view plot
⚠️ NO THRESHOLD
2,324.24 x 1e6
rag_pipeline::pipeline::query_cold cargo_resolver:resolver_built_config()📈 view plot
⚠️ NO THRESHOLD
349.44 x 1e6📈 view plot
🚷 view threshold
🚨 view alert (🔔)
232.30 x 1e6
(+19.23%)Baseline: 194.83 x 1e6
198.73 x 1e6
(116.89%)

📈 view plot
⚠️ NO THRESHOLD
333.70 x 1e6📈 view plot
⚠️ NO THRESHOLD
2.96 x 1e6📈 view plot
⚠️ NO THRESHOLD
27.14 x 1e3📈 view plot
⚠️ NO THRESHOLD
336.68 x 1e6
rag_pipeline::pipeline::query_warm cargo_resolver:resolver_index()📈 view plot
⚠️ NO THRESHOLD
336.87 x 1e6📈 view plot
🚷 view threshold
🚨 view alert (🔔)
224.07 x 1e6
(+18.79%)Baseline: 188.62 x 1e6
192.40 x 1e6
(116.46%)

📈 view plot
⚠️ NO THRESHOLD
321.92 x 1e6📈 view plot
⚠️ NO THRESHOLD
2.82 x 1e6📈 view plot
⚠️ NO THRESHOLD
24.98 x 1e3📈 view plot
⚠️ NO THRESHOLD
324.76 x 1e6
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Branchfeat/oplog-authoring
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
seconds (s)
(Result Δ%)
Upper Boundary
seconds (s)
(Limit %)
index_time/full_rebuild_cargo📈 view plot
🚷 view threshold
5.49 s
(-2.12%)Baseline: 5.61 s
7.93 s
(69.31%)
🐰 View full continuous benchmarking report in Bencher

@skakri

skakri commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f48f45083c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rag-rat-core/src/query/memory/authoring.rs Outdated
Comment thread crates/rag-rat-core/src/oplog/mod.rs Outdated
Comment thread crates/rag-rat-core/src/query/memory/authoring.rs
Comment thread crates/rag-rat-core/src/oplog/store.rs
@skakri skakri force-pushed the feat/oplog-authoring branch from f48f450 to 6a20c9c Compare July 9, 2026 07:04
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.51691% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/rag-rat-core/src/query/memory/authoring.rs 99.22% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a20c9c7c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rag-rat-core/src/query/memory/authoring.rs Outdated
Comment thread crates/rag-rat-core/src/query/memory/authoring.rs
@skakri skakri force-pushed the feat/oplog-authoring branch from 6a20c9c to 26b3681 Compare July 9, 2026 07:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26b36811a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rag-rat-core/src/query/memory/authoring.rs
@skakri skakri force-pushed the feat/oplog-authoring branch from 26b3681 to 38d08f8 Compare July 9, 2026 07:58
@skakri

skakri commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38d08f82ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +134 to +138
for row in read_memory_rows(conn, &repo_id)? {
// `all_edges_from`, not `edges_from`: a backfilled obsolete/rejected memory still carries
// its persisted edges into the complete-history log (the live reader hides them).
let edges = all_edges_from(conn, &row.memory_id)?;
ops.extend(memory_to_ops(&row, &repo_id, &edges)?);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make the backfill snapshot atomic with the chain write

When this backfill runs while another writer creates or updates a memory after read_memory_rows/all_edges_from have been read but before author_batch opens its IMMEDIATE transaction, the signed batch captures only the older snapshot and then leaves the local chain non-empty; every later backfill returns at the chain-tail/idempotency gate, so the concurrent row is permanently omitted from the op-log until some separate live op happens to cover it. Because this helper is intended to produce the complete pre-live history, the memory/edge reads need to be protected by the same write transaction or otherwise block memory writes until the batch is committed.

Useful? React with 👍 / 👎.

Comment on lines +122 to +123
if repo_id == crate::index::schema::LEGACY_REPO_ID {
return Ok(());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip backfill for upgradeable local repo IDs

When the active scope is a shallow-clone local: repo id, register_repo later upgrades that id to a portable repo id and re-points the scoped memory rows; this guard only skips the legacy placeholder, so backfill_memory_oplog can sign an immutable owner stream derived from the temporary local: id. After the upgrade, future memory ops use the portable owner stream and the backfilled history remains stranded under the retired stream, the same class of problem this placeholder check is avoiding.

Useful? React with 👍 / 👎.

… (phase B, unwired)

Freeze the machinery that turns memories into signed op-log entries — the minting
primitive, the row→op translation, and the one-time full backfill — without yet
touching the live memory write path.

- store::author_op / author_batch: mint entries by allocating the next Lamport
  from the (stream, device) chain tail, signing, and inserting. author_op is one
  op in its own txn; author_batch is a whole sequence in ONE atomic txn (an
  interrupted backfill rolls back and re-runs clean) with a single projection
  re-fold. append's reproject branch is factored into a shared helper.
- oplog gains its first crate-internal API surface: a curated pub(crate) re-export
  (the minting fns + the op vocabulary), the one seam query::memory reaches through
  — a one-way dependency, so oplog never depends back on the memory subsystem.
- query::memory::authoring translates a memory into NodeCreate [+ NodeStatus when
  non-active] [+ EdgeAdd per typed node-edge]; code-anchor bindings stay out (they
  are per-device derived resolution state). backfill_memory_oplog authors every one
  of the active repo's memories into its owner stream — idempotent (a completed
  atomic batch leaves a non-empty chain), scope-gated (a no-op on an unscoped DB),
  deterministically ordered. The log becomes the complete signed history.

The minting primitives take a &LocalDevice, keeping DeviceSecret oplog-private.
Still unwired: the next increment calls backfill + author inside each mutation's
transaction (making create_memory/update_memory transactional).

Fixes #524
@skakri skakri force-pushed the feat/oplog-authoring branch from 38d08f8 to 1324921 Compare July 9, 2026 08:30
@skakri skakri merged commit 5161b4e into main Jul 9, 2026
22 checks passed
@skakri skakri deleted the feat/oplog-authoring branch July 9, 2026 08:38
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.

memory op-log: op-authoring helper + full backfill of existing memories (phase B, unwired)

1 participant