Skip to content

fix(lineage): require exact calibrated active channel profiles - #638

Merged
seonghobae merged 3 commits into
feat/external-lineage-contract-mainfrom
fix/exact-active-channel-weights
Aug 25, 2026
Merged

fix(lineage): require exact calibrated active channel profiles#638
seonghobae merged 3 commits into
feat/external-lineage-contract-mainfrom
fix/exact-active-channel-weights

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Contract

  • enforce the exact active channel set required by ADR 0200 and ADR 0205
  • reject unavailable or missing LLM channel profiles instead of dropping and renormalizing weights
  • align the PRD and superseded ADR language with the fail-closed persisted-weight loader

Verification

  • 144 focused backend, contract, documentation, and docstring tests passed
  • git diff --check passed

This PR is stacked on #636; a stack merge is not protected-main delivery evidence.


Open in Devin Review

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 392ecb80-34b4-4b9e-87ae-df6839a98b01

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae merged commit 3609d63 into feat/external-lineage-contract-main Aug 25, 2026
3 of 4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51c2be9d3e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +58 to +59
if set(weights) != expected:
raise ValueError("weights must exactly match the active lineage channels")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve unavailable-channel renormalization

When llm is absent or reports available = False, callers supplying a vector that includes llm now receive ValueError instead of reconstructing with that unavailable channel removed. Restore dropping llm and renormalizing the remaining weights, as required for NullAdjudicationClient; otherwise the documented missing-signal fallback is broken.

AGENTS.md reference: AGENTS.md:L189-L195

Useful? React with 👍 / 👎.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Open in Devin Review

Comment on lines +55 to +69
expected = set(_CORE_WEIGHT_CHANNELS)
if getattr(llm, "available", False):
expected.add("llm")
if set(weights) != expected:
raise ValueError("weights must exactly match the active lineage channels")
values = tuple(weights.values())
if any(
isinstance(value, bool)
or not isinstance(value, (int, float))
or not math.isfinite(float(value))
or float(value) <= 0.0
for value in values
) or not math.isclose(sum(values), 1.0, abs_tol=1e-9):
raise ValueError("active lineage weights must be finite, positive, and sum to one")
return dict(weights)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Code contradicts the mandatory pluggable-channel convention

active_weights now rejects a mismatched channel set with ValueError instead of dropping and renormalizing the unavailable channel. The AGENTS.md "Pluggable channels" section still mandates the drop-and-renormalize behavior and names this exact function, and it was not updated to match.

Prompt for agents
The mandatory convention file AGENTS.md (section "Pluggable channels: never fake a missing signal") states that Null channel clients must "make their channel dropped + renormalized (reconstruct.active_weights)". This PR intentionally changes reconstruct.active_weights to require an exact calibrated channel vector and raise ValueError instead of dropping/renormalizing, per the ADR 0200/0205 amendments. Update AGENTS.md to reflect the new fail-closed exact-vector contract so the mandatory convention file no longer describes the removed drop-and-renormalize behavior and no longer references reconstruct.active_weights as the renormalization mechanism.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +67 to +68
) or not math.isclose(sum(values), 1.0, abs_tol=1e-9):
raise ValueError("active lineage weights must be finite, positive, and sum to one")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Sum-to-one tolerance matches the weight loader

The new abs_tol=1e-9 sum check could in principle fail-close persisted weights, but load_estimated_channel_weights (backend/app/lineage_ingestion.py:302) already enforces the identical abs_tol=1e-9 sum check before reconstruction, and estimate_channel_weights normalizes by dividing by the total. Loaded and estimated vectors sum to 1 within float epsilon, so the stricter gate adds no new failure path.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +55 to +59
expected = set(_CORE_WEIGHT_CHANNELS)
if getattr(llm, "available", False):
expected.add("llm")
if set(weights) != expected:
raise ValueError("weights must exactly match the active lineage channels")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Exact-match change is consistent across all callers

Switching from drop-and-renormalize to exact-match-or-raise could break a caller passing a four-channel vector with an unavailable llm. Every caller derives its channel set from the same available predicate active_weights uses: estimated_weight_channels, analysis_run_start (active_channels gated on _ProviderBoundaryAdjudication.available at backend/app/analysis_run_start.py:77), the demo server, and seed scripts. None passes a set that mismatches its own llm availability.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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