Skip to content

test(ingestion): e2e tests for all Task Delivery metrics (+ MV-refresh fix)#1498

Merged
mitasovr merged 14 commits into
constructorfabric:mainfrom
mitasovr:claude/happy-beaver-80aa57
Jul 10, 2026
Merged

test(ingestion): e2e tests for all Task Delivery metrics (+ MV-refresh fix)#1498
mitasovr merged 14 commits into
constructorfabric:mainfrom
mitasovr:claude/happy-beaver-80aa57

Conversation

@mitasovr

@mitasovr mitasovr commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What

Adds declarative YAML e2e tests for the eight previously-untested Task Delivery bullet metrics, so all 11 metrics in the group now have an e2e test (tasks_completed / bugs_to_task_ratio / due_date_compliance were already covered).

Status-interval metrics (from task_status_intervals → task_dev_seconds_per_issue):

metric_key measures value
task_dev_time hours in dev-active statuses 120 h
mean_time_to_resolution days create → final close 7 d
pickup_time days create → first dev status 2 d
flow_efficiency % lifetime in active work (100·Σdev/Σlead) 71.4 %

Remaining metrics:

metric_key measures value
estimation_accuracy estimate vs spent (folded around 100) 80
task_reopen_rate reopen events, gated on ≥5 closes (100·Σreopen/Σclose) 40
stale_in_progress open issues idle >14d (today() snapshot) 1
worklog_logging_accuracy logged sec / in-progress sec 50 %

Each spec is bronze-only and runs the full dbt + jira-enrich + gold path, asserting just its own metric_key on the IC Task Delivery bullet (…0011). Per the rig's composition rule, templates carry only invariant scaffolding; every field driving an assertion is inline.

Supporting changes

  • bronze_jira.jira_worklogs placeholder (+ schema + template): the pure dbt model jira__task_worklogs (silver:class_task_worklogs) is the worklog_logging_accuracy numerator; seeding the bronze makes derive_selectors build it.
  • timeoriginalestimate / timespent field-catalog entries: these arrive only via the changelog, never the issue snapshot, so estimation_accuracy must set them there.
  • Fix a refresh-completion race in refresh_intermediates: the poll accepted a Finished status left by the prior test's refresh and returned before the just-triggered SYSTEM REFRESH VIEW ran, so the bullet query could read a stale task_issue_current_state / task_status_intervals MV (flaky None/wrong values across the group). CH 24.8 has no SYSTEM WAIT VIEW, so it now waits for refresh_count to advance.

Note on task_reopen_rate: a reopened-but-still-open issue does not register a reopen — the last status interval clamps to final_close_at, so the post-reopen interval is dropped. The fixture closes reopened issues again (close→reopen→close), which is also the realistic shape.

Test

cd src/ingestion/tests/e2e

  • ./e2e.sh test -k task_delivery11 passed (deterministic across repeated runs)
  • ./e2e.sh test (full suite) → 56 passed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for Jira worklog data in fresh environments so related analytics can run successfully.
    • Expanded end-to-end coverage for multiple task delivery metrics, including pickup time, flow efficiency, estimation accuracy, mean time to resolution, stale in progress, reopen rate, and worklog logging accuracy.
  • Bug Fixes

    • Improved refresh detection in automated tests to prevent false “finished” states between back-to-back runs.
    • Added validation to ensure metric calculations match expected outcomes across different Jira scenarios.

Add declarative YAML e2e tests for four Task Delivery bullet metrics that
derive from the status-interval path (task_status_intervals →
task_dev_seconds_per_issue): task_dev_time, mean_time_to_resolution,
pickup_time and flow_efficiency.

All four share one bronze scenario — a single Jira issue (Alice) closed
via Open → In Progress → Closed — so one set of intervals exercises every
metric: 5d dev / 7d lead / 2d pickup → task_dev_time=120h, mttr=7d,
pickup_time=2d, flow_efficiency=71.4%. Each file asserts only its own
metric_key on the IC bullet (...0011), bronze-only, full dbt + jira-enrich
path. `./e2e.sh test -k task_delivery` = 7 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Roman Mitasov <Roman.Mitasov@constructor.tech>
@mitasovr
mitasovr requested a review from a team as a code owner June 26, 2026 08:59
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c577159-e136-4354-9c07-53e14803d558

📥 Commits

Reviewing files that changed from the base of the PR and between 678f545 and 1ae2a1b.

📒 Files selected for processing (14)
  • src/ingestion/tests/e2e/lib/migration_applier.py
  • src/ingestion/tests/e2e/metrics/schemas/bronze_jira.jira_worklogs.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_bugs_to_task_ratio_ratiosum_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_estimation_accuracy_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_flow_efficiency_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_mean_time_to_resolution_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_mean_time_to_resolution_median_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_pickup_time_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_stale_in_progress_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_task_dev_time_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_task_reopen_rate_gate_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_task_reopen_rate_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_worklog_logging_accuracy_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/templates/jira_task.yaml
💤 Files with no reviewable changes (13)
  • src/ingestion/tests/e2e/metrics/task_delivery_pickup_time_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_mean_time_to_resolution_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_estimation_accuracy_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_task_dev_time_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_bugs_to_task_ratio_ratiosum_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/schemas/bronze_jira.jira_worklogs.yaml
  • src/ingestion/tests/e2e/metrics/templates/jira_task.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_worklog_logging_accuracy_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_stale_in_progress_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_mean_time_to_resolution_median_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_flow_efficiency_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_task_reopen_rate_jira.test.yaml
  • src/ingestion/tests/e2e/metrics/task_delivery_task_reopen_rate_gate_jira.test.yaml

📝 Walkthrough

Walkthrough

Adds a bronze_jira.jira_worklogs placeholder table to the Bronze schema script and fixes a stale-state bug in the e2e refresh polling loop. Introduces a JSON schema definition and fixture templates for worklogs, then adds 10 new end-to-end YAML metric test specifications covering Task Delivery JIRA metrics.

Changes

Task Delivery Jira metric e2e coverage

Layer / File(s) Summary
Bronze placeholder and refresh polling fix
src/ingestion/scripts/create-bronze-placeholders.sh, src/ingestion/tests/e2e/lib/migration_applier.py
Adds idempotent bronze_jira.jira_worklogs placeholder table; fixes refresh_intermediates() to record per-view refresh_count before triggering refreshes and to require an incremented count before marking completion.
Worklog schema and fixture templates
src/ingestion/tests/e2e/metrics/schemas/bronze_jira.jira_worklogs.yaml, src/ingestion/tests/e2e/metrics/templates/jira_task.yaml
Adds JSON Schema for bronze_jira.jira_worklogs and extends jira_task.yaml with field_timeoriginalestimate, field_timespent, and a jira_worklog template record.
Lead-time metric specs
src/ingestion/tests/e2e/metrics/task_delivery_pickup_time_jira.test.yaml, task_delivery_mean_time_to_resolution_jira.test.yaml, task_delivery_mean_time_to_resolution_median_jira.test.yaml
Adds e2e specs for pickup_time (2-day queue) and mean_time_to_resolution (single issue: 7 days; three-issue median: 2 days).
Active-time and efficiency metric specs
src/ingestion/tests/e2e/metrics/task_delivery_task_dev_time_jira.test.yaml, task_delivery_flow_efficiency_jira.test.yaml, task_delivery_stale_in_progress_jira.test.yaml, task_delivery_estimation_accuracy_jira.test.yaml
Adds e2e specs for task_dev_time (120 h), flow_efficiency (~71.4%), stale_in_progress (1), and estimation_accuracy (80).
Ratio and reopen-rate metric specs
src/ingestion/tests/e2e/metrics/task_delivery_bugs_to_task_ratio_ratiosum_jira.test.yaml, task_delivery_task_reopen_rate_jira.test.yaml, task_delivery_task_reopen_rate_gate_jira.test.yaml, task_delivery_worklog_logging_accuracy_jira.test.yaml
Adds e2e specs for bugs_to_task_ratio (ratio-of-sums: 40), task_reopen_rate (40 and null-gated below 5 closes), and worklog_logging_accuracy (50).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • constructorfabric/insight#1466: Both PRs add Bronze placeholder tables in create-bronze-placeholders.sh using the same idempotent IF NOT EXISTS guard pattern.

Suggested reviewers

  • cyberantonz
  • ktursunov
  • dzarlax

Poem

🐇 Hops through bronze tables and YAML files galore,
Planting worklogs and metrics, a dozen or more.
The refresh loop no longer sees ghosts of the past—
With refresh_count climbing, completions hold fast.
Ten new test specs bloom in the ingestion meadow,
Each ratio and median cast without shadow! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: Task Delivery e2e coverage and the MV-refresh fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

…esh fix

Cover the last four Task Delivery bullet metrics so all 11 now have an e2e test:
  - estimation_accuracy   — estimate vs spent (time-tracking fields via changelog)
  - task_reopen_rate      — reopen events, gated on >=5 closes
  - stale_in_progress     — open issues idle >14d (today() snapshot, wide window)
  - worklog_logging_accuracy — logged seconds / in-progress seconds

Supporting changes:
  - Add a bronze_jira.jira_worklogs placeholder (+ schema + template) so the pure
    dbt model jira__task_worklogs (silver:class_task_worklogs) builds in the rig;
    this is the worklog_logging_accuracy numerator.
  - Add timeoriginalestimate/timespent to the jira field catalog template — these
    fields only arrive via the changelog, never the issue snapshot.
  - Fix a refresh-completion race in refresh_intermediates: the poll accepted a
    Finished status left by the PRIOR test's refresh and returned before the
    just-triggered SYSTEM REFRESH VIEW ran, so the bullet query could read a stale
    task_issue_current_state / task_status_intervals MV (flaky None/wrong values).
    CH 24.8 has no SYSTEM WAIT VIEW, so wait for refresh_count to advance instead.

`./e2e.sh test -k task_delivery` = 11 passed (deterministic across runs);
full `./e2e.sh test` = 56 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Roman Mitasov <Roman.Mitasov@constructor.tech>
@mitasovr mitasovr changed the title test(ingestion): e2e tests for task_delivery status-interval metrics test(ingestion): e2e tests for all Task Delivery metrics (+ MV-refresh fix) Jun 26, 2026
…dian

Three targeted specs closing coverage gaps the per-metric happy-path tests left:
  - bugs_to_task_ratio (ratio-of-sums): two days with unequal task counts so the
    correct 100*Σbugs/Σtasks (=40) differs from avg-of-daily-ratios (=62.5),
    guarding the issue constructorfabric#433 §3.3 aggregation against a regression to averaging.
  - task_reopen_rate (gate branch): <5 closes → query_ref suppresses the rate to
    NULL even though a reopen exists.
  - mean_time_to_resolution (median): three issues with lead times [10,2,1] so the
    period reducer's median (2.0) differs from the mean (4.33), pinning
    quantileExact(0.5) (odd count avoids the upper-middle ambiguity on even sets).

`./e2e.sh test -k task_delivery` = 14 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Roman Mitasov <Roman.Mitasov@constructor.tech>
Roman Mitasov and others added 3 commits June 29, 2026 11:18
…-80aa57

Signed-off-by: Roman Mitasov <Roman.Mitasov@constructor.tech>

# Conflicts:
#	src/ingestion/tests/e2e/metrics/schemas/bronze_jira.jira_worklogs.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_bugs_to_task_ratio_ratiosum_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_estimation_accuracy_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_flow_efficiency_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_mean_time_to_resolution_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_mean_time_to_resolution_median_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_pickup_time_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_stale_in_progress_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_task_dev_time_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_task_reopen_rate_gate_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_task_reopen_rate_jira.test.yaml
#	src/ingestion/tests/e2e/metrics/task_delivery_worklog_logging_accuracy_jira.test.yaml
@mitasovr
mitasovr requested a review from ktursunov June 29, 2026 16:46
Roman Mitasov and others added 4 commits July 9, 2026 11:14
…-80aa57

Signed-off-by: Roman Mitasov <Roman.Mitasov@constructor.tech>

# Conflicts:
#	src/ingestion/tests/e2e/metrics/templates/jira_task.yaml
… gate

Upstream added a no-unasserted-stat gate (every returned bullet stat must be
asserted) and moved all fixtures to a 5-member-department shape. Rework the 11
task_delivery specs I added so each seeds an Engineering department (alice..erin,
ranks 1..5) with a known per-person value ladder and asserts the full stat set
(value/median/range_min/range_max/p25/p75) in a custom window + an empty window.

Ladders (query = erin): counts {1,2,3,4,5}, ratios {0/20/40/60/80} or
{20..100}. For task_dev_time/mean_time_to_resolution/pickup_time range_max is the
cohort P95 (= max on a 5-point ladder).

Two behaviours worth noting, both captured by the fixtures:
  - Interval-derived metrics (task_dev_time, pickup_time, flow_efficiency,
    worklog_logging_accuracy, task_reopen_rate) use PAST close dates (2026-03),
    because task_status_intervals drops any interval ending after now()+1day — a
    future window (2026-12) silently empties the interval MV. Current-state
    metrics (tasks_completed, mttr, estimation, stale, bugs) are unaffected.
  - task_reopen_rate: a person with closes but ZERO reopens gets a NULL rate
    (the query_ref numerator sumIf(value<0) is NULL over no rows, not 0), so they
    drop out of the distribution — the cohort is the 4 people with reopens.
  - jira__task_worklogs dedups bronze by LIMIT 1 BY _airbyte_raw_id, so the 5
    worklog rows need distinct _airbyte_raw_id (the template's shared placeholder
    collapsed them to one).

Delete task_delivery_mean_time_to_resolution_median_jira: the redesigned base
mttr spec now exercises the cohort median directly.

`./e2e.sh test -k task_delivery` = 14 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Roman Mitasov <Roman.Mitasov@constructor.tech>
mitasovr and others added 4 commits July 9, 2026 17:15
The Metric coverage gate fails on stale skips: estimation_accuracy,
flow_efficiency, mean_time_to_resolution, pickup_time, stale_in_progress,
task_dev_time, task_reopen_rate and worklog_logging_accuracy are now
value-tested by the task_delivery_* fixtures added in this PR, so their
SKIP_LIST entries must go. The five still-untested keys (avg_slip,
on_time_delivery, overrun_ratio, scope_completion, scope_creep) stay.

Verified locally: metric_coverage.py against the CI run's
catalog_metrics.json artifact now exits 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Roman Mitasov <Roman.Mitasov@constructor.tech>
@mitasovr
mitasovr enabled auto-merge (squash) July 9, 2026 17:09
@mitasovr
mitasovr merged commit 2d8c1cd into constructorfabric:main Jul 10, 2026
28 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.

e2e tests for all Task Delivery metrics (task tracker metric group)

3 participants