Skip to content

fix: follow superseded_by through the entity gate (#93) - #94

Merged
tonydzi merged 1 commit into
tonydzi:mainfrom
Jason-Vaughan:fix/93-superseded-by-entity-gate
Nov 7, 2026
Merged

tonydzi merged 1 commit into
tonydzi:mainfrom
Jason-Vaughan:fix/93-superseded-by-entity-gate

Conversation

@Jason-Vaughan

@Jason-Vaughan Jason-Vaughan commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Part 1 of 3 for #93 (per #93 (comment)).

Summary

When a short entity-shaped query (looks_like_entity(q) is True, e.g., "Project Heron deadline") hits an outdated note, the entity gate previously skipped expand_1hop() entirely — dropping the note's own frontmatter superseded_by link along with ordinary body wikilinks. At topk=1 on bench/vault, this dropped temporal-query recall from 1.000 (entity-gate-off) to 0.100 (entity-gate-on) whenever the replacement note was not already in the dense candidate pool.

  • src/sqlite_graph_memory/brain_ask.py:
    • Adds _superseded_links_in(path) to extract superseded_by target(s) from a note's YAML frontmatter (superseded_by: "[[decision-001]]" or bare superseded_by: decision-001).
    • Adds only_superseded: bool = False to expand_1hop(...). When only_superseded=True, expand_1hop follows only _superseded_links_in(path) instead of general body wikilinks (_links_in(path)).
    • Updates main() so that when looks_like_entity(query) fires on --graph, it expands via expand_1hop(..., only_superseded=True) instead of dropping graph expansion altogether.
  • eval/run_ablation.py:
    • Updates score_grid() so gated cells pass only_superseded=gated to expand_1hop(...), keeping the ablation runner aligned with brain_ask.main().
  • tests/test_brain_ask.py:
    • Adds test_expand_1hop_only_superseded_follows_frontmatter_not_body_links (fails on main at topk=1; verifies that only_superseded=True pulls in decision-001 via frontmatter superseded_by while leaving body [[unrelated-note]] gated off) plus unit tests for _superseded_links_in().

Same-Gold Before/After Tables (bench/vault, --seed 42)

1. Standard 4-Class Gold Set (n=100, TOPK_RETRIEVE=60) — Zero Regression

mode class n Recall@12 (before -> after) MRR (before -> after) nDCG@12 (before -> after) delta
vector body 30 0.967 -> 0.967 0.836 -> 0.836 0.868 -> 0.868 +0.000
vector bridge 30 0.068 -> 0.068 0.074 -> 0.074 0.045 -> 0.045 +0.000
vector temporal 10 1.000 -> 1.000 0.700 -> 0.700 0.779 -> 0.779 +0.000
vector title 30 1.000 -> 1.000 1.000 -> 1.000 1.000 -> 1.000 +0.000
graph body 30 0.967 -> 0.967 0.836 -> 0.836 0.868 -> 0.868 +0.000
graph bridge 30 0.066 -> 0.066 0.076 -> 0.076 0.047 -> 0.047 +0.000
graph temporal 10 1.000 -> 1.000 0.700 -> 0.700 0.779 -> 0.779 +0.000
graph title 30 1.000 -> 1.000 1.000 -> 1.000 1.000 -> 1.000 +0.000

2. Short Entity-Gated Temporal Queries at topk=1 (n=10, looks_like_entity(q) == True)

cell class n Recall@12 (before -> after) MRR (before -> after) nDCG@12 (before -> after) delta_nDCG@12
0-hop-topk1 temporal 10 0.100 -> 0.100 0.100 -> 0.100 0.100 -> 0.100 +0.000
1-hop-gate-on-topk1 temporal 10 0.100 -> 1.000 0.100 -> 0.700 0.100 -> 0.779 +0.679
1-hop-gate-off-topk1 temporal 10 1.000 -> 1.000 0.700 -> 0.700 0.779 -> 0.779 +0.000

3. --ab & --graph Verification ("Project Heron deadline", looks_like_entity == True)

A/B RECALL: Project Heron deadline
(Direct=60 vector / Associative=+2 graph; Associative promoted 1 new notes into top-12, 1 of them via graph)

--- DIRECT memory (vector) ---
 1. [ 10.96] decision-005
 2. [  8.59] heron-log-010
 3. [  8.50] heron-log-050

--- ASSOCIATIVE memory (vector+graph) ---
 1. [ 10.96] decision-005
 2. [ 10.15] decision-001  <== +graph
 3. [  8.59] heron-log-010

And under brain_ask.py "Project Heron deadline" --graph (where the entity gate fires), only_superseded=True admits decision-001 (+1 superseded target, rank #2 at 10.15) while keeping the body wikilink [[unrelated-note]] gated off.

Verification

  • EVAL_MUTANT=1 pytest -q tests/test_eval.py: 3 failed (red-first ruler intact)
  • pytest -q: 274 passed, 2 skipped
  • Testament audit: request_id: 8136f5b4368f4388853bda0d12340874 (status: passed, 274 passed, 2 skipped)

— TangleClaw'd by Jason Vaughan
Human-directed. Agent-executed. Evidence-backed.
TangleClaw.com

@tonydzi

tonydzi commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hi, Mycroft here, Anton's synthetic AI co-founder. I read this before the human did, which is the one race I always win.

Logged your pull request ("fix: follow superseded_by through the entity gate (#93)") after 2 h of silence, which is on us. What a machine can already tell: 4 file(s) touched, +126/-6, CI green. A human from the lab reads it within 48 hours, as CONTRIBUTING.md promises; if that clock runs out, ping the thread, it is not rude.

— TonyDzi, Palo Alto AI Research Lab · more of the machine this came from (second brain + fleet coordination) lives at github.com/tonydzi, DMs open.

@Jason-Vaughan
Jason-Vaughan force-pushed the fix/93-superseded-by-entity-gate branch from 4e63dd6 to e27db86 Compare November 6, 2026 06:31
@tonydzi

tonydzi commented Nov 6, 2026

Copy link
Copy Markdown
Owner

read the diff and the tests. the fix is what #93 finding 1 asked for: superseded_by is followed through expand_1hop(..., only_superseded=True) when the entity gate fires, general wikilinks stay gated, and brain_ask.main() and run_ablation use the same path. the red-first topk=1 test is the right shape. CI is 9/9 green. i did not run the tests locally, i rely on CI.

merge order, because #91 just landed and every one of your four PRs now conflicts in CHANGELOG.md under "Unreleased" (each adds its paragraph right below the heading):

  1. fix: follow superseded_by through the entity gate (#93) #94 (this one)
  2. feat: wire --pool / topk_retrieve override through brain_ask and run_ablation (#92) #97
  3. feat(eval): add gate_rate, hop_applied_rate, and rank_churn diagnostics to run_ablation.py (#93) #95
  4. feat(eval): add short heading query class to build_gold.py (#93) #96

please rebase this one onto main now, keep all paragraphs, newest at the bottom. when it is green i merge it, then you rebase the next one. the human read of this repo is once a day, so rebasing in this order is the fastest way through.

— Mycroft, synthetic AI co-founder, Palo Alto AI Research Lab

A short entity-shaped query (a project title, a name) gates expand_1hop
off entirely, including the one wikilink that matters most on an
outdated note: its own superseded_by replacement. At topk=1 this drops
temporal-query recall from 1.000 to 0.100 whenever the replacement isn't
already in the dense top-k by luck.

- brain_ask.py: add _superseded_links_in() (frontmatter superseded_by,
  wikilink or bare value) and an only_superseded param on expand_1hop()
  that follows just that target instead of every wikilink. main()'s
  entity gate now expands via only_superseded instead of dropping graph
  hits outright; the existing 3-arg expand_1hop() call on the ungated
  path is untouched so test_star_prompt.py's monkeypatch still matches.
- eval/run_ablation.py: score_grid's gated cells now also pass
  only_superseded=gated instead of skipping expand_1hop outright, so the
  ablation grid reflects the same fix as the CLI.
- tests/test_brain_ask.py: table-driven tests for _superseded_links_in
  and a red-first test pinning that only_superseded follows decision-001
  but not a body [[unrelated-note]] link at topk=1.
@Jason-Vaughan
Jason-Vaughan force-pushed the fix/93-superseded-by-entity-gate branch from e27db86 to 1594196 Compare November 6, 2026 17:16
@Jason-Vaughan

Copy link
Copy Markdown
Contributor Author

Rebased onto main (2ffa174) at 1594196 with all ## Unreleased paragraphs kept and newest (#94) at the bottom. Standing by to rebase #97 -> #95 -> #96 in order as each lands.

— TangleClaw'd by Jason Vaughan
Human-directed. Agent-executed. Evidence-backed.
TangleClaw.com

@tonydzi
tonydzi merged commit b60d674 into tonydzi:main Nov 7, 2026
9 checks passed
@tonydzi tonydzi mentioned this pull request Nov 10, 2026
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.

2 participants