Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
Quality evidence for feature changes

Assess compactness and readability alongside behavioral and performance evidence. The tools below produce additional observations; they do not decide whether a feature is correct, beautiful, or accepted. Required behavior, typed error causes, cleanup, capture lifetimes, and ownership remain mandatory. Use the existing formatter and naming gates, review meaningful whitespace and simple control flow, and preserve useful comments and error handling. Measure complete client files including helpers with the source compactness tool.

There is no weighted score, universal cognitive limit, minimum token reduction, or invented performance budget. A small source can still be difficult to read. Human review should identify concrete reasons: clear names, visible lifecycle steps, understandable configuration, local reasoning, and consistent error paths.

Cognitive complexity and readability signals

tools/quality/readability.cmake invokes an installed Clang-tidy cognitive complexity check with the existing compilation database. It needs CMake 3.24 or newer and a compatible Clang-tidy installation, including C++23 headers for the configured toolchain. It requires no Python on Windows. Generate compile_commands.json with the project's Ninja configuration and CMAKE_EXPORT_COMPILE_COMMANDS=ON; Visual Studio generators do not supply this database.

In PowerShell, with an existing compatible build:

cmake "-DBUILD_DIR=$PWD/build/windows-msvc-release" `
"-DFILES=$PWD/tools/compactness/scanner.cpp;$PWD/tools/compactness/report.cpp" `
"-DHEADERS=$PWD/tools/compactness/compactness.hpp" `
"-DCLANG_TIDY=C:/Program Files/LLVM/bin/clang-tidy.exe" `
"-DOUTPUT_DIR=$PWD/history/MyFeature/readability-after-1" `
-P tools/quality/readability.cmake

Use the same cmake -D... -P ... arguments on Linux, with shell quoting for the semicolon-separated FILES list. CLANG_TIDY must be an absolute executable path when supplied; otherwise the driver searches for clang-tidy. Optional TIMEOUT_SECONDS defaults to 120 per subprocess. Sources must have explicit compilation database entries. Optional HEADERS lists explicit headers to include in the diagnostic scope and SHA-256 receipt; headers need no invented compilation command and are analyzed through the real translation units (TUs). The driver does not switch compilers to conceal an incompatible build. Canonical duplicate TUs and headers count once. Main-file and explicitly selected header diagnostics are reported; other headers are filtered out.

Optional semicolon-separated EXTRA_ARGS supplies explicit compiler arguments through Clang-tidy's --extra-arg, for example a toolchain compatibility define. Arguments are recorded in extra-args.json and status.json; production build settings remain untouched. These arguments describe the analysis configuration and must be considered when comparing receipts. They cannot override the driver's check configuration directly.

Clang filters file-entry spelling, which may contain relative paths and uncollapsed .. segments. The driver builds exact escaped regex alternatives from canonical header paths and verified aliases through explicit TU/header directories and the compilation working directory. Every alias resolves to a selected header. The actual per-TU filter is retained with the raw logs. Unusual include spellings can require an explicit analysis TU with an absolute header include; an unreported function is never assumed to have zero complexity. Diagnostics from a shared header are deduplicated by canonical location/function/complexity across TUs.

Threshold 0 enables reporting of positive cognitive complexity. This is a measurement setting, not an acceptance threshold. Zero-complexity functions are not enumerated, and filtered/unsupported functions are not fabricated. The structured positive_complexity_diagnostics count is a count of unique emitted diagnostics, not a count of all functions or proof of zero issues. Parsed records include the translation unit, original location-bearing diagnostic, function name, and complexity. Different observed complexities at one template/macro location remain distinct observations. The raw diagnostics and fixes YAML remain authoritative. Template, macro, and language limitations are those of the installed check.

ENABLE_FUNCTION_SIZE=ON and ENABLE_MAGIC_NUMBERS=ON add the existing function-size and magic-numbers signals. Their installed defaults are recorded through the tool version and configuration; they are not newly accepted project limits. They remain raw diagnostics rather than made-up source quality metrics. Existing formatting and naming checks stay separate.

Each new output directory retains status.json, version.txt, config.json, checks.txt, explicit source SHA-256 records, the compilation database SHA-256, and per-TU stdout, stderr, header filters, and exported YAML when emitted. Explicit header SHA-256 records are also retained. Source/header/database changes during analysis fail visibly. Hashes cover the explicit inputs, not the entire include graph or toolchain installation. Source and compilation database files remain untouched. Existing output directories are never overwritten.

Successful execution returns zero with status REPORTED, including a legitimate run with no positive-complexity diagnostics. Missing/incompatible tooling, missing commands, unsupported diagnostic spelling, and invalid setup return nonzero with NOT_RUN. Compiler, tool, timeout, and changed-input failures return nonzero with FAIL. Failure receipts and any collected raw evidence remain in the output directory. An unavailable compiler or check cannot produce a passing zero-issue report. Lexical brace nesting from the compactness scanner is a different diagnostic and is never labeled cognitive complexity.

Client compile and include cost

Measure the complete client translation unit, including its handlers, helpers, error handling and cleanup. Keep #include <portals/ui.hpp> and the ordinary runner in a representative UI client; the umbrella also makes ui::async available. Removing an API from an include experiment changes the workload.

Prepare the SDK separately from the timed client work. Record the library and header revisions, compiler version, configuration, full compile/link commands, source hashes and any local patch. An older installed SDK is a historical baseline even when a newer checkout uses the same compiler. Verify the library and headers belong to the intended revision before reusing build artifacts.

Use the generated client commands to observe these phases separately:

  1. Compile the unchanged full client translation unit and link its executable.
  2. Change only a handler body, then compile that translation unit and link again.
  3. Repeat with matched compiler flags and inputs for both variants, alternating their order over at least three independent pairs. Keep preparation and any warmup outside the reported pairs, and avoid overlapping your own builds.

Retain each process's exit status, raw output, start/end times and elapsed time. Report individual pairs, medians and ranges; distinguish direct compiler/linker process timing from a whole build command's scheduling and startup overhead. Document cache conditions and background load when known. Repeated commands under ordinary OS caching do not establish cold-build performance.

MSVC's /showIncludes records nested includes. Deduplicate resolved paths before reporting header counts or source bytes. These describe dependency size; they do not attribute compiler CPU time or template instantiation cost. Use the existing change-impact tool to inspect which recorded compile outputs depend on a changed header.

A temporary include exclusion can probe the effect of an API's additional includes in that client. Treat it as a diagnostic comparison: it cannot justify shipping the exclusion when the API must remain available. Overlapping timing ranges, inconsistent pair deltas or a large spread require more cautious attribution; moving declarations between headers alone does not establish a speedup. Keep compile/link observations as build evidence: the runtime benchmark adapters below do not accept compile-time records.

Performance history

tools/quality/performance.cmake archives and compares existing benchmark JSON. It does not introduce another timing loop, runtime, or benchmark framework. First build and run the exact executable for each side of a feature change; retain its exit code and JSON before importing. Use a directory layout such as history/MyFeature/before-run-1, after-run-1, and further independent runs. No directory or comparison file is overwritten. This provides history through retained artifacts; there is no automatic scheduler, checkout, or Git operation.

Example for the existing managed benchmark, in PowerShell:

New-Item -ItemType Directory -Force history/MyFeature | Out-Null
& ./build/Release/portals_managed_benchmark.exe --rows 128 --samples 30 --warmup 5 `
--output history/MyFeature/raw-after-1.json
$benchmarkExitCode = $LASTEXITCODE

Prepare a metadata JSON object with actual provenance for that invocation:

{
"revision": "actual source revision; include a patch identity for dirty work",
"toolchain": {
"compiler": "actual compiler/version",
"configure_command": "actual configure invocation and flags"
},
"configuration": "Release",
"host": {
"os": "actual OS/version and host identity",
"cpu": "actual CPU",
"power_mode": "actual power mode",
"background_load": "observed concurrent workload"
},
"command": ["actual/path/portals_managed_benchmark.exe", "--rows", "128", "--samples", "30", "--warmup", "5", "--output", "history/MyFeature/raw-after-1.json"],
"benchmark_exit_code": 0,
"workload": "managed rows128 samples30 warmup5"
}

Replace every descriptive value with the actual evidence; the example is not a measurement receipt. Record the observed exit code, not an assumed zero. Additional metadata such as executable SHA-256, source patch SHA-256, build command, and measurement start/end times is retained when supplied. The script cannot prove caller-supplied provenance or that an executable was built from the named revision. Keep provenance truthful and the required behavior checks alongside the history. When raw JSON supplies compiler/build stamps (managed and MVP application), use those exact strings for toolchain.compiler and configuration; contradictory metadata is refused. Compact and separate-encoding output lack these stamps and require caller-supplied provenance.

Import and compare:

cmake -DMODE=record -DKIND=managed `
"-DRAW_FILE=$PWD/history/MyFeature/raw-after-1.json" `
"-DMETADATA_FILE=$PWD/history/MyFeature/metadata-after-1.json" `
"-DOUTPUT_DIR=$PWD/history/MyFeature/after-run-1" -P tools/quality/performance.cmake
cmake -DMODE=compare "-DBEFORE_DIR=$PWD/history/MyFeature/before-run-1" `
"-DAFTER_DIR=$PWD/history/MyFeature/after-run-1" `
"-DOUTPUT_FILE=$PWD/history/MyFeature/comparison-1.json" -P tools/quality/performance.cmake

Record mode keeps byte-exact raw.json, including formatting, line endings, and all raw samples exported by the existing benchmark. record.json contains schema 1, adapter portals-performance-1, UTC import time, raw SHA-256, supplied metadata, and normalized observations. Import time is not the measurement start time. The original input is untouched. Compare mode rechecks the raw hash and recomputes observations rather than trusting cached normalized numbers.

Supported observations and compatibility

KIND Existing output and observations
managed Schema-1 complete/correctness-verified managed benchmark; per API/rows/phase p50/p95 ns, retained min/max/count/raw timing samples, and scene-node context. --check is refused as a performance baseline.
style_layers Schema-1 complete/correctness-verified style-layer benchmark; update and explicit frame-render p50/p95 ns with retained samples, plus defaults/paint calls, render commands, invalidation, redraw requests, explicit frames, idle redraws and terminal bytes as context. --check is refused as a performance baseline. Optional ordinary allocation calls and requested bytes are separate update/frame series.
compact Current compact benchmark stdout; per API/phase p50/p95 ns, ordinary allocation-call min/max, sample count, scene nodes, and column workload. This benchmark exports no raw timing arrays or timing variance; those fields remain absent/null in the evidence.
pss portals.pss.v1 runtime parser benchmark; all seven case identities, raw batch averages and nearest-rank p50/p95. Values are exactly scaled to integer ns_per_batch; evidence records distribution: batch_means, the batch scale, and original ns_per_parse units.
mvp application Schema-1 complete fixed-viewport application observation with successful accounting, OHLC, and shutdown; phase, transport-read, data-ingress, and runner-control p50/p95 with retained range/count/overflow; actual accepted frames, bytes, wall time, and process CPU time as context.
mvp separate encoding Schema-1 complete oracle-verified encoding observation; full/diff/render p50/p95, retained ranges/counts/raw samples, and frame/byte context.

For managed, style-layer and MVP series, nearest-rank summaries are checked against retained raw samples. Empty or overflowed MVP series have NOT_MEASURED evidence and null comparison values; retained partial sample ranges remain visible. Never turn a missing latency phase into zero. Compact allocation counters count ordinary new/new[] calls, not bytes, aligned allocation, or malloc. Managed output has no allocation metric to invent. Timing boundaries and units are described in the benchmark README and managed measurement documentation.

Style-layer summaries contain count, p50, p95 and samples; each series must contain exactly samples_per_case nonnegative integer samples. The adapter requires unit: ns and percentile: nearest_rank. Allocation measurement uses the optional top-level stamp allocations: ordinary_new_calls_and_requested_bytes and per-case update_allocations, frame_allocations, update_allocated_bytes and frame_allocated_bytes summaries with the same shape. Their units are calls and bytes, respectively. They count calling-thread ordinary new/new[] calls and requested bytes during each phase; aligned allocation, malloc and live memory are outside that scope. Legacy allocations: null or an absent allocation stamp produces NOT_MEASURED values. A measured stamp requires all four series in every case; allocation series without that stamp are rejected. Allocation instrumentation is part of timing compatibility because its counters run inside the timed phases. Null and absent stamps share the not_instrumented signature; they cannot be compared with an instrumented run. Instrumented runs must use the same allocation method to compare timings.

PSS v1 emits its report after validating every timed result outside the timer. It has no separate completion or correctness flag: import checks the known producer contract in tools/benchmarks/pss.cpp, positive checksum, complete case and sample sets, supported timing/cleanup headers, and successful process exit in the required metadata. This is provenance for that producer, not an independent semantic proof. Its p95 describes the distribution of batch means, not individual parse-call latency. Successful owning-result destruction is excluded; partial error cleanup is included. Memory remains NOT_MEASURED.

The native CMake adapter reads original decimal tokens without floating-point evaluation. It accepts nonnegative ordinary decimal notation with at most 15 fractional places after removing trailing zeros, only when multiplication by batch produces an exact integer within 2^53-1. Scientific notation, excessive precision, inexact scaling, and overflow fail explicitly; arbitrary batch sizes can therefore produce unsupported reports. Raw JSON bytes and their SHA-256 are preserved unchanged. Scaling enables comparison without rounding, but does not turn batch averages into individual-call samples. PSS import rejects duplicate JSON object keys, including escaped spellings of the same key, before interpreting numeric tokens. Quoted key-like text is treated as a string value. The v1 case shape is flat except for its raw numeric array; nested case extensions are rejected to keep token extraction unambiguous.

Comparison requires identical benchmark kind, toolchain metadata, configuration, host metadata, workload label, actual raw-derived workload signature, and metric shape/units. Managed signatures include compiler, assertion mode, pointer width, sample/warmup counts, APIs, rows, nodes, and controls. Compact signatures include sample/warmup/node/column counts and APIs. MVP application signatures include compiler, platform, transport, rate, seed, rows, frame cap, observation/warmup, delay, color/text modes, diagnostics, capacity, boundaries, and viewports. MVP encoding signatures include capture identity, frames, repetitions, and modes. PSS signatures include schema, API, units, sample/warmup/batch counts, traversal order, timing and destruction/cleanup boundaries, and each case's identity, source-byte count, validity, and expected-rule count. Style-layer signatures include compiler/build, assertion mode, pointer width, clock, units, percentile method, sample/warmup counts, explicit frame workload and the ordered case identities: API, control count, theme-rule count, visibility, operation and update kind. Empty or duplicate identities fail import. Missing or reordered cases fail comparison rather than pairing unrelated scenarios. Revision and executable/output paths in recorded commands may differ. Configure commands inside toolchain metadata are compared exactly, so consistently record their invocation context. Mismatched inputs fail instead of quietly producing an apples-to-oranges ratio. Metadata equality cannot eliminate ambient noise.

Every available metric reports before, after, signed delta, and after_over_before; zero baseline ratios are null. Ratios use six fractional digits, truncated by integer long division. Nonnegative integer observations through 2^53-1 are supported; fractional or larger timing/counter fields are refused explicitly. Existing floating CPU/throughput summaries remain available in raw JSON and are not reinterpreted as integer metrics.

Increased durations or allocation calls are labeled CANDIDATE_REGRESSION. Decreased observations are labeled OBSERVED_DECREASE; node/frame/byte context does not receive a universal better/worse direction. This is a candidate finding, not causality or statistical significance. Each comparison contains one independent invocation per side. Thirty phase samples within one invocation are not thirty independent runs. Retain repeated runs under controlled conditions, inspect sample ranges and the existing benchmark's noise limits, and confirm a candidate before attributing it to a feature. The MVP benchmark's documented primary profile uses three independent runs per rate; do not replace that policy with one short fixture observation. Missing historical baselines remain missing.

Errors in setup, metadata, JSON shape, raw-summary consistency, complete/correctness flags, SHA-256, compatibility, or numeric support produce nonzero FAIL diagnostics. Failed comparisons publish no success report. CMake fixture tests cover managed, style-layer, compact, and both MVP adapters, zero/null values, incomplete/overflowed samples, raw retention/tampering, metadata/workload incompatibility, malformed inputs, and unavailable/unsupported Clang policy without running slow benchmarks. Pass an absolute TEST_CLANG_TIDY executable to tests/quality_tools.cmake to add live TU/header scope, cross-TU deduplication, and compiler-failure integration; without it that stage reports NOT_RUN explicitly.