Worked Examples

Developer reference for temporal indicator trends — Global Impact Catalyst

Implement and troubleshoot temporal indicator trends in Global Impact Catalyst using versioned observations, governed analysis methods, source provenance, and reproducible publication workflows. This source-reviewed developer reference documents Python and WordPress execution boundaries, temporal calculations, revision handling, access controls, and the evidence required to produce scientifically defensible longitudinal visualizations.

ProductGlobal Impact CatalystUpdatedNovember 22, 2026Reading time1 minutes

Application: Global Impact Catalyst (GIC)
Article type: Developer reference / technical troubleshooting
Source baseline: v2.0.0 release, with v1.7.0 trend-analysis subsystem
Review date: November 22, 2026
Estimated reading time: 20–24 minutes
Applicability: repository behavior at the pinned commit; deployment parity requires separate confirmation

Summary: Implement and troubleshoot temporal indicator trends with reproducible calculations, observation revisions, source-version provenance, method-version controls, and publication-ready chart lineage. This source-reviewed guide identifies the current Python/WordPress execution gap and defines testable engineering contracts without presenting proposed functionality as deployed.

1. Purpose, scope, and scientific boundary

Temporal indicator analysis compares measurements across defined periods, explains changes, and exposes discontinuities in data collection or analytical methods. A useful trend should answer not only how much did a value change? but also which exact observations, units, definitions, and evidence generated each displayed mark?

GIC’s Python trend engine implements descriptive summaries; it does not, by itself, establish causation, counterfactual impact, statistical significance, or independent verification. The relevant software acceptance target is reproducible descriptive analysis plus a defensible evidence trail. Policy or scientific conclusions need separate quality review, domain-specific uncertainty analysis, and source interpretation.

2. Verified source inventory

Inspected component Evidence at pinned commit Engineering consequence
Python analytical engine python/global_impact_analysis.py, analyze_trend() Effective observations, exclusion policies, conversion, sorting, and descriptive statistics are implemented.
WordPress trend route gic_analysis_trend_rest() in the WordPress plugin The POST handler returns a placeholder result; it does not call the Python engine or compute statistics.
Registry docs/indicator-registry.md and repository bindings Immutable definition versions exist but are not included in every Python trend point.
Evidence repository docs/sources-provenance-evidence.md Source-version identifiers and hashes exist separately from per-point trend output.
Repository tests tests/test_analysis_scenarios.py; tests/test_wordpress_contract.py Python assertions cover trend arithmetic; WordPress contract tests check declared endpoint presence, not Python-equivalent computation.

Important qualification: this is a source inventory, not a production status report. File paths and functions may differ from the currently deployed site or from later repository revisions.

3. Execution boundary: Python versus WordPress

The Python entry point analyze_trend(initiative_id, indicator_id, target_unit_id=None, include_partial=False, missing_policy="exclude", actor="system", persist=False) selects and processes observations and returns points, excluded, statistics, integrity, and boundary. Persisted runs are an optional behavior.

By contrast, WordPress registers POST /wp-json/global-impact-catalyst/v1/analysis-trends against gic_analysis_trend_rest(). At the reviewed commit the handler returns identifiers, analysis_type, analysis_version, integrity.valid: true, and a message referring callers to Python; it does not calculate trend points or statistics. The shared route name must not be interpreted as computational parity.

Required correction: do not render that placeholder as a completed trend or as an assurance signal. Until a real backend is connected, represent the route as not_implemented or a non-successful computational status, and prevent chart-publication workflows from accepting it. A future backend must use the same authorization, observation-selection, and response-contract tests as the Python engine.

4. Canonical identifiers and a point-level evidence chain

Every displayed point should resolve to a stable observation record and the exact source, method, indicator definition, and transformation used at computation time. Distinguish a stable record identity from its immutable version identity. A source title or a mutable “latest” pointer is insufficient to reconstruct a historical claim after an update.

The inspected Python point currently includes observation_record_id, period fields, value, unit, state, and dimensions. The proposed chart contract adds source_version_id, method_definition_version_id, indicator_definition_version_id, optional evidence_id, conversion details, inclusion reason, analysis run and publication snapshot fingerprints. These additional fields are proposed and must be populated from verified repository joins, not invented in the frontend.

{
  "status": "PROPOSED_POINT_CONTRACT_NOT_DEPLOYED",
  "observation_record_id": "obs-002",
  "period_start": "2022-01-01",
  "value": 14.0,
  "unit_id": "t",
  "data_state": "complete",
  "indicator_definition_version_id": "ind-v1",
  "method_definition_version_id": "meth-v1",
  "source_version_id": "src-v1",
  "transformation": {"type": "none", "formula_version": "identity-v1"}
}

Never silently substitute the most recent source or method version for the version actually used. When the historical binding is absent, show a provenance gap and prohibit an “evidence complete” status until it has been resolved.

5. Measurement comparability: units, time, population, and geography

Two numeric values are not comparable solely because they share an indicator name. Compare the measurement definition, spatial footprint, population frame, observation period, sampling method, unit, coverage, and inclusion/exclusion criteria. A change in any of these may create a series break. Keep original reported values alongside transformed values and an explicit transformation record.

At the reviewed commit Python will attempt a registered conversion if a point’s unit differs from target_unit_id. Conversion failure adds a blocker and exclusion. This is useful, but dimensional compatibility does not prove methodological comparability. A conversion from kilograms to tonnes cannot reconcile a change from a household population to an institutional population or a shift in denominator.

Decision rule: convert only dimensionally compatible units with documented factors and precision; split or annotate the series when temporal, geographic, or methodological continuity cannot be justified.

6. Observation revisions and effective-record selection

The source uses list_observations() and _effective_records(..., "observation_record_id") before analysis. Revision chains should preserve superseded records, their timestamps, actors, and reasons. The computed result should identify the selected record and record which predecessor was superseded; it must never rewrite a published historical snapshot in place.

A test fixture should include original observation O-1, corrected successor O-2, and a later observation O-3. Assert that the active view includes the corrected value once, while the audit trail retains O-1. If a revision arrives after publication, create a new analysis run and mark the prior publication as superseded, without erasing its original numerical result.

7. Missing, partial, excluded, and invalid observations

The Python engine accepts missing_policy values block, exclude, or warn; include_partial defaults to false. Missing values are excluded, partial values are excluded unless permitted, and incompatible unit conversions are excluded with blockers. integrity.valid is computed as not blockers and len(values) >= 1.

Critical scientific nuance: one usable point can satisfy that implementation’s integrity predicate even though it cannot define a meaningful directional trend. The source adds a warning for fewer than two usable observations but classifies direction from a slope of zero. Publication eligibility therefore requires a stricter policy than this existing integrity.valid flag. Keep computationally_processed, statistically_interpretable, and publication_approved as separate states.

8. Temporal ordering and annualized slope

Values are sorted by period_start, falling back to period_label, with observation ID as a tiebreaker. The current _slope(values) uses integer observation positions: 0, 1, 2, and so on. The resulting slope is in value per observation step, not necessarily value per year. This matters when periods are irregular, annual, quarterly, or mixed.

For elapsed calendar-time analysis, represent observations as pairs (ti, yi), where t is elapsed years from a declared time origin. Ordinary least squares uses:

beta = Σ[(t_i − mean(t))(y_i − mean(y))] / Σ[(t_i − mean(t))²]

The slope has units of indicator units per year. For a two-point change, report the absolute difference and annualized difference separately; they need not equal the OLS slope for three or more records. Period midpoints, end dates, or start dates must be selected consistently, documented, and scientifically justified. Irregular seasonal or autocorrelated data may require a model beyond this descriptive OLS reference.

# Synthetic points: 2020=10, 2022=14, 2025=20 (unit: tonnes)
# index-based slope: mean step increase = 5 per observation step
# elapsed-calendar-year slope: approximately 2 tonnes per year
# These are DIFFERENT quantities and must not share an axis label.

9. Baselines, zero denominators, and interpretation

The reviewed Python function computes absolute_change = last − first and percentage change as (last − first) / abs(first) × 100, returning null when the first value is zero. This is a signed relative-change convention with an absolute-valued denominator, not an arbitrary growth rate. Make that convention visible in the UI, especially for indicators that may be negative.

Preserve baseline date, baseline value, unit, population, and method version. Distinguish observed difference from target gap, projection, counterfactual change, and attributed effect. Do not infer improvement merely from an increasing trend unless the indicator’s directionality and intended outcome have been defined.

10. Proposed evidence-linked trend manifest (not an existing API)

Adopt a versioned manifest that captures the exact analysis inputs and presentation marks. This is an engineering proposal, not an existing endpoint or schema in the inspected repository. Include manifest_version, bound workspace/initiative/indicator identifiers, analysis_version, code_commit, input observation IDs and versions, excluded records with reasons, unit-conversion instructions, ordered plotted points, calculation policy, analysis-run hash, publication snapshot hash, and reviewer decision.

The SHA-256 digest should be computed over a precisely specified canonical serialization with stable field order and normalized numeric representations. A checksum supports tamper detection for the captured bytes; it does not prove a scientific claim, authenticated authorship, or authorization. Maintain the hash outside the hashed payload to avoid a circular digest.

{
  "manifest_version": "proposed-temporal-trend-v1",
  "status": "offline_reference_only",
  "code_commit": "e75808a0aa272656b1fdbacd2491c30fd6b987dc",
  "calculation_policy": {"time_basis": "elapsed_calendar_years", "partial": "exclude"},
  "analysis_run_id": "synthetic-run-001",
  "observation_ids": ["obs-001", "obs-002", "obs-003"],
  "source_version_ids": ["src-v1", "src-v2"],
  "approval": {"state": "not_reviewed"},
  "publication_snapshot_hash": null
}

11. Reference diagnostics: reproducible synthetic implementation

The companion gic_temporal_reference.py implements an offline proposed contract using only the Python standard library. It checks required point identifiers, numeric finiteness, unique observation IDs and period starts, compatible units, missing/partial handling, a minimum of two usable observations, elapsed-year regression, and deterministic hashing. The diagnostic is intentionally independent of the GIC database and does not claim to reproduce GIC’s internal algorithm or authorize publication.

# From the extracted companion directory, with Python 3.10+:
python3 -m unittest -v test_gic_temporal_reference.py
python3 gic_temporal_reference.py example_points.json
# The script reads local fictional JSON only. No credentials or network calls.

Expected synthetic result: three observations at 2020-01-01, 2022-01-01, and 2025-01-01 with values 10, 14, and 20 produce absolute change 10, percentage change 100%, and an OLS slope of approximately 2 indicator units per year. Actual day counts and leap-year normalization yield a small difference from exactly 2. The input values are fictional.

12. Suggested integration architecture and idempotency

A proposed production path is authorized request → workspace/initiative permission check → immutable observation snapshot → Python analysis execution → deterministic manifest → editorial/scientific review → approved publication snapshot → read-only chart. Authorization must be checked at the boundary and again when accessing the underlying data. A successful HTTP response, save, background job, or checksum comparison must not imply human approval.

Assign idempotency keys per (workspace, initiative, indicator, input snapshot hash, analysis policy version). Repeated equivalent requests should resolve to the same immutable run or a clearly marked equivalent without duplicating records. If the active observation or method revision changes, generate a new run ID and invalidate any unapproved publication candidate that depended on the former snapshot.

13. WordPress authorization and tenant isolation

The inspected WordPress endpoint routes use permission_callback => gic_repository_can_edit; the callback checks the generic edit_posts capability. This is evidence of an editing permission gate, not proof of workspace-specific authorization. A caller with editing capability must not automatically gain access to another institution’s workspace, initiative, private sources, or draft analyses.

Require server-side tenant and workspace membership checks for every lookup, analytic run, export, and publication action. Do not accept client-supplied workspace_id alone as proof of scope. Apply least privilege; redact source excerpts and protected metadata from anonymous charts, search indexes, API responses, errors, telemetry, and downloadable manifests. For public display, use a deliberately minimized derivative manifest linked to a restricted full audit artifact.

14. Endpoint contracts and placeholder failure behavior

At the reviewed commit, the WordPress handler can return integrity.valid: true even though no computation ran. A safer transitional response is a typed non-successful computation status that cannot be mistaken for a calculated result. The following illustrates a proposed response shape; it is not the current route output:

{
  "status": "not_implemented",
  "computed": false,
  "integrity": {"valid": false, "blockers": ["trend calculation not executed"]},
  "points": [],
  "statistics": null,
  "boundary": "This response is not a computed trend."
}

For a future computed response, require a nonempty points array with accepted evidence links, a statistics object with declared time basis, explicit exclusions and blockers, a stable run ID, and an analysis-engine version. Reject incompatible fields, stale revisions, unresolved lineage, and cross-workspace inputs before recording publishable output.

15. Analysis-run persistence, publication snapshots, and reversibility

The Python persist=True path records an analysis run; publication remains a separate governance step. Capture the input snapshot, engine commit/version, transformation registry, reviewer identity and decision, release date, superseded-by pointer, and withdrawal state. A new analysis does not automatically replace an already published chart. Public caches, downloadable exports, embeds, and search snippets must be invalidated or updated consistently when an approved correction or withdrawal occurs.

Rollback should restore prior code and published presentation safely without deleting the audit trail or reclassifying superseded computations as current. Treat chart markup, accessible data tables, API payloads, and citations as one publication unit, not independently mutable representations.

16. Accessibility and visualization behavior

Display clearly labeled axes with units and time granularity, series-break annotations, uncertainty descriptions, and source/method revision markers. Give the graphic a concise visible caption and a machine-readable data table containing dates, values, units, provenance status, and exclusions. Accessible tooltips cannot be the sole carrier of essential facts. Keyboard users must be able to inspect values without hover-only interactions; avoid using red/green as the only semantics for improvement or deterioration.

When a unit or methodology changes, show a visible break or side-by-side comparison instead of connecting values with a deceptively continuous line. Distinguish observed measurements, imputed points, projections, and forecasts through text labels and visually differentiable styles.

17. Troubleshooting matrix

Observed symptom Likely cause to inspect Required evidence
API returns valid but chart lacks points WordPress placeholder handler at reviewed commit Source handler, request/response capture, environment version
Unexpected “per-year” slope Index-based slope with irregular time steps Sorted input periods, calculation policy, independent recomputation
Trend changes after source update Mutable source reference or newer effective observation Source-version IDs, predecessor chain, both run hashes
Series mixes methods or populations Comparability gate absent or overly permissive Definition/method bindings, geographies, population frames
Different tenants can read the same draft Generic editor permission without workspace authorization Denied cross-tenant integration test, access policy and logs
One-point trend labeled “stable” Existing integrity predicate and zero slope fallback Included count, warnings, publication eligibility checks

18. Read-only database and audit inspection

Perform database inspection only against an authorized copy or read-only staging snapshot. Avoid running speculative schema migrations or mutating user data. In a SQLite environment, inspect the real table definition first, rather than assuming column names or table prefixes. This sample checks metadata only and does not expose record contents:

-- Open an explicitly authorized, read-only SQLite snapshot.
PRAGMA query_only = ON;
SELECT name, type FROM sqlite_master
WHERE type IN ('table', 'view') AND name LIKE '%observation%'
ORDER BY name;
-- Inspect actual fields before any further query:
PRAGMA table_info('observation_records');

For any tenant data, capture results in a restricted evidence bundle; public articles should use synthetic examples, schema names, and summarized counts instead of private source payloads.

19. Acceptance tests: computation, evidence, security, and release

Computational acceptance: verify two-point and multi-point trends, irregular dates, zero and negative baselines, mixed units, invalid conversions, unknown states, missing and partial records, duplicate/revisioned observations, deterministic sorting, and nonfinite values. Compare Python and WordPress against the same frozen fixtures; require numerical parity within an explicit tolerance and unit basis.

Evidence acceptance: every rendered point resolves to its observation and immutable source/method/indicator definition versions. Test an intentional missing source-version ID, a deleted reference, a revision of a source payload, stale method binding, and a changed registry definition. Each must either block publication or show a documented, approved exception; none may silently pass as evidence-complete.

Access acceptance: assert anonymous denial to draft resources, denied cross-tenant access for authenticated editors, no leak through query parameters or error bodies, no duplicate writes under replay, and no publication bypass on a successful save. Capture both allowed and denied cases in staging with redacted logs.

Release acceptance: pin repository commit, schema versions, staging image, test artifacts and checksums. Attach reproducible fixtures, command output, reviewer approval, rollback procedure, and a public anonymous chart test. Run under production-like authorization but with synthetic or properly authorized data. Passing offline unit tests is not equivalent to staging or deployment acceptance.

20. Suggested engineering sequence

  1. P0 — Correct misleading completion: stop treating a WordPress placeholder valid: true response as a finished analytic run; add negative tests.
  2. P1 — Establish execution parity: expose actual governed analysis from the Python service through an authenticated integration, or implement equivalent verified computation under a shared contract.
  3. P1 — Add mark-level lineage: bind immutable source, method, and definition versions to plotted values and chart exports.
  4. P1 — Enforce workspace permissions: authorize resource access per tenant, not only by general WordPress editing capability.
  5. P2 — Improve temporal semantics: clearly distinguish index-based change from elapsed-time annualized slope and handle irregular intervals.
  6. P2 — Add publication governance: explicit review, immutable snapshot, supersession, withdrawal, and cache invalidation controls.

21. Evidence and acceptance criteria

Source review supports the implementation findings in Sections 2–9 and 13–14 at commit e75808a0aa272656b1fdbacd2491c30fd6b987dc. Companion offline diagnostics and test results are separate engineering samples; they are not repository-native test suite results. The publication acceptance state remains not verified until a known staging deployment demonstrates Python/WordPress trend parity, workspace authorization, version-complete per-point provenance, and reviewed chart snapshots.

Minimum evidence packet: exact repo SHA; deployed component versions; captured schema and route definitions; fixture SHA-256; inputs and selected/superseded observation IDs; calculation output and independent recomputation; permission test logs; reviewer decision; cache/export checks; and release/rollback verification.

22. Technical references and source links

Version note: these references identify the reviewed implementation and general standards. A later commit, deployed WordPress build, or unpublished local patch may differ. Review those separately before modifying production behavior.

Scroll to Top