feat(dashboard): show observed model on learning details - #148
feat(dashboard): show observed model on learning details#148wenchanghan wants to merge 11 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe dashboard now reads model provenance from Reflexio SQLite lineage data, exposes it through an API and React hook, and displays it on preference and skill detail pages. ChangesLearning model provenance
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant DetailPage
participant useLearningModelProvenance
participant model_provenance_GET
participant getLearningModelProvenance
participant ReflexioSQLite
DetailPage->>useLearningModelProvenance: provide entityType and entityId
useLearningModelProvenance->>model_provenance_GET: fetch provenance query
model_provenance_GET->>getLearningModelProvenance: request validated lineage
getLearningModelProvenance->>ReflexioSQLite: read recent lineage events
ReflexioSQLite-->>getLearningModelProvenance: return lineage rows
getLearningModelProvenance-->>model_provenance_GET: return provenance
model_provenance_GET-->>useLearningModelProvenance: return JSON provenance
useLearningModelProvenance-->>DetailPage: expose provenance state
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plugin/dashboard/lib/model-lineage.ts`:
- Around line 7-10: Align the dashboard package’s declared Node.js engine
requirement with the node:sqlite DatabaseSync usage in model-lineage, ensuring
the minimum runtime supports the readOnly option; alternatively, replace the
read-only SQLite implementation with an approach compatible with Node >=20.9.0.
- Around line 130-132: Update the provenance route around emptyProvenance and
NextResponse.json({ provenance }) to replace filesystem paths and raw SQLite
diagnostics with fixed public reasons such as “database unavailable” for missing
databases and “provenance query failed” for query or database errors. Keep the
detailed path and SQLite error information only in server-side logging, while
preserving successful provenance responses.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 38efc6af-73a0-44d8-9f70-c16331343de2
⛔ Files ignored due to path filters (4)
docs/pr-assets/model-provenance/pref-match.pngis excluded by!**/*.pngdocs/pr-assets/model-provenance/pref-mismatch.pngis excluded by!**/*.pngdocs/pr-assets/model-provenance/project-skill.pngis excluded by!**/*.pngdocs/pr-assets/model-provenance/shared-skill.pngis excluded by!**/*.png
📒 Files selected for processing (8)
plugin/dashboard/app/api/learning-model-provenance/route.tsplugin/dashboard/app/preferences/[id]/page.tsxplugin/dashboard/app/skills/project/[id]/page.tsxplugin/dashboard/app/skills/shared/[id]/page.tsxplugin/dashboard/components/common/model-provenance.tsxplugin/dashboard/lib/model-lineage.tsplugin/dashboard/lib/model-provenance.tsplugin/dashboard/types/node-sqlite.d.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plugin/dashboard/lib/model-lineage.ts`:
- Around line 143-151: Update the emptyProvenance call in the lineage_event
table-missing branch to pass true for the availability flag, so missing lineage
data renders as Unavailable while preserving the existing entity details and
message.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 050d1881-8743-474e-8ed6-9108ee305a6f
⛔ Files ignored due to path filters (3)
docs/pr-assets/model-provenance/pref-historical.pngis excluded by!**/*.pngdocs/pr-assets/model-provenance/pref-with-model.pngis excluded by!**/*.pngdocs/pr-assets/model-provenance/project-skill.pngis excluded by!**/*.png
📒 Files selected for processing (3)
plugin/dashboard/components/common/model-provenance.tsxplugin/dashboard/lib/model-lineage.tsplugin/dashboard/lib/model-provenance.ts
💤 Files with no reviewable changes (1)
- plugin/dashboard/lib/model-provenance.ts
Surface provider/model from local lineage_event on preference and skill detail pages so config mismatches (requested vs observed) are visible without using the Reflexio HTTP API.
Fixture-only images used for PR visual evidence; no real session data.
Drop requested_model/credential mismatch logic. Detail pages now show provider/model from lineage when present, and "Not recorded" for historical rows without those fields.
Align dashboard Node engine with node:sqlite readOnly, sanitize public error reasons, and treat a missing lineage_event table as unavailable.
Keep only observed provider/model display, simplify the SQLite reader to a single ranked query, and drop unused lineage metadata plus PR binary screenshot assets from the branch.
Expose observed model via a thin local /api/model-provenance route that reads SQLite directly, matching the origin/session local-data pattern, and lock the contract with dashboard static tests.
Replace design-shape static assertions with SQLite fixture tests for observed model, historical missing fields, schema without model columns, missing entity, and missing database.
Remove redundant force-dynamic on the local model-provenance route and simplify the SQLite reader test helper.
8ec983f to
dd65feb
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/test_model_lineage_reader.py (1)
190-193: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd coverage for a missing
lineage_eventtable.A database can exist without this table. Assert that this case returns
unavailable: true. This protects theUnavailableUI contract from regression.Proposed test
+def test_reader_missing_lineage_table_is_unavailable(tmp_path: Path) -> None: + db = tmp_path / "reflexio.db" + sqlite3.connect(db).close() + + result = _run_reader(db, "profile", "pref-1") + assert result["unavailable"] is True + assert result["reason"] == "lineage_event table not present"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_model_lineage_reader.py` around lines 190 - 193, Add a test alongside test_reader_missing_database_is_unavailable that exercises an existing database without the lineage_event table, invoking _run_reader with the same representative inputs and asserting result["unavailable"] is True. Also assert the expected unavailable reason for the missing table, preserving the Unavailable UI contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plugin/dashboard/lib/model-provenance.ts`:
- Around line 22-31: Update the useEffect request flow to clear the existing
provenance state immediately when entityType or entityId changes, before
initiating fetch. Preserve the current cancellation and loading behavior,
ensuring stale metadata is not rendered while the new request is pending.
---
Nitpick comments:
In `@tests/test_model_lineage_reader.py`:
- Around line 190-193: Add a test alongside
test_reader_missing_database_is_unavailable that exercises an existing database
without the lineage_event table, invoking _run_reader with the same
representative inputs and asserting result["unavailable"] is True. Also assert
the expected unavailable reason for the missing table, preserving the
Unavailable UI contract.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b04f49d7-728f-4f9d-b4e0-a8ec3d5df708
📒 Files selected for processing (10)
plugin/dashboard/app/api/model-provenance/route.tsplugin/dashboard/app/preferences/[id]/page.tsxplugin/dashboard/app/skills/project/[id]/page.tsxplugin/dashboard/app/skills/shared/[id]/page.tsxplugin/dashboard/components/common/model-provenance.tsxplugin/dashboard/lib/model-lineage.tsplugin/dashboard/lib/model-provenance.tsplugin/dashboard/package.jsonplugin/dashboard/types/node-sqlite.d.tstests/test_model_lineage_reader.py
🚧 Files skipped from review as they are similar to previous changes (5)
- plugin/dashboard/package.json
- plugin/dashboard/components/common/model-provenance.tsx
- plugin/dashboard/app/skills/project/[id]/page.tsx
- plugin/dashboard/app/skills/shared/[id]/page.tsx
- plugin/dashboard/app/preferences/[id]/page.tsx
Clear outdated model metadata as soon as the detail page target changes, and cover the missing lineage_event table path in the reader tests.
Lazy-load node:sqlite and restore the dashboard engines floor so install and CI Node 20 matrices can build without evaluating sqlite at module load.
Use a filesystem path with createRequire so Next does not break lazy sqlite loading via rewritten import.meta.url values.




What's broken / annoying
Learning detail pages show origin host, but not which model generated the learning. When generation drifts, that is hard to notice from the UI.
What's changing
Add a Model field to preference and skill detail metadata.
It reads observed
provider/model_namefrom local SQLitelineage_eventthrough a thin local dashboard route (/api/model-provenance), then renders:provider/modelwhen presentNot recordedfor historical rows without model fieldsUnavailablewhen the local DB cannot be readList views are unchanged. There is no requested-model or live-config comparison.
How the product behaves afterwards
On preference, project-skill, and shared-skill detail pages, the right-hand metadata panel shows the observed generation model next to existing metadata such as origin.
How it was verified
main(d096b3b)npx tsc --noEmitinplugin/dashboardpytest tests/test_model_lineage_reader.py(7 behavioral SQLite fixture cases)pytest tests/test_dashboard_managed_reflexio.pynext buildfor the dashboardminimax/MiniMax-M3Not recordedminimax/MiniMax-M3Not recordedRisks / follow-ups
node:sqliteat request time. That needs a runtime with sqlite support (Node>=22.18forDatabaseSync({ readOnly })); older runtimes returnUnavailable.>=20.9.0so install/build matrices stay compatible.