Skip to content

feat(search): use compression-lineage memo resolver (#62) - #63

Open
Skywind5487 wants to merge 4 commits into
devfrom
fix/session-search-lineage-memo
Open

feat(search): use compression-lineage memo resolver (#62)#63
Skywind5487 wants to merge 4 commits into
devfrom
fix/session-search-lineage-memo

Conversation

@Skywind5487

Copy link
Copy Markdown
Owner

Summary

Implements #62 using the decision from #54 / PR #55:

  • replace generic-parent recursive winner lineage handling with a query-local Python node -> resolved_root memo/path-compression resolver;
  • enforce a global successful-row-lookup budget of B = 1500;
  • preserve existing candidate generation/ranking routes and defer expensive hydration until winners are known;
  • make tool-layer lineage/current/title handling use the same compression-lineage semantics;
  • fail closed on missing parents, positive cycles, and budget exhaustion;
  • keep branch/delegate/tool parent edges separate while allowing legitimate compression continuations, including foreign inherited markers.

Production lineage predicate

A child continues a compression lineage only when all supported conditions hold:

  • child.parent_session_id = parent.id;
  • parent.end_reason = 'compression';
  • child.source != 'tool';
  • _branched_from does not point at this parent;
  • _delegate_from does not point at this parent.

Foreign/stale markers pointing elsewhere do not disqualify a legitimate continuation.

Implementation

  • hermes_state_lineage.py
    • production resolver with query-local memo/path compression;
    • one logical read snapshot;
    • local cycle detection;
    • B=1500 global successful-row-lookup bound;
    • search_session_winners() override preserving existing unicode61 / CJK LIKE / trigram candidate ranking and source-priority ordering;
    • diagnostics for lineage work and bound hits.
  • hermes_state.py
    • wires SessionDB to the new search mixin.
  • tools/session_search_tool.py
    • routes _resolve_lineage() through the shared production resolver;
    • keeps generic-parent fallback only for older/mock DB objects;
    • title discovery now obtains a lightweight first-message anchor instead of loading the entire transcript, satisfying the existing bounded-hydration contract.
  • tests updated/added for positive compression continuation, branch/delegate/tool separation, foreign markers, malformed config, missing parents, cycles, budget exhaustion, memo reuse, source priority, current/title exclusion parity, and candidate routing.

Validation

VM validation on the implementation worktree:

#62 focused tests:        15 passed in 3.97s
session-search sweep:     15 passed in 3.56s

The focused mechanism benchmark from #54 / PR #55 was run on the same VM hardware and selected Python memo/path compression over no-memo/TEMP/fixed-depth references. The benchmark receipt used /usr/bin/python3 + SQLite 3.40.1; this PR does not reopen that algorithm decision. Production Hermes may use a separately patched owner runtime, while this acceptance run exercises the repository code path on the target VM.

Evidence / references

Non-goals

Closes #62

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