Git, GitHub & Version Control

Chapter 14
Engineering Analytics, AI and Future Version-Control Practice

Bachelors Program in Full Stack Development
Git, GitHub & Version Control   •   Bachelor

Engineering Analytics, AI and Future Version-Control Practice

Introduction

Git and GitHub began as tools for recording source-code history, but contemporary software organisations use them as evidence systems for engineering work. Commits, pull requests, reviews, deployments, incidents, branch protections, identity records and audit events can collectively describe how software is changed and delivered. This evidence supports improvement—but it can also be misused. A commit count is not a measure of value, a short pull request is not automatically a good pull request, and a high deployment frequency is not beneficial if reliability declines.

This chapter examines responsible engineering analytics, GitHub APIs and audit logs, AI-assisted coding and review, and emerging practices including merge queues, platform engineering, policy as code and software attestations. The central principle is that measurement should improve systems and decisions, not create surveillance or reward superficial activity.

Learning Objectives

By the end of this chapter, you should be able to:

  • interpret contribution, review, lead-time, change-failure and workflow metrics responsibly;
  • distinguish descriptive evidence from causal claims about productivity;
  • retrieve and validate evidence using GitHub APIs and audit logs;
  • design dashboards that protect confidentiality and avoid harmful incentives;
  • evaluate AI-assisted coding and review with human accountability, provenance and data controls;
  • explain how merge queues, platform engineering, policy as code and attestations influence version-control practice.

1. From Repository History to Engineering Evidence

A repository contains several kinds of evidence:

EvidenceExamplesWhat it can help describe
Change evidencecommits, diffs, tagsWhat changed and when
Collaboration evidencepull requests, comments, approvalsHow change was discussed and reviewed
Delivery evidenceworkflow runs, deployments, releasesHow change moved toward production
Reliability evidenceincidents, rollbacks, failed deploymentsConsequences after delivery
Governance evidencebranch rules, audit events, identity recordsWhether controls were followed

These evidence types have different meanings. A commit timestamp may represent local work completed earlier, rebasing, or an automated update. A pull-request creation time may not equal the beginning of development. A deployment may contain many changes. Therefore, analytics must define events and boundaries before calculating metrics.

A useful analytical model separates four questions:

  1. Activity: What actions occurred?
  2. Flow: How long and how smoothly did work move?
  3. Outcome: What quality, reliability or customer result followed?
  4. Context: What constraints, risks and dependencies influenced the result?

Metrics become more credible when all four questions are considered together.

2. Interpreting Engineering Metrics

2.1 Contribution metrics

Contribution metrics may include number of commits, lines added or deleted, pull requests opened or merged, review comments, files changed and authors contributing to a repository. They are useful for describing repository activity and identifying process bottlenecks. They are weak proxies for individual productivity.

For example, one carefully designed architectural change may have few lines but substantial value, while generated code may create thousands of lines with little design contribution. Pair programming, mentoring, incident response, documentation and system design may produce few commits. A responsible dashboard therefore uses contribution data primarily at team or system level and combines it with qualitative evidence.

Lines changed should not be treated as a universal productivity measure. They are affected by formatting, generated files, vendor code, refactoring, programming language and repository conventions. If used for a narrow purpose, exclusions and counting rules must be documented.

2.2 Review metrics

Common review measures include:

  • Review response time: time from a review request or comment to the next substantive response.
  • Time to first review: time from pull-request readiness to the first review event.
  • Review cycle time: time from readiness to approval or merge.
  • Review participation: number and diversity of reviewers involved.
  • Rework rate: proportion of pull requests requiring significant revision after review.

Averages can conceal long delays, so medians and upper percentiles are often more informative. For a set of durations x1, x2, ..., xn, the arithmetic mean is:

x̄ = (1/n) ∑ᵢ₌₁ⁿ xᵢ

where n is the number of observations and x̄ has the same time unit as each observation. The median is the middle ordered observation, or the average of the two middle observations when n is even. The mean is sensitive to unusually long waits; the median describes a typical case more robustly.

Review metrics require a readiness definition. Including weekends, waiting for an author, or time spent in an external dependency can materially change results. Teams should distinguish active work time from elapsed time and report both when useful.

2.3 Lead time and cycle time

In software delivery, lead time for changes is commonly measured from code committed to code successfully running in production. Some organisations instead measure from work-item selection to production. Neither definition is automatically correct; the definition must be explicit and stable.

For change i, if its start event occurs at si and production event at pi, its elapsed lead time is:

Li = pi − si

Both timestamps must use the same time standard, normally UTC, and the result has a unit such as hours or days. A team-level median lead time is the median of the individual Li values. Lead time is meaningful only when the start and end events are reliably linked.

Cycle time usually refers to a narrower interval, such as time from pull-request open to merge. A system can reduce cycle time while increasing waiting before pull-request creation. Measuring only one interval can therefore create a misleading improvement story.

2.4 Deployment frequency and change-failure rate

Deployment frequency is the number of production deployments during a defined period. It may be reported as deployments per day, week or month. The unit and treatment of multiple services must be specified: ten deployments to one service are not necessarily equivalent to ten deployments across ten services.

Change-failure rate estimates the proportion of production changes that result in a failure requiring remediation, such as rollback, hotfix, incident response or service degradation. A general form is:

CFR = F / N × 100%

where F is the number of qualifying failed changes and N is the total number of production changes in the observation period. The formula assumes that failures and changes are defined consistently, that each change is counted according to an established rule, and that the observation window is appropriate. If one deployment contains many independently attributable changes, the denominator should not be silently changed without explaining the attribution method.

A high deployment frequency with a stable or falling change-failure rate may indicate effective automation and small batches. A high frequency with rising incidents may indicate reckless acceleration. A low failure rate may also reflect under-reporting, so auditability matters.

2.5 Workflow and queue metrics

Workflow metrics include the number of pull requests awaiting review, workflow-run queue time, failed checks, merge-queue wait time and work in progress. Queueing theory suggests that waiting increases as utilisation approaches capacity, but precise predictions require assumptions about arrival and service distributions. Teams should not infer a universal productivity law from a single queue metric.

A practical measure is the proportion of elapsed time spent waiting:

W = Twait / Ttotal × 100%

where Twait is time in defined waiting states and Ttotal is total elapsed time for the same item. The measure is useful only when states are mutually understood and timestamps are complete. High waiting time may indicate reviewer overload, test capacity, dependency delays or an intentionally cautious control—not simply poor performance.

3. Avoiding Misuse of Productivity Data

Engineering analytics can become harmful when managers rank individuals by commits, compare teams with different systems, or attach bonuses to a single metric. Such practices encourage gaming: splitting changes into artificial commits, approving reviews without reading them, avoiding difficult work, or suppressing incident reports.

A safer measurement design follows these principles:

  1. Purpose limitation: collect data for a stated improvement or governance purpose.
  2. Aggregation: prefer team, service or value-stream analysis over individual ranking.
  3. Triangulation: combine quantitative measures with interviews, retrospectives, defect data and customer outcomes.
  4. Context: record factors such as migrations, on-call work, staffing changes and regulatory controls.
  5. Trend analysis: compare a team with its own historical baseline rather than imposing a universal target.
  6. Metric review: periodically test whether the measure creates undesirable incentives.
  7. Privacy and fairness: restrict access, minimise personal data and provide explanations for consequential decisions.

Metrics are descriptive observations, not automatic causes. If lead time falls after a new tool is introduced, the tool may have contributed, but parallel changes—smaller work items, staffing, seasonality or changed definitions—may also explain the result. Causal claims require a credible comparison or research design, not merely a before-and-after chart.

4. GitHub APIs and Audit Logs as Evidence Sources

GitHub exposes repository and organisation information through APIs. Depending on account and product configuration, a team may use REST endpoints, GraphQL queries, webhooks, Actions data and organisation audit logs. The exact fields, retention periods, permissions and rate limits vary, so production analytics must consult current platform documentation and test against the deployed GitHub plan.

4.1 Evidence pipeline

A defensible pipeline contains the following stages:

  1. Define the question. For example: “Where does review waiting time accumulate?”
  2. Specify event semantics. Define ready-for-review, approval, merge, deployment and failure.
  3. Collect minimally. Request only fields needed for the purpose.
  4. Authenticate securely. Use short-lived or narrowly scoped credentials where possible; never place tokens in source code.
  5. Handle pagination and rate limits. APIs commonly return partial pages and may reject excessive requests.
  6. Normalise time and identity. Store timestamps in UTC and document how bots, renamed users and deleted accounts are handled.
  7. Validate. Compare API results with repository interfaces, deployment records and sampled pull requests.
  8. Version definitions. Record query logic, extraction time and schema changes.
  9. Control access. Protect raw events and publish only appropriate aggregates.

A simple conceptual data model links entities such as pull_request, commit, workflow_run, deployment, incident and actor. A pull request may reference many commits, a deployment may include many pull requests, and an incident may be related to one or more deployments. These are many-to-many relationships in practice; forcing a one-to-one model can create false precision.

4.2 Audit logs

Audit logs answer governance questions such as who changed a branch rule, enabled a workflow, modified repository visibility or accessed administrative functions. They are not a complete record of every engineering thought or every local action. Retention, event coverage and access depend on GitHub configuration and plan.

Audit evidence should be treated as security-sensitive. A good process includes restricted access, documented retention, integrity protection, clock synchronisation and a procedure for investigating anomalies. Logs should support accountability without becoming unrestricted employee surveillance.

5. AI-Assisted Coding and Review

AI tools can generate code, tests, documentation, explanations and review suggestions. They can accelerate routine work, but they do not remove the need for software engineering judgment. Generated output may be incorrect, insecure, biased, incompatible with local architecture or based on confidential input.

5.1 A human-governed workflow

A responsible workflow contains these controls:

  • the developer remains accountable for understanding and testing submitted code;
  • generated suggestions are treated as untrusted drafts;
  • static analysis, dependency scanning, tests and human review remain required;
  • prompts and outputs are handled according to organisational confidentiality rules;
  • high-risk code receives stronger review, such as security or domain-expert approval;
  • generated material is identifiable where provenance is important;
  • licences, attribution obligations and third-party terms are checked;
  • model and tool versions are recorded when reproducibility matters.

AI review should assist, not replace, independent human review. A model can identify a missing null check while overlooking a flawed business assumption. It may also produce confident but unsupported explanations. Reviewers should verify claims against code, tests, requirements and runtime evidence.

5.2 Provenance and confidentiality

Provenance answers: What tool or model produced this artifact? What input context was supplied? What human edited or approved it? Which tests and policies were applied? A lightweight record may include tool identity, model version, timestamp, repository revision, prompt classification, generated-file status and approving reviewer. Sensitive prompts should not be copied into public issues or unrestricted logs.

Organisations should classify repositories and data before enabling AI tools. Source code containing credentials, personal data, regulated information or undisclosed intellectual property requires stricter controls. Secret scanning and data-loss-prevention measures are complementary; neither makes unsafe disclosure acceptable.

5.3 Evaluating AI assistance

Evaluation should use task-relevant outcomes: defect rates, security findings, test adequacy, review effort, maintainability, developer learning and incident frequency. It should compare equivalent tasks and account for selection effects. “More accepted suggestions” is not sufficient evidence of benefit.

A useful governance question is not “Did AI write this line?” but “Can the organisation explain, test, secure, attribute and maintain this change?”

6. Emerging Version-Control Practices

6.1 Merge queues

A merge queue places approved changes into an ordered integration process. It may create temporary speculative branches, run required checks and merge only changes that remain valid with the current target branch. This reduces the risk that individually passing pull requests break the branch when merged together.

Merge queues introduce trade-offs: queue waiting, compute cost, ordering disputes and possible frustration when a late failure invalidates several candidates. Useful measures include queue wait, validation duration, invalidation rate and post-merge failure rate. A queue should be configured with clear priority rules and emergency procedures rather than treated as a magical substitute for good integration practices.

6.2 Platform engineering

Platform engineering provides reusable internal capabilities—repositories, build pipelines, deployment paths, observability, secrets integration and compliance controls—as products for development teams. Its objective is to reduce cognitive load while preserving appropriate autonomy.

A platform team should define service-level expectations, document paved and alternative paths, measure adoption and collect developer feedback. Centralisation can improve consistency, but an inflexible platform can become a bottleneck. The platform must be treated as an evolving product, not merely an operations ticket queue.

6.3 Policy as code

Policy as code expresses rules in machine-evaluable form. Examples include requiring signed commits, preventing direct pushes to protected branches, requiring successful tests, restricting deployment environments and checking infrastructure configuration.

Policy automation improves consistency and produces evidence, but policies can be incomplete or wrong. Every policy needs ownership, testing, version control, review, exception handling and an expiry mechanism for temporary exceptions. A rule that blocks all change during an emergency may reduce rather than increase safety.

6.4 Software attestations and supply-chain evidence

An attestation is a signed statement about an artifact or process, such as the source revision, build system, dependencies, tests or provenance of a container image. Attestations support verification by downstream systems and help organisations investigate compromised build paths.

Attestations are not automatically proof that software is safe. Their value depends on trustworthy signing keys, protected build environments, accurate claims, identity binding and verification. A signed statement from a compromised process can still be a misleading statement. Organisations should define which claims are required and how verifiers respond when evidence is missing or invalid.

7. Integrated Case: The Northstar Payments Team

This is an illustrative case, not a report of a real organisation.

Background

Northstar Payments operates a service used by online retailers. Its engineering director introduced a dashboard showing commits per developer, pull-request counts, average review time, deployment frequency and failed deployments.

Problem

After two quarters, commit counts increased, but customer incidents also increased. Developers began splitting work into many small commits, avoiding large refactors and approving reviews quickly. The dashboard reported a lower average review time, although reviewers later disclosed that they often inspected changes after approval.

Analysis

A cross-functional group audited the metric definitions. The average review time excluded weekends but included time before a pull request was marked ready. Deployment frequency counted staging and production deployments together. Failed deployments were recorded manually and omitted rollbacks caused by configuration changes. The data therefore mixed incompatible event definitions.

The group replaced individual rankings with team-level trends. It defined production deployment precisely, linked deployments to pull requests where possible, and classified a change failure as a production change followed by rollback, hotfix or a severity-defined incident within seven days. It reported median and 90th-percentile lead time, review waiting time, deployment frequency and change-failure rate together.

The team also introduced a merge queue for the main service, required security checks for payment-related code, and permitted an AI coding assistant only for repositories classified as suitable for external processing. AI-generated suggestions required normal human review and automated tests.

Outcome

Commit counts fell, but the proportion of pull requests reviewed before approval increased. The median lead time initially rose because the team included a previously hidden pre-review queue; after reviewer rotation and smaller service ownership groups, both the queue and the 90th-percentile lead time declined. Reported failures initially increased because the new definition captured rollbacks that had previously been omitted. Subsequent quarters showed a lower change-failure rate and fewer severe incidents.

Learning points

The case demonstrates that better measurement can make performance appear worse before it becomes more accurate. It also shows why metrics need definitions, context and governance. A metric system should reveal hidden work and risk, not reward cosmetic activity.

8. Limitations, Ethics and Professional Practice

Engineering data is incomplete. Local work may occur outside GitHub, identities may be shared by automation, timestamps may be edited by rebasing, and incident attribution may be disputed. Privacy laws and employment regulations may restrict monitoring and automated decision-making. Organisations should consult legal and security specialists where personal or regulated data is involved.

Professional practice requires proportionality. Collect the least data necessary, explain its purpose, limit access, protect retention and allow correction of material errors. Do not use analytics as the sole basis for disciplinary or promotion decisions. Human review is especially important when metrics affect employment, access or reputation.

The strongest engineering organisations treat metrics as questions for learning: Where is work waiting? Which controls prevent unsafe changes? Which automation reduces toil without reducing understanding? Which evidence supports a decision, and what evidence is missing?

Contemporary Best Practices

  • Define every metric in a data dictionary with numerator, denominator, event boundaries and exclusions.
  • Use UTC timestamps and preserve the original event source.
  • Prefer distributions, medians and percentiles over a single average.
  • Pair flow metrics with reliability and customer outcomes.
  • Aggregate by team or service unless an individual-level purpose is justified and governed.
  • Reconcile GitHub data with deployment, incident and identity systems.
  • Protect API credentials and apply least privilege.
  • Treat AI output as untrusted until tested and reviewed.
  • Record provenance when AI or automated generation affects maintenance, licensing or compliance.
  • Version policies, attestations and analytics queries.
  • Design merge queues and platforms around developer needs and explicit failure modes.
  • Review metrics and automated policies for gaming, bias and unintended consequences.

Chapter Summary

Engineering analytics turns version-control and delivery events into evidence about activity, flow, outcomes and governance. Contribution and review metrics describe work but do not measure individual worth. Lead time, deployment frequency and change-failure rate are useful only when their event definitions, units, attribution rules and limitations are explicit. Medians, percentiles, context and triangulation generally provide more responsible interpretation than isolated averages or counts.

GitHub APIs and audit logs can support evidence-based decisions, but reliable analysis requires secure authentication, pagination handling, time normalisation, validation, versioned definitions and privacy controls. AI-assisted coding and review can improve efficiency while introducing risks involving correctness, security, confidentiality, licensing and provenance. Human accountability, testing and appropriate review remain essential.

Merge queues improve integration control, platform engineering provides reusable delivery capabilities, policy as code automates governance, and software attestations provide verifiable supply-chain claims. None is sufficient by itself. Their value depends on accurate configuration, trustworthy evidence, clear ownership and continuous critical evaluation.

Key Terms

Contribution metric: A measure describing repository activity such as commits, pull requests or reviews.

Change-failure rate: The percentage of defined production changes associated with a qualifying failure.

Cycle time: Elapsed time for a defined part of a workflow, such as pull-request opening to merge.

Deployment frequency: Number of production deployments in a specified period.

Engineering analytics: Systematic analysis of software-development and delivery evidence.

Event semantics: The agreed meaning and boundary of an event used in measurement.

Lead time for changes: Elapsed time between a defined starting event and successful production operation.

Merge queue: An automated integration process that validates approved changes in target-branch order.

Metric gaming: Behaviour that improves a measured value without improving the underlying outcome.

Paved path: A supported, reusable platform route for performing a common engineering task.

Policy as code: Machine-evaluable rules maintained and reviewed as versioned artifacts.

Provenance: Evidence about the origin, processing and approval history of an artifact.

Review cycle time: Time from a defined review-ready event to approval or merge.

Software attestation: A signed claim about an artifact, build process or software property.

Telemetry: Recorded events and measurements describing system or workflow behaviour.

Triangulation: Combining multiple evidence types to improve interpretation.

Workflow queue: Work waiting for a resource such as a reviewer, runner or merge slot.

Review Questions

Short Answer Questions

  1. Why is commit count a weak standalone measure of developer productivity?
  2. Distinguish lead time from cycle time.
  3. What does change-failure rate attempt to measure?
  4. Why must API-based analytics handle pagination and rate limits?
  5. State two human controls required for responsible AI-assisted coding.

Long Answer Questions

  1. Explain how a team can design an engineering dashboard that avoids harmful productivity incentives.
  2. Discuss the assumptions and limitations involved in calculating lead time and change-failure rate.
  3. Describe a defensible evidence pipeline using GitHub APIs, workflow data and audit logs.
  4. Evaluate the benefits and risks of merge queues and policy as code.
  5. Explain why software attestations provide useful evidence but do not automatically prove software safety.

Analytical / Application Questions

  1. A team reports faster average review time but more production incidents. Identify at least four possible measurement or process explanations and propose an investigation.
  2. Design metric definitions for a service that uses pull requests, a merge queue and automated production deployment. Specify start events, end events, failure rules and useful distribution summaries.
  3. An organisation wants to permit an AI coding assistant in repositories containing customer data. Develop a governance decision that addresses confidentiality, provenance, human review, testing and access controls.

Multiple Choice Questions with Answers

Question 1

Which is the most responsible use of commit counts?

A. Ranking individual developers for promotion

B. Treating them as a complete measure of software value

C. Using them as one descriptive signal alongside context and outcomes

D. Setting a minimum number of commits per week

Correct Answer: C. Using them as one descriptive signal alongside context and outcomes

Question 2

In the formula CFR = F / N × 100%, what does F represent?

A. Total number of files changed

B. Number of qualifying failed production changes

C. Number of reviewers

D. Average deployment duration

Correct Answer: B. Number of qualifying failed production changes

Question 3

Why are medians often useful for review or lead-time data?

A. They always produce larger values than means

B. They ignore every observation except the first

C. They are less affected by unusually long delays

D. They eliminate the need to define events

Correct Answer: C. They are less affected by unusually long delays

Question 4

Which practice best supports reliable GitHub API analytics?

A. Embedding a permanent administrator token in a repository

B. Ignoring pagination because the first response is complete

C. Normalising timestamps and documenting event definitions

D. Deleting raw data immediately after each query

Correct Answer: C. Normalising timestamps and documenting event definitions

Question 5

What is the primary role of a merge queue?

A. To replace all human code review

B. To validate approved changes as they are integrated with the target branch

C. To increase the number of artificial commits

D. To disable automated tests before merging

Correct Answer: B. To validate approved changes as they are integrated with the target branch

Question 6

Which statement about AI-generated code is most accurate?

A. It is correct whenever the model explains it confidently

B. It should be treated as an untrusted draft requiring testing and human accountability

C. It does not require licence or confidentiality review

D. It makes security review unnecessary

Correct Answer: B. It should be treated as an untrusted draft requiring testing and human accountability

Question 7

What does provenance primarily document?

A. Only the number of lines in a file

B. The origin, processing and approval history of an artifact

C. The colour scheme of a repository

D. The average age of developers

Correct Answer: B. The origin, processing and approval history of an artifact

Question 8

Which is an example of policy as code?

A. A private verbal agreement to review changes

B. A versioned automated rule requiring successful checks before merge

C. An unrecorded preference for short commits

D. A manually remembered deployment convention

Correct Answer: B. A versioned automated rule requiring successful checks before merge

Question 9

A team has 4 qualifying failed changes among 80 production changes. What is its change-failure rate?

A. 0.5%

B. 5%

C. 20%

D. 84%

Correct Answer: B. 5%

Question 10

Why should engineering metrics generally not be used alone for disciplinary decisions?

A. Metrics are always mathematically impossible to calculate

B. Repository events may be incomplete, contextual and subject to interpretation

C. Teams never produce measurable events

D. Audit logs cannot contain timestamps

Correct Answer: B. Repository events may be incomplete, contextual and subject to interpretation

Git, GitHub & Version Control
Chapter 14 of 14