feat(doctor): --classify-orphans pass for un-typed low-prior beliefs (#206) - #253
Merged
Merged
Conversation
…eclassification core New CLI: aelf doctor --classify-orphans [--max N] [--dry-run] Orphan definition (both signals required): - type = 'unknown' or NULL (never resolved by onboard or ingest) - alpha + beta < 2 (untouched Bayesian prior — no feedback applied) Future extension signals (entity_index miss, zero non-CONTAINS edges) noted as TODO in code comments pending #143 and edge-type auditing. store.py additions: find_orphan_beliefs(max_n) — SQL query implementing the definition count_beliefs_by_type() — distribution snapshot for the report doctor.py additions: classify_orphans() — drives classify_batch, updates beliefs in-place format_orphan_report() — human-readable cost + distribution report OrphanRunReport — dataclass accumulating run telemetry cli.py additions: _cmd_doctor_classify_orphans() — CLI handler; gates API key, routes --classify-orphans / --dry-run / --max N args on p_doctor
…-orphans Fix orphan threshold: alpha+beta <= 2 (the untouched default prior sums to exactly 2; any feedback event pushes the sum above 2). Adds test_doctor_classify_orphans.py with 14 tests covering: - find_orphan_beliefs SQL correctness (type filter, alpha+beta gate) - max_n cap on both query and LLM batch - dry_run: no network calls, no store writes - 95-percent recovery acceptance criterion (N=100 synthetic orphans) - no-orphans noop path - CLI integration: --classify-orphans / --dry-run / --max N / no-key - format_orphan_report output (cost estimate, before/after distribution) - count_beliefs_by_type distribution snapshot
robotrocketscience
force-pushed
the
feat/issue-206-classify-orphans
branch
from
April 28, 2026 23:18
ef68124 to
cee89c2
Compare
This was referenced Apr 29, 2026
robotrocketscience
added a commit
that referenced
this pull request
Apr 29, 2026
## Summary Spec memo for #290. Phase-3 of the #286 redesign — the foundational typing axis that ranking, aging, and promotion all consume. **Doc-only — no code change. Posted for ratification.** Core moves: 1. **New orthogonal axis `retention_class`** with three live values: `fact`, `snapshot`, `transient` (plus `unknown` for migration). Distinct from the existing `type` enum, which describes *form* not *expected lifetime*. 2. **Defaults per ingest path.** Filesystem/git/CLI-remember → `fact`. Transcript/hook → `snapshot`. `transient` requires explicit operator opt-in. Table in §2. 3. **Soft down-weight in ranking, not hard expiry.** Composite score from #289 gains a `retention_age_multiplier(class, age_days)` term. Per-class exponential decay with floor (fact ~300d half-life, snapshot 14d, transient 1d). Locks force multiplier = 1.0. 4. **Promotion: snapshot → fact** when `corroboration_count >= 3 AND distinct_sessions >= 2 AND no contradiction`. Reuses #190 corroboration recorder. Doctor-pass opt-in (`aelf doctor --promote-retention`, mirrors #253). No demotion — contradictions handle correctness. 5. **Migration via `_maybe_classify_retention_class()`**, schema-meta gated, heuristic by `source_kind`. `legacy_unknown` rows stay `unknown`. ## Decision asks (nine) Bottom of the memo. Schema shape, defaults table, transient opt-in, multiplier shape, lock override, calibration plan, promotion thresholds, no-demotion, migration heuristic. ## What ships if ratified Three PRs: 1. Schema + score-formula change + migration helper (~500 lines) 2. Per-ingest defaults wired across scanner / ingest / hooks (~250 lines) 3. Promotion lane via `aelf doctor --promote-retention` (~300 lines) ## Test plan - [x] Memo cross-references #286, #196, #229, #190, #253, #283, #281 - [x] Code touchpoints listed in Provenance - [x] No code change; nothing to test - [ ] Ratification or override comment from maintainer Refs #290, #286
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #206.
Summary
Adds `aelf doctor --classify-orphans` — a targeted reclassification pass that finds beliefs whose `type` was never resolved AND that have never received any feedback, then re-classifies them through the same Haiku batch path `aelf onboard --llm-classify` already uses. Strict superset of onboard: only adds calls, doesn't replace anything.
Orphan definition (both signals required)
The other orphan signals from the issue (zero non-CONTAINS edges, entity_index miss) are noted in code comments as future extensions once #143 / edge-type auditing land.
CLI
Implementation notes
Test plan
Out of scope