Skip to content

fix(overview-metrics): count stale assets and orphan terms inside Egeria - #572

Merged
dwolfson merged 2 commits into
odpi:mainfrom
dwolfson:fix/native-counts-dashboard-analytics
Nov 9, 2026
Merged

dwolfson merged 2 commits into
odpi:mainfrom
dwolfson:fix/native-counts-dashboard-analytics

Conversation

@dwolfson

@dwolfson dwolfson commented Nov 9, 2026

Copy link
Copy Markdown
Member

Stale Assets gives a real answer, from about log2(N) one-row reads instead of one capped page; Orphan Glossary Terms runs its slow viewer count alongside its scan. For pyegeria 6.2.29: the pyegeria half of the owner's "both" (native counts in pyegeria, plus a Portal cache) for the slow local-dashboard analytics.

Branch fix/native-counts-dashboard-analytics off upstream/main 259ca15 (6.2.28). One commit: 1f7ec15. No Egeria writes. No version bump.

What Egeria can and cannot count (checked in Java source and live, read-only)

  • It cannot count by update time. A search condition reaches only an element's own properties. updateTime is in the header, so no search condition can test it.
    • Live, a count of Asset with updateTime LT <cutoff> (and createTime, as date or long) answered 0, in the repository population.
    • In the postgres connector's QueryBuilder, update_time is only a sort column.
    • The header-property matching in OMRSRepositoryContentValidator.countMatchingHeaderPropertyValues is equality-only, on the in-memory path.
  • It can sort by update time, with sequencingOrder: LAST_UPDATE_OLDEST. updateTime is set at create, so no row lacks one.
  • startFrom is an offset into the repository's own sorted rows. Live, single-row pages at offsets 0–11 returned the same rows as one 12-row page, with empty pages at offsets 6, 8, 9 and 11: rows erinoverview cannot see keep their offsets.
  • It cannot count the distinct ends of a relationship type. FindRelationshipRequestBody filters by end GUIDs and types, but it has no distinct or group-by. So "terms with at least one SemanticAssignment" still needs the relationship scan.

Changes

stale_assets: bisection over update-time order (_rows_updated_before)

  • staleCount is the offset of the first Asset updated at or after the cutoff.
    • It is found by one-row reads, bisecting between 0 and the native Asset count.
    • When the window is 25 rows or fewer, one read of the whole window settles it, if every row in it is visible.
    • That is about log2(N / 25) + 1 reads: 12 for 37,000 Assets. It never reads a page of Assets.
    • Reads are capped by MAX_BISECT_READS = 64.
  • Population: repository, for both figures.
    • A hidden row between two rows updated before the cutoff was updated before it too, because the order is by update time. So it counts, like it does in assetTotal, the native push-down count.
    • 6.2.28 had assetTotal in the viewer population, which timed out at 30 s live.
    • This follows feat(overview-metrics): totals count the whole repository (push-down) by default #556's repository default for counts. The two figures stay in one population.
  • When it is not measured (None plus an unmeasured note, never a sample's figure):
    • the native count failed (then nothing is read);
    • a read failed;
    • the reads ran out;
    • rows the viewer cannot see sit exactly at the cutoff. Then the note gives the range ("between 295 and 305") and at_least.
  • Small risk: an Asset updated while the bisection runs moves to the end of the order and can shift offsets by one. This is documented.
  • Declaration:
    • Both measures declare population="repository".
    • staleCount gets assetTotal as its basis.
    • The description and cost line carry REPOSITORY_WORDS.
    • The not_measured sentence names the hidden-rows case.

orphan_glossary_terms: the two reads now run at once

  • The exact answer needs the paged SemanticAssignment scan from fix(overview-metrics): scans read every page or report nothing; a failed viewer count is None #565.
  • Its term total stays a viewer count, so the payload stays in one population. That count is slow: 13.5 s live, against 0.7 s for the repository count.
  • It now runs on a one-worker thread (contextvars.copy_context(), so its note reaches the caller's recording_unmeasured()) while the scan pages.
  • The answer is unchanged: 984 orphans of 1,061 terms.

Docs

  • docs/output-formats-and-report-specs.md gains two paragraphs: Counting by update time (6.2.29) and Distinct relationship ends cannot be counted natively. The Scans and Population paragraphs now say stale_assets moved.
  • New docs/release-notes/6.2.29.md.

Live before/after (read-only, as erinoverview)

Method:

  • 2026-11-09, qs-view-server, through exec_report_spec(label, params={}), as the Coordinator measured.
  • One routine at a time.
  • Before = upstream/main 259ca15, run in this worktree before the change. After = this branch.
  • Egeria's own latency varied between runs: the same one-row read took 0.8–3.3 s.
routine before (259ca15) after (this PR)
Analytic Demo - Stale Assets 34.5 s: staleCount None, assetTotal None. Notes: "the find stopped at its 500-element page cap…" and "Asset: the native count timed out, and the find fallback stopped at its 500-element page cap, so there are at least 500" 13.3 s: staleCount 287, assetTotal 37,568, no notes
Analytic Demo - Orphan Glossary Terms 22.6 s: termTotal 1,061, referenced 77, orphans 984 16.8 s: termTotal 1,061, referenced 77, orphans 984
Analytic Demo - Catalog Growth Trend 7.3 s: 6 points, May 13 assets 287 / terms 200 / governed 55 / products 3 → Nov 9 37,489 / 1,061 / 884 / 412 8.6 s: same series (unchanged code; Nov 9 assets 37,556)
Analytic Demo - Ownership Coverage 4.6 s: 422, Unspecified 411, SolutionActorRole 11 4.4 s: same (unchanged code)
Analytic Demo - Governance Coverage 5.9 s: governed 256, fully 11, zone-only 245 6.5 s: same (unchanged code)

Checking 287:

  • The bisection read offsets 286–288 one row at a time. Row 286 was updated 2026-04-01 and row 287 on 2026-11-07, with no hidden rows between.
  • Catalog Growth's own native as-of count for 13 May 2026, the cutoff, is also 287 Assets. That is an independent check: no Asset that existed then has been updated since.

Where the time goes now:

  • Stale Assets is one 0.8–2.8 s native count, then 11 one-row reads and one 17-row read, at about 1 s each (instrumented run: 15.0 s).
  • Orphans is about the viewer term count (13.5 s), with the scan (about 9 s, 747 relationships of about 8 KB each) under it.

The next three (looked at; not changed)

  • Catalog Growth Trend does not page. It is 24 native counts: 6 points × 4 series, about 0.3 s each, one after another.
    • Running them concurrently, capped as asset_composition is at 5, would make it about 2 s.
    • That is a concurrency change, not a count replacing a page, so it is left as a follow-up.
  • Ownership Coverage reads one find page of 422 Ownership-classified elements, plus the empty page.
    • ownershipCount alone could be a native count.
    • byOwnerType reads ownerTypeName from each Ownership classification, an open set of values. A native count needs each value known in advance.
    • Replacing only the total would also move it to the repository population beside a viewer breakdown. No change.
  • Governance Coverage reads one find page: 256 elements erinoverview can see.
    • governedCount, fullyGoverned and partialZoneOnly could be native counts, about 3 per call.
    • byClassification (every classification on a governed element, including Anchors and UsageActivity, an open set) and topZones (zone values) need the elements.
    • So a count would not remove the page. No change.
    • Worth labelling on the dashboard: this tile says 256 (viewer population), while Catalog Growth's "governed" series says 884 (repository population) for the same classifications.

Tests

  • Full suite, uv run -p 3.13 pytest tests/micro-tests/ (Python 3.13.2), JUnit counts: at 1f7ec15, 2,561 collected, 2,558 passed, 3 skipped, 0 failed.
  • New test_native_counts_dashboard.py. Every test fails on the old module except test_the_term_count_note_from_its_thread_reaches_the_caller, a control (checked). Its fake is a sorted repository: a list of update times, with None for a row the viewer cannot see, served from startFrom in LAST_UPDATE_OLDEST order.
    • 287 of 37,431 in at most 13 reads; every read but the last is one row, and the last is at most 25 rows. The bodies carry asOfTime, and the count is push-down.
    • Hidden rows inside the stale run count.
    • A hidden row near the cutoff still gives the exact count, or a range that holds it.
    • Hidden rows at the cutoff give a range note, not a count.
    • A failed count measures neither figure and reads nothing.
    • A failed read is not measured.
    • The read budget holds.
    • Edges: none stale, all stale, empty, one row.
    • as_of anchors the cutoff.
    • 40 randomized repositories (up to 3,000 rows, a fifth of them hidden): the bisection equals a count of every row, or its note's range holds the truth.
    • The declaration says repository for both measures.
    • Orphans: a fake count that only returns once the scan has started proves the two run at once (still 1,061 / 77 / 984), and the viewer count's note from its thread reaches the caller.
  • test_capped_scans_not_counts.py: its two stale_assets one-page tests are replaced by the above.
  • ruff: clean on the changed code. The one remaining finding, an unused Callable import in overview_metrics.py, pre-exists.

Consumers (not changed here)

  • stale_assets output shape is unchanged. staleCount is now a number where it was None on every catalog over 500 Assets, and assetTotal is now a repository count.
    • The Portal payload's countScope: "repository" label is now true of stale_assets.
    • orphan_glossary_terms stays viewer-scoped inside that payload, as before.
  • The Portal cache is the other half of the owner's decision. Stale Assets is still about 13 s and Orphans about 17 s per call on this catalog, so they are worth caching.

Follow-ups (not changed here)

  • Egeria: a native count by an update-time condition, a header-property search condition such as updateTime LT, would make stale_assets one call. So would a distinct-end relationship count for orphan_glossary_terms.
  • Catalog Growth: run its 24 native counts concurrently (cap 5).
  • Governance and Ownership: label their viewer population beside Catalog Growth's repository "governed" series (256 vs 884).
  • ai_ready_assets and drl_readiness_gates still read one Asset page, and are None + capped: true on this catalog. The bisection does not apply: "has DataFlow" is not an order.

Review

  • Coordinator gate on Python 3.13 at 1f7ec15: 2,561 tests, 0 failed, 0 errors, 3 skipped.
  • Architect read-back: PASS. Stale count 287 verified at the cutoff boundary by offset; orphans 984 = 1,061 − 77 re-paged independently. Not yet proven: behaviour for a restricted viewer (erinoverview sees every Asset).

🤖 Generated with Claude Code

…orphan terms count while scanning

Egeria cannot count by an update-time condition: a search condition reaches
only an element's own properties, so `updateTime LT <cutoff>` counts 0
(checked live and in the postgres QueryBuilder). It does sort by update time,
and startFrom is an offset into the repository's sorted rows. So stale_assets
now finds the stale count as the offset of the first Asset updated at or after
the cutoff: about log2(N/25) one-row reads plus one read of the last 25-row
window, never a page of Assets. Both figures are in the repository population.
Live as erinoverview: 287 of 37,568 Assets in 13.3 s, where 6.2.28 took 34.5 s
to report "not measured". Hidden rows exactly at the cutoff, a failed read or
an exhausted read budget give None plus a note (with the range).

Distinct relationship ends cannot be counted natively, so
orphan_glossary_terms keeps its SemanticAssignment scan; its slow viewer term
count (13.5 s) now runs on its own thread while the scan pages: 22.6 s -> 16.8 s,
same answer (984 of 1,061).

Catalog Growth, Ownership and Governance were reviewed: none pages where a count
would do (see the PR body).

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>

# Conflicts:
#	docs/release-notes/6.2.29.md
@dwolfson
dwolfson merged commit 8d5bd55 into odpi:main Nov 9, 2026
6 checks passed
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