-
Notifications
You must be signed in to change notification settings - Fork 1
fix(lineage): preserve grouping provenance and fail closed weights #506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # ADR 0145 — Channel-weight estimation remains unavailable without an independent anchor | ||
|
|
||
| **Decision status:** Rejected proposal | ||
| **Date:** 2026-08-23 | ||
| **Reconciles with:** [ADR 0003](0003-fast-mlsirm-report-integration.md) | ||
|
|
||
| ## Context | ||
|
|
||
| `lineageweave.reconstruct` currently uses hand-picked convex weights for its | ||
| temporal, secondary-key, text-similarity, and optional LLM channels. Those | ||
| constants are an explicitly ungrounded historical fallback; a citation does | ||
| not turn them into calibrated measurement. | ||
|
|
||
| The rejected proposal treated channels as 2PL items, candidate pairs as | ||
| respondents, and normalized item discriminations as fusion weights. That does | ||
| not establish the product construct. An unanchored IRT fit can describe common | ||
| response structure, but it provides no independent evidence that its latent | ||
| factor is “these posts are genuinely related.” Birnbaum's 2PL item information | ||
| is also conditional on trait location and item difficulty, | ||
| `I_j(theta) = a_j^2 P_j(theta) (1 - P_j(theta))`; it is not a global constant | ||
| proportional only to `a_j`. Normalizing discriminations therefore is not an | ||
| information-optimal convex fusion rule. | ||
|
|
||
| The official pinned `fast-mlsirm` contract makes two further boundaries | ||
| explicit: `factor_id` assigns items to latent dimensions, while `cluster_id` | ||
| represents respondent nesting; and a `FitResult` exposes | ||
| `convergence_status` plus package diagnostics that callers must inspect. Those | ||
| contracts can validate a fit's execution, but cannot supply the missing | ||
| criterion validity. | ||
|
|
||
| Accepted ADR 0003 assigns temporal/event measurement to TEPP and limits this | ||
| repository's fast-mlsirm integration to the approved LLM-judge/report path. | ||
| This proposed lineage-weight path cannot silently expand that boundary. | ||
|
|
||
| ## Decision | ||
|
|
||
| 1. **No unanchored estimate.** LineageWeave does not run the proposed | ||
| candidate-pair IRT fit and does not persist or activate weights from it. | ||
| Estimation reports unavailable until an independent lineage anchor and its | ||
| upstream contract exist. | ||
| 2. **No scientific claim for fallback constants.** Existing constants remain | ||
| unchanged for compatibility, but are neither calibrated nor | ||
| paper-grounded. This ADR does not promote them to measurement evidence. | ||
| 3. **A future proposal must be ADR-first.** It must amend ADR 0003, identify an | ||
| independent outcome/anchor (for example, an accepted TEPP contract rather | ||
| than a local proxy), use official fast-mlsirm diagnostics, reject every | ||
| non-converged fit, and prove criterion validity before product activation. | ||
| 4. **Future persisted vectors must be self-consistent and reproducible.** The | ||
| schema requires a known channel vocabulary, finite positive weights, an | ||
| exact sum of one at runtime, one estimation run identity, estimator and | ||
| anchor method versions, sample size, immutable source-snapshot digest, and | ||
| knowledge cutoff. Current code has no supported anchor method and therefore | ||
| loads no vector. | ||
| 5. **Grouping repair is independent of measurement.** Source row identifiers | ||
| that were mapped as grouping values are normalized only in derived | ||
| reconstruction fields. Their caller-mapped raw values remain preserved in | ||
| separate source-provenance columns across backfill and re-import. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - `scripts/estimate_channel_weights.py` exits without writing because no | ||
| scientifically authorized anchor exists. | ||
| - Missing migration 0135 remains a normal rollout state and is detected via a | ||
| non-error PostgreSQL catalog probe, so an outer rebuild transaction is not | ||
| aborted. | ||
| - The persistence contract is fail-closed: malformed, mixed-provenance, or | ||
| unsupported-anchor rows are ignored rather than renormalized or repaired. | ||
| - Parameter-recovery tests cannot substitute for criterion validity; they may | ||
| return only with a future accepted anchored estimator. | ||
|
|
||
| ## References | ||
|
|
||
| Birnbaum, A. (1968). Some latent trait models and their use in inferring an | ||
| examinee's ability. In F. M. Lord & M. R. Novick, *Statistical theories of | ||
| mental test scores* (pp. 397–479). Addison-Wesley. | ||
|
|
||
| Fox, J.-P., & Glas, C. A. W. (2001). Bayesian estimation of a multilevel IRT | ||
| model using Gibbs sampling. *Psychometrika, 66*(2), 271–288. | ||
| https://doi.org/10.1007/BF02294839 | ||
|
|
||
| McNeish, D., & Wolf, M. G. (2020). Thinking twice about sum scores. | ||
| *Behavior Research Methods, 52*(6), 2287–2305. | ||
| https://doi.org/10.3758/s13428-020-01398-0 | ||
|
|
||
| ContextualWisdomLab. (2026). *fast-mlsirm*, pinned LineageWeave dependency | ||
| contract at commit `5006c38286a4fa1d81bcf57eeed5ce27ae743f50`. | ||
| https://github.com/ContextualWisdomLab/fast-mlsirm/tree/5006c38286a4fa1d81bcf57eeed5ce27ae743f50 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """Fail-closed lineage channel-weight boundary (ADR 0145). | ||
|
|
||
| Channel-score covariance is not an independent lineage anchor. Until an | ||
| accepted upstream anchor contract exists, this module produces no estimate. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
|
|
||
| def estimate_channel_weights( | ||
| pair_channel_scores: list[dict[str, float]], | ||
| group_ids: list[int], | ||
| ) -> None: | ||
| """Report unavailable for unanchored channel scores. | ||
|
|
||
| Args: | ||
| pair_channel_scores: unanchored candidate-pair channel scores. | ||
| group_ids: corresponding reconstruction-group indexes. | ||
|
|
||
| Returns: | ||
| Always ``None`` until ADR 0145's independent-anchor requirement is met. | ||
| """ | ||
| if len(pair_channel_scores) != len(group_ids): | ||
| raise ValueError("pair_channel_scores and group_ids must align") | ||
| return None |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| -- ADR 0145: reserve an integrity- and provenance-bearing persistence contract. | ||
| -- No anchor method is currently authorized, so application code activates no | ||
| -- stored vector. | ||
|
|
||
| alter table source_post | ||
| add column if not exists source_thread_group_key text, | ||
| add column if not exists source_secondary_grouping_key text; | ||
|
|
||
| comment on column source_post.source_thread_group_key is | ||
| 'Raw caller-mapped source thread field; preserved separately from derived reconstruction grouping.'; | ||
| comment on column source_post.source_secondary_grouping_key is | ||
| 'Raw caller-mapped source secondary-group field; preserved separately from derived reconstruction evidence.'; | ||
|
|
||
| create table if not exists lineage_channel_weight ( | ||
| channel_code text primary key, | ||
| weight_value double precision not null, | ||
| estimation_run_id uuid not null, | ||
| estimation_method_code text not null, | ||
| estimator_version text not null, | ||
| anchor_method_code text not null, | ||
| source_snapshot_sha256 text not null, | ||
| sample_pair_count bigint not null, | ||
| knowledge_cutoff timestamptz not null, | ||
| estimated_at timestamptz not null default now(), | ||
| constraint lineage_channel_code_check | ||
| check (channel_code in ('temporal', 'secondary_key', 'text', 'llm')), | ||
| constraint lineage_weight_value_check | ||
| check (weight_value > 0 and weight_value <= 1), | ||
| constraint lineage_estimation_method_check | ||
| check (btrim(estimation_method_code) <> ''), | ||
| constraint lineage_estimator_version_check | ||
| check (btrim(estimator_version) <> ''), | ||
| constraint lineage_anchor_method_check | ||
| check (btrim(anchor_method_code) <> ''), | ||
| constraint lineage_sample_pair_count_check | ||
| check (sample_pair_count >= 200), | ||
| constraint lineage_source_snapshot_check | ||
| check (source_snapshot_sha256 ~ '^[0-9a-f]{64}$'), | ||
| constraint lineage_knowledge_cutoff_check | ||
| check (knowledge_cutoff <= estimated_at) | ||
| ); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| -- Rollback for 0135: remove the unavailable channel-weight persistence | ||
| -- contract and the raw grouping provenance columns introduced with it. | ||
|
|
||
| drop table if exists lineage_channel_weight; | ||
|
|
||
| alter table source_post | ||
| drop column if exists source_secondary_grouping_key, | ||
| drop column if exists source_thread_group_key; |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Migration 0103 absent from the replay gate
The replay gate gains
0135_*but0103_tenant_settings.sqlstays excluded.migrate.shreplays migrations on every compose up, so volumes predating 0103 never createtenant_settings, andread_tenant_settingsin main.py then 500s on undefined_table. It cannot simply be added: 0103 lacks IF NOT EXISTS and would fail replay where the table already exists. Pre-existing, but this line is edited here.Was this helpful? React with 👍 or 👎 to provide feedback.