Planning material — fictional examples, no production behavior

AI Delivery Measurement and Estimation Framework

Status

Working direction — begin with a bounded client-portal automation pilot.

The first proposed implementation is ai-consulting-client-portal issue #90. It records token consumption for issue-attributed Codex automation without introducing centralized infrastructure or dollar calculations. This document defines the larger direction; it does not authorize implementation in any repository.

Goal

Build an evidence base that can answer four related questions:

  1. How much AI consumption did a delivery activity use?
  2. What did that activity cost in AI compute and human effort?
  3. What will a proposed issue, feature, epic, or product likely require?
  4. How accurate and well calibrated were previous estimates?

The framework should support planning and implementation across the client portal, consulting site, AI delivery orchestrator, and later repositories without coupling historical facts to one workflow engine or model provider.

Measurement principles

Event model

Every event has an immutable identity, schema version, occurrence time, source, repository/work-item references, event type, outcome, and provenance. Optional fields remain absent or explicitly unavailable; unknown values are not reported as zero.

Event types

Event type Purpose
model_invocation Provider-reported model usage for one attributable attempt or turn.
delivery_estimate A prediction range, confidence, assumptions, and estimator version.
delivery_evaluation A comparison of a prior estimate with completed actuals.
pricing_snapshot Dated provider/model rates and the source used for cost derivation.
human_effort Deliberately recorded planning, review, correction, or operational effort.
event_correction A replacement or qualification that preserves the original event.

Model invocation fields

The initial ai-usage/v1 contract contains:

Group Fields
Identity schema_version, event_id, occurred_at
Source source, provider, workflow, workflow_version
Work repository, issue_number, optional pull-request and hierarchy references
Scenario stage, prompt_category, attempt, outcome, measurement_status
Model model, optional model_version, reasoning_effort, optional service tier
Usage input_tokens, cached_input_tokens, output_tokens, reasoning_output_tokens
Timing started_at, completed_at, duration_ms
Provenance Run URL or private artifact reference, collector version, and correlation IDs

Cached input is a classified portion of input, and reasoning output may be a classified portion of output. Consumers must follow the provider contract and must not blindly add every field together. An unavailable measurement uses nullable counts plus an explicit reason rather than synthetic zero usage.

The portal pilot uses one event per workflow attempt because that is the smallest unit with deterministic issue, stage, model, and run attribution. A future orchestrator may emit finer-grained invocation events and derive an attempt view.

Work hierarchy

Events reference stable work identities rather than embedding rollups:

Product
  Epic
    Feature or story
      Issue
        Plan
          Delivery attempt
            Model invocation

Not every repository uses every level. Missing hierarchy levels remain absent; they are not inferred from issue titles. Relationships may be added later as versioned mapping records without changing the invocation event.

Rollups and economics

Derived views should answer questions such as:

Dollar calculations join invocation events to the pricing snapshot effective for the provider, model, service tier, and usage class. Store both the derived amount and the pricing-snapshot reference in analytical output. Distinguish:

Initial portal pilot

The client portal is the first measurement surface because its label-triggered workflow already assigns each valid model run to an issue and one of three stages: planning, revision, or implementation. It also selects an explicit model and reasoning effort before execution.

The pilot should:

The pilot deliberately excludes local interactive sessions, the consulting site, centralized storage, dashboards, estimation agents, and orchestrator integration. A hard-cancelled GitHub Actions run may not execute its finalizer; later reconciliation should discover this from workflow-run state.

Target architecture

After the pilot proves that measurements are complete, safe, and useful, move from issue comments as a pilot record to an access-controlled ingestion path:

Repository automation, local agents, and delivery orchestrator
  -> authenticated event ingestion
  -> schema validation, deduplication, and policy checks
  -> append-only object storage
  -> derived analytical datasets
  -> queries, forecasts, and evaluation reports

The preferred AWS direction is:

This infrastructure belongs in separately approved orchestrator or operations issues. The public meta repository contains only the generalized design.

Estimation and evaluation

Estimator

When an issue becomes eligible for development, an estimator should produce a delivery_estimate event with:

The estimator proposes planning evidence; it does not approve scope, budgets, or implementation.

Evaluator

After completion, an evaluator emits a separate delivery_evaluation event that references the estimate and actual rollup. It records:

Begin with transparent heuristics and cohort summaries. Consider a learned predictor only after the event definitions are stable, missingness is understood, representative completed work exists, and backtesting demonstrates an improvement over the heuristic baseline.

Delivery sequence and gates

Phase 1 — Portal automation pilot

Implement issue-attributed token events in the client portal. Review a small set of naturally occurring planning and implementation runs for completeness, privacy, duplicate handling, and operational noise.

Gate: proceed only if events can be captured without weakening the existing credential and publishing boundary.

Phase 2 — Portable repository measurement

Extract the proven event contract and publisher behavior into a versioned, reusable component. Open a consulting-site adoption issue rather than copying unreviewed workflow code.

Gate: the portal pilot must demonstrate stable fields and useful issue history across successful, failed, and retried attempts.

Phase 3 — Local interactive measurement

Add an opt-in local collector and an explicit command or workflow that binds a Codex conversation to a repository, issue, scenario, and operator-selected privacy policy. Account-wide token totals are supporting evidence, not exact issue attribution.

Gate: correlation must be deliberate and inspectable; repository identity must not be guessed solely from aggregate workspace analytics.

Phase 4 — Orchestrator events and centralized storage

Extend the delivery orchestrator’s existing model-provider provenance and usage contract into canonical invocation events when its real model adapter is separately authorized. Add secured ingestion, append-only storage, retention, and reconciliation for missing or cancelled attempts.

Gate: complete the threat model, data classification, access model, cost budget, and recovery design before accepting private repository or client events.

Phase 5 — Cost, estimation, and evaluation

Add pricing snapshots, derived cost views, heuristic estimates, post-delivery evaluations, and confidence reporting. Aggregate issue predictions into feature, epic, and product ranges without presenting the sums as more certain than their inputs.

Gate: publish forecast quality and data limitations alongside every decision-support view.

Privacy, security, and governance

Success measures

The framework is useful when it can show, with explicit data-quality caveats:

The objective is not to minimize tokens in isolation. It is to improve the quality, predictability, and total economics of useful delivery outcomes.