Skip to content

feat(dashboard): consume TEPP topic influence evidence - #650

Merged
seonghobae merged 5 commits into
feat/dashboard-case-metricsfrom
feat/dashboard-topic-influence-consumer
Aug 25, 2026
Merged

feat(dashboard): consume TEPP topic influence evidence#650
seonghobae merged 5 commits into
feat/dashboard-case-metricsfrom
feat/dashboard-topic-influence-consumer

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Outcome

  • persists TEPP temporal topic posteriors and fast-mlsirm multilevel/multiple-membership influence in normalized, provenance-bound tables
  • fails closed until both exact producer envelopes are persisted and the full fitted scope is authorized
  • renders exact topic activity, lineage, memberships, tied influence values, uncertainty, and provenance without local math or weights

Verification

  • focused backend/API coverage: 100% for operations_dashboard.py
  • PostgreSQL migration replay and provenance-trigger tests passed
  • OperationsDashboard component: 7 tests passed
  • Storybook accepted/unavailable scenes built and desktop/mobile screenshots audited

Upstream readiness

TEPP PR #247 defines the posterior envelope. fast-mlsirm PR #1395 is closed without merge and its topic-context endpoint remains explicitly unavailable, so production truthfully reports fast_mlsirm_influence_not_persisted rather than fabricating values.

Stacked on #640.


Open in Devin Review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@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: 625ef5fd-cedc-4b34-b051-6f194fc8e028

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

Copy link
Copy Markdown
Contributor Author

Reviewed exact head a9c25e65 after incorporating the concurrently pushed parent-sync merge. The branch now preserves the parent dashboard changes, keeps both topic-influence and external-scope tests, and orders migrations deterministically: the operations target migration is 0213, while the topic influence projection is 0214 to avoid the independently queued 0212 knowledge-cutoff migration.

The focused external-relation test needed an explicit unavailable topic-producer response; otherwise its mock returned a case row to the new topic query and failed with a missing topic_index. The mock now models the real fail-closed boundary.

Local evidence: uv run --extra dev --extra backend pytest -q tests/test_operations_dashboard.py tests/test_schema.py tests/test_operations_case_analysis.py tests/test_operations_case_ingestion.py -k 'operations or migration' → 23 passed, 18 deselected.

@seonghobae
seonghobae merged commit 42492e3 into feat/dashboard-case-metrics Aug 25, 2026
3 of 4 checks passed

@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

where {authorized_model_scope}
) as fast_mlsirm_influence_persisted
""",
*args,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Dashboard crashes on every non-external request

_fetch_topic_context_dashboard passes all five query parameters (*args) to two SQL statements that reference only $1$4; the fifth (external_only) is unused. asyncpg rejects the extra argument, so every non-external dashboard request fails. The mock-connection tests never bind real parameters, so CI stays green.

Prompt for agents
In _fetch_topic_context_dashboard (backend/app/operations_dashboard.py), both conn.fetchrow (the readiness query around line 393) and conn.fetch (the rows query around line 490) are called with *args, where args is the 5-element tuple built in fetch_operations_dashboard: (corporate_entity_ids, process_unit_ids, period_start, period_end, external_only). However, these two SQL statements only reference positional parameters $1 through $4 (via _visible_period_sql and authorized_model_scope); they never reference $5. asyncpg requires the number of passed arguments to exactly match the highest parameter referenced in the query, so passing 5 args to a 4-parameter query raises InterfaceError and the dashboard endpoint fails for every non-external request. Fix by passing only the first four arguments (e.g. *args[:4]) to both topic-context queries, since external_only is already handled by the caller before this function runs.
Open in Devin Review

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

Comment on lines +448 to +452
join topic_activity_interval activity
on activity.topic_model_run_id = influence.topic_model_run_id
and activity.topic_index = influence.topic_index
and visible_post.occurred_at >= activity.valid_from
and visible_post.occurred_at < activity.valid_to

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Influence rows dropped when no activity interval covers the post

The eligible CTE inner-joins topic_activity_interval on the post's occurred_at falling within [valid_from, valid_to). A post whose event time lands in a gap between intervals is silently dropped, so an authorized influential post never appears. Confirm the producer guarantees gap-free interval coverage.

Open in Devin Review

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

Comment on lines +362 to +394
readiness = await conn.fetchrow(
f"""
with visible_post as (
select post.post_id
from source_post post
where {visible_post_sql}
)
select exists (
select 1
from topic_context_membership membership
join topic_model_run model
on model.topic_model_run_id = membership.topic_model_run_id
join analysis_run analysis on analysis.analysis_run_id = model.analysis_run_id
join analysis_run_scope scope on scope.analysis_run_id = analysis.analysis_run_id
join visible_post on visible_post.post_id = membership.source_post_id
where {authorized_model_scope}
) as tepp_posterior_persisted,
exists (
select 1
from topic_post_context_influence influence
join topic_context_membership membership
on membership.topic_model_run_id = influence.topic_model_run_id
and membership.topic_context_membership_id = influence.topic_context_membership_id
join topic_model_run model
on model.topic_model_run_id = influence.topic_model_run_id
join analysis_run analysis on analysis.analysis_run_id = model.analysis_run_id
join analysis_run_scope scope on scope.analysis_run_id = analysis.analysis_run_id
join visible_post on visible_post.post_id = membership.source_post_id
where {authorized_model_scope}
) as fast_mlsirm_influence_persisted
""",
*args,
)

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: Readiness query runs even when unused

The readiness fetchrow executes on every non-external request, but its result is consumed only in the if not rows: branch. When accepted rows exist, it is a wasted round-trip; it could be deferred until rows is empty.

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