Skip to content

feat(analytic-registry): declarations for every registered routine (RS-W2-1a) - #539

Merged
dwolfson merged 6 commits into
odpi:mainfrom
dwolfson:feat/rs-w2-1a-routine-declarations
Nov 7, 2026
Merged

dwolfson merged 6 commits into
odpi:mainfrom
dwolfson:feat/rs-w2-1a-routine-declarations

Conversation

@dwolfson

@dwolfson dwolfson commented Nov 7, 2026

Copy link
Copy Markdown
Member

RS-W2-1a (Wave 2 delivery step (a), pyegeria half). Every routine in analytic_registry now declares what it returns: measures with unit and as-of, the four nothing_found-vocabulary absence sentences, and an out field list in the §5 vocabulary. Decisions applied: D1 (declarations stay as Python literals beside each entry), D2 (the model mirrors egeria-trellis-analytics; a cross-validation test checks it), D6 (count_relationships, drl_readiness_gates and solution_component_realisation are registered and declared).

Census: 0 undeclared of 28 entries (the 24 undeclared ones, asset_composition, and the 3 newly registered).

Model (commit 1)

  • MeasureDeclaration.completeness_field replaces capped_field. capped_field is still read and gives a DeprecationWarning, as in library 0.3. population (viewer | repository) is new. A basis on a share is refused.
  • New: FieldDeclaration/FieldCompanion (§5 Field), AnalyticDeclaration.out, and the categories and listing blocks the library requires for distribution and list results. ROW_SHAPES holds the row shapes that dataset fields name.
  • as_of="run.as_of" names the call's own as_of argument (the library's run.<field> convention), because these results carry no time of their own. A bare-number result declares value_field: value, the key metric_trend already uses.
  • test_declarations_match_library.py: every declaration loads as a library Declaration, its out loads as a library Shape, and every row shape registers. It is skipped when trellis_analytics isn't installed and passes against 0.3.1 (60 passed). pyegeria-only keys (MeasureDeclaration.population, Declaration.out) are dropped before validation only if the installed library doesn't have that field, so 0.4 checks them too.
  • Field-level differences from the brief's sketch: no description or states on fields. The library's Field has neither and refuses unknown keys. A named state set goes in companions: [{name: state, valid_values: <set>}]. The cost class is in each spec's description, because neither declaration model has a description.

The 28 routines

name result_kind measures cost class generic?
active_contributors measure contributors, raters, commenters, likers, taggers, note_loggers five capped relationship pages, seconds no
ai_ready_assets measure assets_checked, ai_ready_assets one capped Asset find plus one capped DataFlow relationship page, seconds no
asset_composition distribution repository_count, viewer_count, not_visible one count per type per population in a pool of 3-5; repository counts sub-second, viewer counts can take minutes for a large type (Process: 120 s) yes
business_value_signals measure assets_read, confidential_assets, described_assets, duplicate_elements one capped Asset find plus one count, seconds no
certifications_summary measure certifications, expiring_certifications, licenses, exceptions three capped relationship pages, seconds no
context_readiness_funnel measure cataloged, documented, classified, lineage two counts, one capped Asset find and one relationship page, seconds no
contextualised_coverage measure contextualised_assets, assets, contextualised_percent one capped relationship page plus one count, seconds no
control_implementation_summary distribution not_started, planned, partially_implemented, implemented, other one read of one statement of applicability's control relationships, seconds no
count_elements measure elements one native count, sub-second in the repository population (0.2-0.8 s measured); a viewer-population count reads every element and can take minutes for a large type (Process: 120 s); a server with no native count falls back to a capped find yes
count_elements_by_property measure elements one native count, sub-second in the repository population; a viewer-population count can take minutes for a large type yes
count_relationships measure relationships one relationship page, seconds; the native count is sub-second yes
counts_by_type distribution count one native count per type, sub-second each in the repository population; a viewer-population count can take minutes for a large type yes
drl_readiness_gates measure assets_checked, ai_ready_assets, ai_ready_recent_assets, tabular_assets, text_media_assets, other_assets one capped Asset find and one capped DataFlow relationship page, seconds no
engagement_series series feedback, comments, ratings, likes, tags, note_logs five capped relationship pages, seconds no
feedback_summary measure feedback, ratings, comments, likes, tags, note_logs five relationship pages (native counts when an expert client is passed), seconds no
governed_coverage measure governed_elements, fully_governed, zone_only one capped find (one page of elements), seconds no
growth_series series assets, terms, governed, products one count per series per snapshot (four series by default), seconds to tens of seconds yes
karma_leaderboard list karma_points one capped find, seconds no
metric_trend series value the target routine's cost once per snapshot yes
orphan_glossary_terms measure terms, referenced_terms, orphan_terms one count plus one capped relationship page, seconds no
ownership_coverage measure owned_elements one capped find (one page of elements), seconds no
people_counts measure persons, teams, organizations, it_profiles, communities five native counts, sub-second each in the repository population no
semantic_grounding measure grounding_links, grounding_percent one count plus one capped relationship page, seconds no
solution_component_realisation measure solution_components, realised_components one native count plus one capped ImplementedBy relationship page, seconds no
stale_assets measure stale_assets, assets one capped Asset find plus one count, seconds no
sum_type_counts measure total as counts_by_type: one native count per type yes
term_definition_completeness measure terms_read, defined_terms, undefined_percent one capped find, seconds no
usage_context_counts measure supply_chains, blueprints two native counts, sub-second each in the repository population no

Only the 10.8 data points are measured timings (repository counts 0.2–0.8 s; viewer count of Process 120 s). The other cost classes come from each routine's query shape.

generic is unchanged for growth_series and asset_composition, which are True (the brief lists five). _demo() builds each demo spec's description from generic/binding_note, so changing either would break the byte-identical gate.

Behaviour: demo specs byte-identical; only failure results change

Snapshot of all 23 demo specs and of all 27 callable routines under fake clients, one run succeeding and one with every query failing, before (upstream/main 3f1fa35) and after:

  • 23/23 demo FormatSets identical (model_dump).
  • Every successful run is identical.
  • Seven failure runs change, each from a measured-looking 0 to None. This is the brief's §3.3 fix, made in the same commit as that routine's declaration:
routine failure result before after
ownership_coverage ownershipCount 0, ownershipCapped false both None (as governed_coverage already was)
active_contributors 0 per failed type, smaller union failed type None; contributors None unless every type was read
context_readiness_funnel documented 0 None
ai_ready_assets {0, 0, false}; also aiReadyCount 0 when only DataFlow failed Nones; total/capped kept when only DataFlow failed
drl_readiness_gates all 0 all None; ready counts None when only DataFlow failed
term_definition_completeness total 0, defined 0 all None
stale_assets staleCount 0 None

The Portal's Overview (overview_handler.py, odpi main) already guards these fields with if x:/try, so it shows no number where it showed 0. Two existing tests pinned the old 0s and now pin None. exec_report_spec uses a declaration only through _absence_for, which needs an envelope. Of these routines only asset_composition returns one, and its sentences haven't changed.

Gaps the declarations expose, not fixed here (the fix would change a signature or a successful result)

  • Governed coverage is not Asset-only. governed_coverage and ownership_coverage count elements of any type carrying the classification, and their units say so. The read-back expects "Assets carrying at least one of five classifications over all Assets". Getting that means restricting the find to Asset, which is a code change.
  • Non-strict counts read 0 on failure (ISSUE-123, by design): count_elements, count_elements_by_property, counts_by_type, sum_type_counts, people_counts, usage_context_counts, growth_series, and the totals inside orphan_glossary_terms, stale_assets and semantic_grounding.
  • Capped pages with no completeness flag: count_relationships (default path), certifications_summary, active_contributors, engagement_series, term_definition_completeness, context_readiness_funnel.documented, stale_assets.staleCount.
  • The inverse bug: contextualised_coverage.assetTotal and solution_component_realisation.solutionComponentsTotal use total or None, so a measured 0 reads as not measured.
  • Lists that can't tell failure from nothing: karma_leaderboard returns [] both when the find fails and when there's nothing to list. engagement_series zero-fills a type whose query failed.

Tests

  • uv run -p 3.13 pytest tests/micro-tests/: 1952 passed, 2 skipped (the skips existed before this PR; the cross-validation test is collected and skipped here because the library isn't a dependency).
  • Cross-validation in a scratch venv with egeria-trellis-analytics 0.3.1 and this branch: 60 passed.
  • New: test_rs_w2_1a_routine_declarations.py: test_every_registry_entry_is_declared; test_declared_value_fields_exist, which calls each routine with fake clients and checks that every value_field, completeness_field, basis denominator, as_of and out field resolves in the real result; test_absence_sentences_use_the_four_words; kind blocks; one failure test per 0→None fix.
  • ruff: the new and changed code is clean. Four findings are on untouched lines that were already on upstream/main (overview_metrics.py:32 unused Callable, three in test_overview_metrics.py).

No version bump. No Egeria, Postgres or 8813 writes. The live read-back (§5: exec_report_spec as a low-privilege user) hasn't been run; it's the Architect's.

🤖 Generated with Claude Code

…the declaration model

RS-W2-1a step 1 (decision D2: trellis-analytics authors the vocabulary, pyegeria mirrors it).

- MeasureDeclaration: completeness_field replaces capped_field (still read, with a
  DeprecationWarning, as the library did in 0.3); population (viewer | repository);
  a basis on a share is refused, as in the library.
- FieldDeclaration / FieldCompanion (name, label, kind data|cell|representation|dataset,
  type, unit, companions, ...), AnalyticDeclaration.out, plus the categories and listing
  blocks the library requires for distribution/graph and list results.
- ROW_SHAPES: the row shapes built-in declarations name from a dataset field.
- asset_composition: categories (rows overlap), population and completeness on its
  measures, and an out field list.
- test_declarations_match_library.py: every built-in declaration loads as a library
  Declaration, its out as a library Shape; skipped when trellis_analytics is absent.
  Passes against egeria-trellis-analytics 0.3.1.

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

RS-W2-1a, routines: count_elements, count_elements_by_property, count_relationships
(newly registered, decision D6), counts_by_type, sum_type_counts.

Each declares its measure (unit, as_of, value_field), the four nothing_found-vocabulary
absence sentences and its out fields; the count routines also list their population=
parameter (odpi#538) and a cost class in the description, for W2-2's tile_safe.

What the functions return, worth knowing:
- count_elements / count_elements_by_property / counts_by_type return 0 when a count
  fails unless strict=True (ISSUE-123, by design, overview_metrics.py:383); sum_type_counts
  runs non-strict, so a failed type adds 0 to its total. Not changed here: strict= is the
  documented switch and the Portal relies on the default. Named in the PR.
- count_relationships' default path is one get_relationships page (DEFAULT_CAP): a type
  with more relationships than a page reads the page size, with no completeness flag
  (overview_metrics.py:499). Named in the PR.
- A bare-number result declares value_field "value", the key metric_trend already uses
  for a non-dict result.

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
…lure is None, not 0

RS-W2-1a, routines: governed_coverage, ownership_coverage, business_value_signals,
certifications_summary, semantic_grounding.

Fix in this commit: ownership_coverage used _find, which turns a failed query into an
empty list, so an outage reported ownershipCount 0 ("nothing owned") with
ownershipCapped False (overview_metrics.py:693 before this change). It now uses
_find_or_none and returns None for both, as governed_coverage already did. The Portal
assigns ownershipCount before dividing and catches the TypeError, so it shows no
number instead of 0; a successful call is unchanged.

What the functions return, worth knowing:
- governed_coverage and ownership_coverage are not restricted to Asset: they count
  elements of any type carrying the classification. The declarations say so ("elements
  of any type ..."); restricting them to Assets is a code change, named in the PR.
- certifications_summary's counts are each one get_relationships page with no
  completeness flag, like count_relationships.
- semantic_grounding's groundingPct is links per hundred Assets (capped at 100), not
  the share of Assets with a link; its unit says that.

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
…contributors failure is None

RS-W2-1a, routines: people_counts, feedback_summary, usage_context_counts,
active_contributors, karma_leaderboard.

Fix in this commit: active_contributors turned a failed relationship query into an empty
set, so an outage read as 0 contributors for that type and a smaller union overall
(overview_metrics.py:1811 before this change). A failed type is now None in byType and
contributors is None unless every type was read, the rule feedback_summary's total
already follows. test_active_contributors_degrades_per_type_on_failure pinned the old 0
and now pins the None. Not called by the Portal's Overview.

What the functions return, worth knowing:
- people_counts and usage_context_counts run non-strict by default: a failed count is 0
  unless strict=True (ISSUE-123). Named in the PR, not changed.
- karma_leaderboard returns [] both when the find fails and when nobody has karma, so
  not_measured and nothing_found are indistinguishable in its result (overview_metrics.py:1480).
  Changing [] to None would change a list routine's shape for the Portal; named in the PR.
- active_contributors counts users from relationship audit headers (createdBy), viewer
  population, one capped page per type.

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
… and realisation; failures are None

RS-W2-1a, routines: context_readiness_funnel, ai_ready_assets, drl_readiness_gates
(newly registered, D6), contextualised_coverage, solution_component_realisation (newly
registered, D6).

Fixes in this commit, each a failed query that read as a measured 0:
- context_readiness_funnel: `documented` came from _find, which never raises, so its
  try/except never fired and a failed Asset find gave documented 0
  (overview_metrics.py:999 before). Now None.
- ai_ready_assets: a failed Asset find gave {aiReadyCount 0, total 0, capped False}, and a
  failed DataFlow query gave aiReadyCount 0 ("no asset is lineage-traced")
  (overview_metrics.py:1061/1075 before). Now None, keeping total/capped when only the
  DataFlow query failed. test_ai_ready_assets_lineage_query_failure... pinned the 0 and
  now pins the None.
- drl_readiness_gates: the same two failures (overview_metrics.py:1182/1196 before).
  Now every field None on an Asset-find failure; aiReadyCount/aiReadyRecentCount None on
  a DataFlow failure, keeping total, capped and byModality.
The Portal's ai-context endpoint already guards each of these with `if x:` / try, so it
shows no number instead of 0; successful calls are unchanged.

What the functions return, worth knowing:
- context_readiness_funnel's four stages are independent counts over different
  populations (Assets, elements of any type, relationships), not nested stages, and its
  `documented` stage has no completeness flag although it comes from one capped find.
- contextualised_coverage and solution_component_realisation turn a measured 0 total into
  None (`total or None`, overview_metrics.py:1381/1438): a real zero reads as unmeasured,
  the inverse bug. Not changed (it would change a success result); named in the PR.

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

RS-W2-1a, routines: growth_series, engagement_series, metric_trend,
term_definition_completeness, orphan_glossary_terms, stale_assets,
control_implementation_summary. With these every one of the 28 registry entries
declares its results.

Fixes in this commit, each a failed find that read as a measured 0:
- term_definition_completeness: _find turned a failed find into an empty glossary,
  {total 0, defined 0} (overview_metrics.py:1757 before). Now all three fields None.
- stale_assets: staleCount 0 on a failed find (overview_metrics.py:926 before). Now None.
Neither is read by the Portal's Overview in a way that changes: staleAssetCount was
already None when the routine raised.

What the functions return, worth knowing:
- growth_series and metric_trend carry no per-point as-of time, only the formatted
  `date`/`label`; the series measures name `date`. growth_series' counts are non-strict,
  so a failed snapshot reads 0 per series.
- engagement_series zero-fills a type whose query failed, so an outage reads as a
  flat zero line (overview_metrics.py:1564). Changing that changes a list shape; named
  in the PR.
- stale_assets' staleCount comes from one capped find and its assetTotal from a native
  count, so they are not a part and its whole; no basis is declared between them.
- orphan_glossary_terms' termTotal is a non-strict count: a failed count is 0, and
  orphanCount then floors at 0 (overview_metrics.py:871/893). Named in the PR.

Also: every description now ends with its cost class ("Cost: ..."), so W2-2 can set
tile_safe from evidence. Only the 10.8 points are measured (repository counts
0.2-0.8 s; viewer count of Process 120 s); the rest are read from each routine's
query shape.

Tests (test_rs_w2_1a_routine_declarations.py): test_every_registry_entry_is_declared,
test_declared_value_fields_exist (each routine called with fake clients; every
value_field, completeness_field, basis denominator, as_of and out field resolves in
its real result), test_absence_sentences_use_the_four_words, kind blocks present, and a
failure test per 0 -> None fix.

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
@dwolfson
dwolfson merged commit 1b50171 into odpi:main Nov 7, 2026
6 checks passed
dwolfson added a commit that referenced this pull request Nov 7, 2026
Ships #537 (five link methods sent a properties class Egeria lacks),
#538 (population= is the count keyword; scope= deprecated), #539
(declarations for every registered routine), #540 and #541 (client
support and Dr.Egeria commands for Egeria 6.3 report specs,
measurements and dashboards), #542 (built-in declaration tests scoped to
pyegeria's own routines) and #543 (report_spec passed through the
MetadataExpert find methods).

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
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