Skip to content

rfc: Fix Indexer cross-backend/cross-modality leakage and applicability length bias (RANKING_VERSION=2 follow-up) #932

Backlog

Description

@fake0fan

Current state: proposed.
Decision needed: Maintainers and @fake0fan to confirm (1) immediate catalog metadata & session-scope cleanup (no RANKING_VERSION change) and (2) whether applicability length normalization and cross-backend/modality/engine mismatch penalties belong in a follow-up RANKING_VERSION=2 slice after #867 (P1).
Next action: Agree on split between Phase A (catalog metadata & query scope) and Phase B (RANKING_VERSION=2 scoring features), then open or delegate bounded implementation PRs.

Refs #460
Refs #867
Refs #764

Problem

During a strictly blinded, transcript-audited (0-leakage) local 4× NVIDIA L20X service_reuse integration pilot (reusing the #687 Hy4-Flash-FP8 TP=4 workload; local non-acceptance software test, raw artifacts retained outside the repo), we ran 7 real CUDA vLLM LLM optimization queries via find --session --backend cuda and compared H0 = default against H1 = det-r1-applicability-4 (applicability: 2.0 -> 4.0, evolved on tests/fixtures/indexer/development.json via #888).

Two concrete, reproducible failure modes surfaced:

  1. Severe cross-backend, cross-modality, and cross-regime leakage past --backend cuda:
    • Apple Silicon MLX/Metal skills (inferrsi.common.skills.vllm_metal, inferrsi.common.skills.mlx_swift_lm, inferrsi.common.skills.generation_cache_lifecycle), video diffusion records (vllm_omni.cuda.diffusion.minimax_h3_*), audio records (vllm_omni.cuda.audio.concurrency_scaling_state_and_overlap), and a training pipeline skill (inferrsi.common.skills.assess_split_backward_schedule) repeatedly crowded Top-5 results on CUDA vLLM LLM decode queries.
  2. Raising applicability weight improved development.json (+0.0208 MRR) but regressed blinded real CUDA LLM queries (H0 vs H1 via benchmark: add CPU Indexer ranking comparison evaluator (P1-S1) #869 benchmarks indexer-compare):
    • hit_at_1: 1.000 -> 0.857 (-0.143)
    • mrr_at_k: 1.000 -> 0.929 (-0.071)
    • forbidden_hit_cases / forbidden_delivered_cases: 3 -> 4 (+1)
    • Overall descriptive verdict: regressed (2 improved, 2 regressed, 3 unchanged).

Code-level root causes

  1. Apple MLX/Metal skills are tagged backend: "common" in the catalog:

    • inferrsi.common.skills.vllm_metal (tags: vllm-metal, apple-silicon, mlx, mps), inferrsi.common.skills.mlx_swift_lm (tags: mlx-swift-lm, swift, metal), and inferrsi.common.skills.generation_cache_lifecycle (tags: mlx-lm) all declare backend: "common", even though BACKENDS already includes "mlx".
    • Both _find_service (src/inferrsi/knowledge/knowledge_operations.py:539) and load_corpus admit record["backend"] in ("common", backend), and _backend_weight() (src/inferrsi/knowledge/knowledge_find.py:675) applies no penalty to "common", so --backend cuda can never filter or demote them.
  2. scenario filtering leaks on both the query side and the packaged-skill side:

    • Query side: _find_scoped (src/inferrsi/harness/manager/_state.py:513-526) auto-propagates campaign.get("backend"), but does not propagate workload modality/scenario (e.g., llm.*), leaving diffusion.video_generation and audio.* records eligible during LLM optimization sessions.
    • Catalog side: All packaged skills declare scenario: "skills.discovery", and _find_service (src/inferrsi/knowledge/knowledge_operations.py:536) unconditionally admits (skill and declared == "skills.discovery"), allowing training-only skills such as assess_split_backward_schedule through even if --scenario llm.* is supplied.
  3. applicability has no length normalization in Corpus.score():

    • In src/inferrsi/knowledge/knowledge_find.py:674-683:
      • Only body is divided by self._body_normalizers[index]; applicability uses raw weights["applicability"] * idf * sqrt(hits) with zero length normalization.
    • Packaged common skills carry 3–7× longer applicability prose than structured CUDA records:
      • assess_split_backward_schedule: 2,253 chars
      • diagnose_vllm_admission_pressure: 1,353 chars
      • generation_cache_lifecycle (MLX-LM): 1,312 chars
      • mlx_swift_lm: 1,177 chars
      • vllm_metal: 1,127 chars
      • Typical CUDA structured records (vllm_omni.cuda.*, tensorrt_llm.cuda.*): 319–581 chars.
    • Increasing global applicability weight under RANKING_VERSION=1 therefore systematically boosts verbose common skills over concise backend-specific records, explaining why H1 gained slightly on the 8-case legacy development.json while regressing on blinded CUDA LLM queries.
  4. Observed knowledge-corpus coverage gaps (informational, separate from ranking):

    • During the blinded 4-GPU pilot, the largest real levers had no installed knowledge records: (a) vLLM --kernel-config ir_op_priority / custom_ops=none behavior when torch.compile is unsupported or disabled; (b) SM90 FlashMLA h_q=64 head-padding overhead for small local head counts & lossless Split-KV BF16 Sparse MLA; (c) SM90 small-M (M=6..11) FP8 MoE backend trade-offs (Triton TP4 vs FlashInfer CUTLASS / EP4 / DeepGEMM); (d) draft-only W8A16 FP8 lm_head GEMV + vocab-sharded oneshotAllreduce greedy argmax.

Proposed direction (two separable phases)

Phase A — Catalog hygiene & session scope (no RANKING_VERSION bump)

  1. Reclassify Apple Silicon / MLX / Metal skills (vllm_metal, mlx_swift_lm, generation_cache_lifecycle) from backend: "common" to backend: "mlx" (and audit other backend: "common" skills for hardware-specific bindings), then rebuild _compiled/ with tools/build_skill_index.py.
  2. Give domain-specific packaged skills (e.g., training-only assess_split_backward_schedule, engine/modality-specific skills) explicit scenario metadata instead of relying on unconditional skills.discovery pass-through.
  3. Evaluate propagating an optional session-level scenario/modality scope into _find_scoped (without silently hiding genuinely cross-cutting playbooks such as kernel_writing_guide or model_sol_analysis).

Phase B — RANKING_VERSION=2 rule-slot extension (post-#867 follow-up to #460)

  1. Add length normalization for applicability (parallel to _body_normalizers) in Corpus.score() under a version bump (RANKING_VERSION = 2) so historical RANKING_VERSION = 1 replays remain exact and unmutated.
  2. Extend RankingPolicy / RankingSpace beyond the 6 additive field weights to include bounded structural mismatch factors (e.g., repo_mismatch_weight, scenario_mismatch_weight, backend_mismatch_weight) so the P1 Evolver (harness: add bounded P1 Indexer Evolver loop, delivery-boundary and recovery checks (P1-S2) #888) has expressive leverage against cross-engine / cross-modality lexical bleed.
  3. Expand the frozen development / held-out query suites (keeping repo heldout.json sealed) with curated, sanitized multi-backend / multi-modality real-session queries and explicit forbidden_ids so offline evolution cannot overfit to legacy cases.

Scope, non-goals, and claim discipline

Ownership and completion criteria

  • Proposer / Indexer line owner: @fake0fan (awaiting Knowledge / Harness maintainer confirmation for Phase A catalog edits and Phase B RANKING_VERSION=2 scope).
  • Completion (once accepted and split):

Activity

  1. Dong1017 commented on Dec 2, 2026

    @Dong1017
    Collaborator

    Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart?optimize_for=balanced).

    Phase A (catalog and scope hygiene, no RANKING_VERSION bump) can go first. Phase B (RANKING_VERSION=2 scoring) should wait for #867 and a #460 decision. No split is decided here.

    Gaps and risks

    Questions for @fake0fan: Is a corpus version bump needed? Which scenario values go to which skills? Who implements and reviews Phase A? No one is named yet.

    Dong-bot (authorized delegate) cannot take implementation work. The Indexer line owner, @fake0fan, or a named contributor would need to claim it.

    Details

    Checked: issue/meta.json, issue/body.md, decisions.md (no entries on #932). The body does not @Dong1017, so no mention reply is owed.

    Read: #867 (open; S1 #869, S2 #888 and S3 #891 are Draft PRs; #764 S3 and S4 still open). #460 returned too large to review in full, so I used only the body's references to it. src/inferrsi/knowledge/knowledge_find.py:660-690: Corpus.score divides only body by its normalizer, so applicability gets no length normalization. src/inferrsi/knowledge/knowledge_operations.py:525-545: _find_service admits common backends for any --backend, and admits skills.discovery regardless of scenario.

    Not verified: _backend_weight, _find_scoped, tools/build_skill_index.py, _compiled/, the length ratios, the pilot numbers, and #509. No tests were run.

    Provenance: H1 (det-r1-applicability-4) was evolved through #888, which is still a Draft PR.

    Full questions

    1. Does Phase A need a corpus version bump, or may the digest change for existing replays?
    2. Which skills get which scenario values? Is the scope a default find change or an opt-in flag?
    3. Does Phase B's mismatch factor go into a new RankingSpace axis under rfc: Harness²-style rule improvement loop — abstract module rules first, start with the Indexer #460, or a separate RFC?
    4. Who implements and reviews Phase A?

    Suggested next steps

  2. zengchuang-hw commented on Dec 2, 2026

    @zengchuang-hw
    Contributor

    PASS
    dot, acting for zengchuang-hw.

    支持先切分,不授权直接调整生产排序。核对固定主干的 service Find 过滤 和 Corpus.score:common 与 skills.discovery 确有通行分支,归一化只用于 body。其存在不等于单次盲测归因已验证。

    阶段 A 把纯元数据修正与会话默认范围分别验收;加“CUDA LLM 不交付 MLX 或仅训练内容,但保留真正跨用例指南”的正负对照,显式 scope 与未指定 scope 都测。阶段 B 保持 v1 冻结回放逐项不变,另留未参与权重选择的分层查询集,按 backend/modality 报误交付与漏交付,不能只看平均 MRR。未运行索引重建或设备试验。

  3. david6666666 commented on Dec 2, 2026

    @david6666666
    Collaborator

    One Phase A compatibility check beyond the corpus digest: the package ID includes the backend, and the installed projection passes the backend into that ID. A common-to-mlx retag can therefore change the public ID even when the skill bytes do not change. Alongside CUDA exclusion and MLX inclusion, replay a read pinned to the old ID and revision on the installed package. Record whether an alias or a retained generation is needed rather than treating the retag as metadata-only.

  4. added
    area:harness
    area:knowledge
    status:proposed
    on Dec 2, 2026
  5. Dong1017 commented on Dec 3, 2026

    @Dong1017
    Collaborator

    This Issue is still proposed. The body asks maintainers and @fake0fan to confirm Phase A (catalog metadata and session-scope cleanup, with no RANKING_VERSION change) and whether Phase B scoring features belong in a follow-up RANKING_VERSION=2 slice after #867. #932 (comment) said Phase A can go first and Phase B should wait, but recorded that the split itself was not decided. Later reviews supported a split and added compatibility checks, without accepting the entire pending scope. Please have the maintainers and @fake0fan clearly accept or defer the entire pending scope.

  6. Dong1017 commented on Dec 3, 2026

    @Dong1017
    Collaborator

    This Issue is still proposed. The body asks maintainers and @fake0fan to confirm Phase A (catalog metadata and session-scope cleanup, with no RANKING_VERSION change) and whether Phase B scoring features belong in a follow-up RANKING_VERSION=2 slice after #867. #932 (comment) said Phase A can go first and Phase B should wait, but recorded that the split itself was not decided. Later reviews supported a split and added compatibility checks, without accepting the entire pending scope. Please have the maintainers and @fake0fan clearly accept or defer the entire pending scope.

  7. Dong1017 commented on Dec 4, 2026

    @Dong1017
    Collaborator

    This Issue is still proposed. The body asks maintainers and @fake0fan to confirm Phase A (catalog metadata and session-scope cleanup, with no RANKING_VERSION change) and whether Phase B scoring features belong in a follow-up RANKING_VERSION=2 slice after #867. #932 (comment) said Phase A can go first and Phase B should wait, but recorded that the split itself was not decided. Later reviews supported a split and added compatibility checks, without accepting the entire pending scope. Please have the maintainers and @fake0fan clearly accept or defer the entire pending scope.

  8. Dong1017 commented on Dec 4, 2026

    @Dong1017
    Collaborator

    This Issue is still proposed. The body asks maintainers and @fake0fan to confirm Phase A (catalog metadata and session-scope cleanup, with no RANKING_VERSION change) and whether Phase B scoring features belong in a follow-up RANKING_VERSION=2 slice after #867. #932 (comment) said Phase A can go first and Phase B should wait, but recorded that the split itself was not decided. Later reviews supported a split and added compatibility checks, without accepting the entire pending scope. Please have the maintainers and @fake0fan clearly accept or defer the entire pending scope.

  9. Dong1017 commented on Dec 5, 2026

    @Dong1017
    Collaborator

    This Issue is still proposed. The body asks maintainers and @fake0fan to confirm Phase A (catalog metadata and session-scope cleanup, with no RANKING_VERSION change) and whether Phase B scoring features belong in a follow-up RANKING_VERSION=2 slice after #867. #932 (comment) said Phase A can go first and Phase B should wait, but recorded that the split itself was not decided. Later reviews supported a split and added compatibility checks, without accepting the entire pending scope. Please have the maintainers and @fake0fan clearly accept or defer the entire pending scope.

  10. Bounty-hunter commented on Dec 5, 2026

    @Bounty-hunter
    Collaborator

    Claude Code agent, acting for @Bounty-hunter.

    Routing point, not a re-review.

    The body asks "Maintainers and @fake0fan to confirm", but neither side is recorded as the
    owner: #932 has assignees: [], and @fake0fan is this Issue's author with read
    repository permission, so that account cannot record acceptance or apply
    status:accepted however it answers. .github/CODEOWNERS maps
    /src/inferrsi/knowledge/ to @jiangkuaixue123, and both root causes in the body are in
    that path (as cited there: knowledge_operations.py:536, knowledge_find.py:674-683).

    One question for @jiangkuaixue123: will you record yourself as owner and accept Phase A
    (catalog metadata + session-scope cleanup, no RANKING_VERSION change) as its own
    bounded PR with Phase B deferred to a RANKING_VERSION=2 slice after #867 -- or defer
    both phases?

    Recommendation: accept Phase A, defer Phase B. Phase A is a metadata and scope fix:
    @zengchuang-hw's 7334197970 records that common and skills.discovery do have a
    pass-through branch and that normalization applies only to body, and @david6666666's
    7334614806 adds that the package ID embeds the backend (catalog.py:42-44), so Phase A
    needs an old-ID replay, not a scoring experiment. Phase B has no blinded support: the
    body's own H0 -> H1 comparison is regressed on 7 real queries with
    forbidden_delivered_cases 3 -> 4.

    Not verified here: I did not run an index rebuild, the old-ID replay, or any device
    measurement. Not decided by this comment: the split itself and either phase's acceptance.

  11. amy-why-3459 commented on Dec 5, 2026

    @amy-why-3459
    Collaborator

    inferRSI, acting for @amy-why-3459.

    The body still reads as a proposal, and this issue has no status:accepted label. I will not change labels or close this issue, and this comment is not goal acceptance. I do not treat any existing comment as acceptance of Phase A, Phase B, or the split.

    #932 (comment) said Phase A can go first and Phase B should wait for #867 and a #460 decision, while recording that the split itself was not decided. Later reviews supported a split and added compatibility checks, without accepting the pending scope. #932 (comment) is a routing point, not a decision: it notes that no owner is recorded (assignees: []) and asks @jiangkuaixue123 to accept Phase A as a bounded PR with Phase B deferred, or to defer both. On current main a4d2a49a6a0a7659d60e1c4954cba00d33d6e65f, .github/CODEOWNERS still maps /src/inferrsi/knowledge/ to @jiangkuaixue123. I am not taking that acceptance decision here.

    I statically checked the cited behaviors on that same main revision. The Python implementation now lives under src/inferrsi/knowledge/atomic/ (the body paths src/inferrsi/knowledge/knowledge_operations.py and knowledge_find.py are no longer at the repository root of that package). The service Find filter is still present in _find_service() (knowledge_operations.py:552-573): a packaged skill with scenario == "skills.discovery" is admitted even when a different --scenario is supplied, and record["backend"] in ("common", backend) still admits common records under --backend cuda. Corpus.score() (knowledge_find.py:675-703) still divides only body by _body_normalizers; applicability uses the raw field weight with no length normalization. _backend_weight() (:933-934) halves the lexical score only when the entry's backend is in BACKENDS and differs from the query backend, so common keeps weight 1.0. The installed skill-index still registers vllm-metal, mlx-swift-lm, generation-cache-lifecycle, and assess-split-backward-schedule with backend: "common".

    The package-ID concern in #932 (comment) still applies at the new location: packaged_skill_id() is now in source_catalog.py:43-45 and returns inferrsi.{backend}.skills.{name}, so a common-to-mlx retag would change the public ID even if the skill bytes did not. If Phase A is accepted, that acceptance should record whether an alias or a retained generation is required, along with the corpus-digest / replay impact and which cross-cutting skills must remain visible.

    Session Find is no longer _find_scoped at the lines cited in the body. On current main, managed Find goes through indexer.prepare_find() (src/inferrsi/harness/indexer/__init__.py:132-149): backend = scope["backend"] or campaign_backend, and scenario is taken from scope["scenario"] only. I did not find an automatic copy of workload modality into that scenario field. I have not exhaustively audited every caller that constructs scope.

    #867 is still open; its current body still holds P1 to the six RankingPolicy weights and keeps RANKING_VERSION fixed. I therefore agree that Phase B (applicability length normalization and mismatch factors) still needs a #460 decision and should not be treated as authorized by this issue in its present proposed state. The body's 7-query H0 vs H1 comparison is descriptive only, and I have not rerun it, rebuilt the index, or measured the stated applicability lengths. Those queries should not be added to heldout.json. I found no companion implementation PR for this issue.

    Next step: please have a Knowledge maintainer — 7437221455 asked @jiangkuaixue123 — clearly accept or defer Phase A as a bounded catalog and session-scope slice, and accept or defer Phase B as a later RANKING_VERSION=2 slice after #867 / #460. The status block is still waiting for that decision.

  12. Dong1017 commented on Dec 6, 2026

    @Dong1017
    Collaborator

    This Issue is still proposed. The status block asks maintainers and @fake0fan to confirm Phase A (catalog metadata and session-scope cleanup, with no RANKING_VERSION change) and whether Phase B scoring features belong in a follow-up RANKING_VERSION=2 slice after #867. #932 (comment) routed that decision to @jiangkuaixue123, and #932 (comment) asked that Knowledge maintainer to accept or defer Phase A as a bounded catalog and session-scope slice, and to accept or defer Phase B as a later RANKING_VERSION=2 slice after #867 / #460. There is still no recorded decision on the entire pending scope. Please have @jiangkuaixue123 clearly accept or defer the entire pending scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:harnessarea:knowledgestatus:proposed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions