Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

fix(query): skip unresolvable pre-tag atom refs with warn (alpha BLOCKER 4b171) - #566

Merged
shiba4life merged 2 commits into
mainlinefrom
fix/4b171-pretag-ref-leak-graceful-query
Apr 20, 2026
Merged

fix(query): skip unresolvable pre-tag atom refs with warn (alpha BLOCKER 4b171)#566
shiba4life merged 2 commits into
mainlinefrom
fix/4b171-pretag-ref-leak-graceful-query

Conversation

@shiba4life

Copy link
Copy Markdown
Collaborator

Summary

Alpha BLOCKER 4b171, surfaced by dogfood run #5: Alice tags a schema with org_hash after ingesting. Post-tag molecules sync fine, but molecules whose refs point to pre-tag atom uuids ship the ref without the backing atom data — design org_shared_sync.md explicitly does not migrate pre-tag molecules. Receiver (Bob) holds an orphan ref and every unfiltered query on the shared schema fails with Atom not found for key.

Fix is query-side, scoped to org reads: when BOTH the org-prefixed and unprefixed lookups miss, log warn and skip the ref instead of erroring out the whole query. Personal reads stay strict (genuine integrity bugs still surface). Option 2 from the run-5 followup — non-destructive, does not touch set-org-hash, does not re-emit pre-tag molecules (that would be option 3, separate task if we want it).

Changes

  • src/schema/types/field/filter_utils.rs — on Ok(None) after dual-read, if org_hash.is_some(), log::warn! + continue. Else keep the existing InvalidField error.
  • tests/org_key_prefixing_test.rs — two regression tests:
    • test_org_query_skips_unresolvable_pretag_atom_refs_with_warn: org schema + simulated sync gap (delete atom at Sled level). Unfiltered query must succeed.
    • test_personal_query_still_errors_on_missing_atom: personal schema + missing atom still raises InvalidField.

Test plan

  • cargo fmt --all
  • cargo clippy --workspace --all-targets -- -D warnings — green
  • cargo test --workspace --all-targets — green
  • Workspace pointer bump after this merges, to unblock alpha-thesis

Refs gbrain projects/alpha-e2e-dogfood-run-5 and projects/alpha-e2e-dogfood-run-5/4b171 severity:BLOCKER.

🤖 Generated with Claude Code

…KER 4b171)

When Alice tags an existing schema with `org_hash` and then writes more
molecules, the set-org-hash design intentionally does not migrate pre-tag
atom data. Post-tag molecules ship through the org log fine, but a
molecule whose ref contains a pre-tag atom uuid ships the ref without the
backing atom — leaving a receiver (Bob) with an orphan ref that fails
every unfiltered query on the shared schema with `Atom not found for
key`.

Fix: in `fetch_atoms_with_key_metadata_async_with_org`, when both the
org-prefixed and unprefixed atom lookups miss for an org-scoped read, log
a warning and skip the ref instead of erroring the whole query. Personal
reads keep the strict error so genuine data integrity bugs still
surface.

Adds two regression tests in `tests/org_key_prefixing_test.rs`:
- `test_org_query_skips_unresolvable_pretag_atom_refs_with_warn` — org
  schema with a simulated sync gap (delete one atom at the Sled level),
  unfiltered query must succeed and return the resolvable molecules.
- `test_personal_query_still_errors_on_missing_atom` — personal schema
  with a missing atom must still raise `InvalidField`.

See gbrain `projects/alpha-e2e-dogfood-run-5` for repro context.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
github-actions Bot enabled auto-merge April 20, 2026 04:02
Comment thread src/schema/types/field/filter_utils.rs Fixed
@shiba4life
shiba4life disabled auto-merge April 20, 2026 04:22
@shiba4life
shiba4life added this pull request to the merge queue Apr 20, 2026
Merged via the queue into mainline with commit dbaf9f9 Apr 20, 2026
7 checks passed
@shiba4life
shiba4life deleted the fix/4b171-pretag-ref-leak-graceful-query branch April 20, 2026 04:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants