Skip to content

fix(lineage): preserve grouping provenance and fail closed weights - #506

Closed
seonghobae wants to merge 3 commits into
mainfrom
codex/pr499-fail-closed-main-20260824
Closed

fix(lineage): preserve grouping provenance and fail closed weights#506
seonghobae wants to merge 3 commits into
mainfrom
codex/pr499-fail-closed-main-20260824

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • restacks the feature portion of PR feat(lineage): estimate channel-fusion weights psychometrically (ADR 0145) #499 directly onto exact current main without the 769-commit docs/customer-master-scope-adr ancestry
  • preserves caller-mapped raw grouping values while deriving placeholder-free reconstruction grouping
  • probes lineage_channel_weight with to_regclass so a missing rollout table does not abort the outer transaction
  • rejects unanchored channel-weight estimation and activates no persisted vector without an independently approved anchor and complete provenance

Provenance

  • prerequisite feature commit: a985f82
  • completed remediation source: 715ca0c6b7da87d0f3ed336ec40a2838f9e9eb8b
  • restacked commits: ad6dc00 and ba90cbe
  • base: ef6f5a5

The only conflict resolutions were base-specific: register migration 0135 without importing absent unrelated migration families, and adapt the importer insert from 30 to 32 parameters rather than the docs-branch 36-parameter schema.

Verification

  • uv run --frozen --extra dev --extra backend pytest -q tests/test_channel_weight_estimation.py tests/test_estimate_channel_weights_script.py tests/test_backfill_thread_group_keys.py tests/test_import_postgresql_posts.py tests/test_lineage_ingestion.py tests/test_migration_replay.py (43 passed)
  • uv run --frozen --extra dev --extra backend pytest -q backend/tests/test_api.py::test_rebuild_lineage_recovers_the_a100_fork (1 passed)
  • uv run --frozen --extra dev --extra backend python -m compileall -q on changed Python modules
  • git diff --check origin/main..HEAD

No real source records or identifying examples are included.


Open in Devin Review

seonghobae and others added 2 commits August 24, 2026 01:08
…0145)

The convex weights reconstruct() fuses its evidence channels with were
hand-picked constants justified only by a code comment. ADR 0145
replaces assertion with estimation: channels are items observing the
latent "these posts are related" trait, scored candidate pairs are
respondents nested in reconstruction groups, and fast-mlsirm's
multilevel 2PL (MLS2PLM, mmle estimator with cluster random intercepts
per Fox & Glas 2001) estimates per-channel discriminations -- the
information-optimal weights per Birnbaum (1968). Fail-closed at every
step: no fast_mlsirm, too small a sample, a degenerate channel, or a
non-finite estimate produces no weights and rebuilds keep the (now
explicitly labeled) fallback constants; persisted weights are used only
on an exact active-channel-set match, never mixed.

Also lands the grouping-evidence backfill this estimation depends on:
the zcrht811 import stuffed per-row-unique identifiers into BOTH
grouping columns (thread_group_key = own record GUID on 43,811/43,839
rows; secondary_grouping_key = own document number), so _group_by saw
~43k singleton groups and no channel ever scored a real candidate pair
-- Event Lineage was silently non-functional corpus-wide.
backfill_thread_group_keys.py clears the placeholder signature rows to
'' (migration 0002's designed "no signal" value; grouping falls back to
process-unit/corporate-entity candidate pools) and routes
source_project_code to secondary_grouping_key -- the secondary-key
channel's documented signal ("e.g. project code") -- as fused evidence,
never a hard partition that would wall related posts apart. Fails
closed when an analysis_scope_thread_group run (TEPP/report scope keys
resolve live against thread_group_key) would be orphaned.

Verified: parameter-recovery test recovers planted discrimination
ordering (strong > mid > weak) via the real fast-mlsirm fit; estimation
script fails closed against the live un-backfilled corpus (105 pairs <
200 minimum, nothing written); a100-fork rebuild regression stays
green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015HgzNGsCxqiTaT4YuJEb5J
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3946f774-f76e-4ac8-b111-cc768d277827

📥 Commits

Reviewing files that changed from the base of the PR and between ef6f5a5 and fd27f2d.

📒 Files selected for processing (18)
  • backend/app/lineage_ingestion.py
  • backend/tests/test_api.py
  • docker/postgres-init/migrate.sh
  • docs/adr/0145-psychometric-channel-weight-estimation.md
  • lineageweave/channel_weight_estimation.py
  • lineageweave/lineage_persistence.py
  • lineageweave/reconstruct.py
  • migrations/0135_lineage_channel_weight.sql
  • migrations/rollback/0135_lineage_channel_weight.sql
  • scripts/backfill_thread_group_keys.py
  • scripts/estimate_channel_weights.py
  • scripts/import_postgresql_posts.py
  • tests/test_backfill_thread_group_keys.py
  • tests/test_channel_weight_estimation.py
  • tests/test_estimate_channel_weights_script.py
  • tests/test_import_postgresql_posts.py
  • tests/test_lineage_ingestion.py
  • tests/test_migration_replay.py

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

Copy link
Copy Markdown
Contributor Author

Superseded by #507. The clean single-commit restack preserves the validated final tree while keeping private source identifiers out of the protected-main route. No force-push was used.

@seonghobae seonghobae closed this Aug 23, 2026

@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 1 potential issue.

Open in Devin Review

case "$migration_name" in
0012_*|0013_*|0014_*|0015_*|0016_*|0017_*|0018_*|0019_*|0020_*|0021_*|0022_*|0023_*|0024_*|0025_*|0026_*|0027_*|0028_*|0029_*|0030_*|0031_*|0032_*|0033_*|0034_*|0035_*|0036_*|0037_*|0038_*|0039_*|0040_*|0041_*|0042_*|0043_*|0044_*|0045_*|0046_*|0047_*|0048_*|0049_*|0050_*) ;;
0060_*|0100_*|0101_*|0102_*) ;;
0060_*|0100_*|0101_*|0102_*|0135_*) ;;

Copy link
Copy Markdown

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_* but 0103_tenant_settings.sql stays excluded. migrate.sh replays migrations on every compose up, so volumes predating 0103 never create tenant_settings, and read_tenant_settings in 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.

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