Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This index is navigation. Delivery status lives in issues, not here.
- [Architecture decisions](adr/README.md)
- [ADR 022 — Timeline 属性查询与正文重建](adr/022-event-property-queries.md)(中文):目标 API 与模块结构、属性查询、业务状态恢复和正文释放
- [ADR 023 — 上下文用量由独立分支部件维护](adr/023-context-usage.md)(中文):ContextUsage 的职责、增量统计、服务商校准及后续设计边界
- [ADR 026 — Verification tiers, test coverage and CI governance](adr/026-verification-tiers-and-ci-governance.md)([中文](zh/adr/026-verification-tiers-and-ci-governance.md)):three operational test states, verification tiers (L0–L4), form-only doc checks and CI governance (#1938)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: the linked issue #1938 still calls this proposal "ADR 025", which now names PR #1941's rutis ADR. Updating the issue body to 026 would keep this index link from pointing at a stale number.

- [Resume:按业务对象设计计算与读取](design/resume-read-design.md)(中文,草案):usage、输入队列、Prompt、显示详情、SQL 执行和恢复校验的分项设计与成本验收
- [当前状态字段索引](design/appserver/timeline-state-read-indexes.md)(中文,草案):现有API缺口、完整索引键、源位置前驱和SQL扫描验收
- [状态保存与恢复读取](design/owner-state-indexed-reads.md)(中文,草案):按业务对象决定持久化;当前队列点查、Prompt有效引用、Usage数字和真实流程读写数量
Expand Down
173 changes: 173 additions & 0 deletions docs/adr/026-verification-tiers-and-ci-governance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# 026: Verification tiers, test coverage and CI governance

Decision status: Proposed.

## Context

Repository verification grows monotonically when every discovered defect or new check is appended
directly to the pull-request gate. Over time, two distinct concepts get conflated:

- **Repository verification coverage**: every check, formal model, suite, benchmark and acceptance
procedure the repository maintains.
- **Active pull-request gate**: the bounded subset that must complete synchronously before a change
merges.

When those two are treated as identical, slow suites, cross-platform checks, compile-time rebuild
loops and brittle text scans all pile onto one flat gate. Raising timeouts when jobs approach the
ceiling hides the degradation until queues, compiler-cache eviction and mutual cancellations erode
both contributor turnaround and `main` signal quality.

## Decision

### D1. Verification separates into three operational states; tiers (L0–L4) map assets to states

Every verification asset has an explicit operational state that governs its lifecycle and CI cost:

1. **Active gate**: runs automatically on pull requests under explicit wall-clock budgets, guarding
high-frequency contracts and the affected dependency closure.
2. **Retained (on-demand & sweep)**: stays in the repository without gating ordinary pull requests.
Runs when the asset's own source files change (for example, formal model edits), on scheduled
full sweeps, before release, when diagnosing or reproducing a failure, or when a design/protocol
review calls for it — with the tier table's "Default state & trigger" column authoritative for
each tier. Retained Rust tests remain compiled (for example, consolidated with `#[ignore]`) so
they do not bitrot; external-toolchain checks (TLC/Java, local tmux E2E, standalone profiling
scripts) stay out of everyday build toolchains.
3. **Dev / exploratory**: temporary probes or fine-grained local tests created while developing or
debugging. Ablated before merge: enduring contract coverage moves into the active gate (D3),
reusable diagnostic reproducers move into Retained, and throwaway scaffolding is removed.

Verification tiers (L0–L4) map each class of asset to its default operational state and trigger:

| Tier | Question answered | Scope | Default state & trigger |
| --- | --- | --- | --- |
| **L0 — Design & formal** | Do abstract state-machine, protocol and handover invariants hold? | Formal models (e.g. TLA+ specifications and `.cfg` properties) | **Retained**: (a) triggered on formal model file changes (with tool cost disclosed under D4 if wired into CI), and (b) enforced via PR checklist/review whenever an implementation change alters a modelled handover, recovery or ordering guarantee. Not run on ordinary implementation PRs. |
| **L1 — Static form & contract** | Are formatting, dependency boundaries, ADR immutability, public schemas/wire types and license/advisory policies intact? | Formatters, linters, pure static form/structure checks (including ADR freeze checks on every PR / ADR edit), frontend typecheck/lint, source-derived wire/schema contracts, dependency advisory/license scans | **Active gate**: fast fail-first on every PR, scoped to the changed surface (dependency scans only on manifest, lockfile or policy changes). |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: this parenthetical does not match today's job. .github/workflows/ci.yml:54-76 runs cargo deny when rust == true or dependencies == true, and scripts/ci-changes.mjs:20-26 sets rust for crate and workspace changes, so a Rust source change runs the scan even with no manifest or lockfile change. If the sentence describes the target scoping, say so or cite the follow-up.

| **L2 — Business flows** | Do modified modules and their transitive consumers preserve behavioral contracts? | Unit and in-process or loopback flow tests (plus runtime-assembled structural checks that require compiling the workspace) | **Active gate** on the primary high-throughput platform for the **reverse-dependency closure** of changed crates (expanding to the full workspace when foundational crates or workspace-wide configuration change). Heavy historical, soak or low-frequency flows belong in **Retained**. |
| **L3 — Real environment & cross-platform** | Do real OS primitives, process/plugin wiring, terminal interaction and external protocol boundaries work? | OS-native boundary slices, real daemon + plugin runtime flows, interactive terminal E2E suites, external registry acceptance | **Split**: narrow OS-native boundary slices run in the **Active gate** only on PRs touching platform/client code; full cross-platform runs and external-registry acceptance are **Retained** (asynchronous `main`/scheduled sweeps, pre-release or on-demand); interactive terminal E2E is **Retained (local-only)** — run locally on demand or before release, **never** invoked by a CI workflow. |
| **L4 — Quality, performance & release** | Have model quality, resource budgets, executable layout or distribution artifacts regressed? | Evaluation harnesses, memory/startup measurements, native code-layout builds, multi-platform release builds and registry/image acceptance | **Execution is always Retained** (scheduled, manual or release train only — never gates ordinary feature PRs). Changes to an L4 harness itself run the harness's own L1/L2 checks in the **Active gate** on that PR. |

Formal models (L0) verify that an abstract state machine satisfies safety and conditional liveness
invariants within a finite state space; they do not compile or test implementation code. Ordinary
implementation changes rely on L2 flow tests to guard that code still refines the model's actions.
If a code change alters a modelled handover or ordering guarantee, it is a design change and returns
to L0 through review before merging.

### D2. Documentation guides and states semantic contracts; automated checks enforce form, not prose semantics

Documentation exists to guide contributors and state semantic contracts. Automated checks over
documentation and source conventions enforce only **deterministic, low-false-positive form and
structural invariants**:

- **Pure static form checks (L1, zero business compilation)**: lifecycle/immutability form (such as
accepted-ADR freeze checks), link and template structure, and manifest- or AST-derived structural
checks (such as crate/module dependency boundaries and source-parsed type declarations) that do
not compile business runtime crates and do not parse natural-language prose.
- **Runtime-assembled structural projections (workspace-coupled, alongside L2)**: deterministic
code-to-document projections that inherently require compiling and assembling the runtime (such
as a live public service catalog) run on the workspace-coupled build/verify path rather than
blocking pure-static docs, frontend or script PRs.
- **Keep generated snapshots minimal**: commit and freshness-check a generated file only when
downstream code consumes it (e.g. cross-language type declarations) or when it is a concise,
actively referenced public summary. Fine-grained internal dependency graphs computed for boundary
checks are verified live in memory and generated on demand rather than committed to Git as
conflict-prone snapshots.
- **Out of scope for automated checks**: semantic correctness of prose, design quality, and
judgement calls such as whether an edit alters a modelled invariant. Avoid introducing new brittle
cross-language text scanners that try to infer semantics from raw literals and rely on growing
manual allowlists (existing allowlist-backed scanners are kept only until replaced by types,
boundaries or behavioral tests rather than imitated); enforce invariants through types,
boundaries, review checklists, L0 models and L2 behavioral tests instead.

### D3. Test coverage follows lowest flow/contract layer, single owner, release-safe injection and build hygiene

Coverage quality is measured by contract protection per unit of cost, not by test count at the top
layer.

- **Lowest flow or contract layer that proves the contract**: assertions about private modules,
helpers or single functions belong in the nearest flow or contract test rather than standalone
unit tests, while state transitions, rendering rules, validation errors and edge matrices stay
out of process-spawning, PTY or binary-copying E2E tests. End-to-end suites cover wiring and real
OS interaction on representative paths rather than exhaustive combinations.
- **One owning layer per behavior**: once a lower layer (or a dedicated suite such as the local
terminal E2E suite) proves a behavior, higher layers verify only connectivity and do not duplicate
its failure matrix. Migrating coverage to a better carrier requires retiring or demoting the
superseded active CI case in the same change or tracked migration.
- **Release-safe runtime injection instead of recompiling**: test variants (release stamps, build
IDs, clocks, endpoints, fault injection) must be injectable at runtime or test boundaries without
flipping build-time flags that recompile upstream crates in CI. **Production-safety bound**: every
test-only override must be unreachable in release builds (compiled only under debug/test builds)
or confined to test-harness entry points so test injection never widens what a shipped binary
accepts.
- **Treat test executables as build artifacts**: consolidate integration tests into a bounded number
of balanced entry binaries per crate to avoid linker and compiler-cache amplification from dozens
of single-file executables, while splitting oversized binaries that create single-process
scheduling tails or linker pressure.

### D4. Active gates operate under recorded budgets and physical light/heavy isolation

- **Recorded wall-clock and resource budgets**: every synchronous active-gate tier declares a
recorded latency and resource budget (maintained alongside runner measurements in
`docs/architecture/build.md` and tracking issues, not hardcoded as immutable constants in this
ADR). Approaching or hitting a budget is a regression fixed by narrowing scope, optimizing slow
tests, improving parallelism or demoting cases to Retained — **never** by raising job or target
timeouts alone.
- **Cost disclosure for gate additions**: any change that adds a required PR check or widens path
selection must state its incremental runtime, added compile dependencies and target runner pool.
- **Physical isolation of light checks from heavy builds**: pure static repository checks must not

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: today the static checks are still bundled. xtask/src/main.rs:67-74 runs boundaries, catalog::check, types::check, npm::check, comment_links::check and literal_main::check in one xtask check, and .github/workflows/ci.yml:186-194 runs it in the macOS verify job after the workspace build. The Consequences hedge at :143-146 covers today's state; citing #1933 here would make the planned split discoverable. The same applies to the source-parsed type declarations example at :63, which #1933 groups with types::check as workspace-coupled.

depend on compiling business runtime crates. Docs, frontend, script and static checks run in
lightweight jobs and never contend for heavy build or scarce platform runner pools.

### D5. Impact-scoped routing and platform minimalism require scheduled full sweeps and periodic pruning

- **Impact-scoped routing with sweep prerequisite**: both pull requests and pushes to `main` route
by changed paths, and `main` pushes run to completion without cancelling earlier ones. Narrowing
`main` pushes is permitted **only while an active scheduled full sweep is running** to catch
cross-group drift; a sweep failure must have defined triage ownership and commit-range bisection
back to the regressing merge on `main`.
- **Explicit path classification**: new top-level repository directories and non-code assets must
be classified explicitly in the change router rather than silently falling through to the
most expensive full-workspace fallback.
- **Scarce platforms run platform-native boundaries only**: full workspace compilation and
platform-neutral L1/L2 verification run on the highest-throughput primary platform (Linux).
Secondary OS pools (macOS, Windows) run only checks covering platform-specific code paths
(`cfg(target_os = ...)`), native OS APIs or packaging boundaries on pull requests, verified
mechanically against the source rather than maintained as an unchecked manual list.
- **Periodic telemetry and pruning**: CI health (queue p90, execution p90, cache write/eviction
volume, slowest test targets, zero-match dead steps and cancellation waste) is reviewed
periodically to retire obsolete checks and demote emerging long tails to Retained.

## Consequences

- Every new test, static check or formal model declares its operational state (Active / Retained /
Dev), tier (L0–L4) and owner before wiring into CI.
- Until this ADR is accepted and its follow-up tooling changes land, `AGENTS.md` and
`docs/architecture/` remain the authoritative reference for today's commands and committed
snapshots; once aligned, `AGENTS.md` (`## Testing`) can consolidate its testing rules onto this
ADR so the rule is stated once.
- Pure static form checks are decoupled from workspace-coupled tooling so docs, frontend and script
PRs stay fast.
- Test-only build flags move to release-unreachable runtime/harness injection, eliminating
cascading CI recompiles without weakening production boundaries.
- Concrete workflow changes, runner migrations, scheduled sweeps, test-binary consolidation and
numeric budgets live in `docs/architecture/build.md`, `docs/release/README.md` and tracking
issues rather than here.

## Non-goals

- Lowering overall defect detection or deleting coverage without an owning replacement at a more
appropriate layer or operational state.
- Freezing numeric latency targets, runner hostnames, workflow syntax or crate-by-crate routing
tables in an immutable ADR.
- Replacing design review or code review with automated checks.

## Supersession

Does not supersede any prior ADR. Extends [ADR 008](008-documentation-ownership.md) by separating
verification and CI governance principles (here) from numeric budgets and current CI implementation
(`docs/architecture/build.md`, `docs/release/README.md`) and delivery status (issues).

References: [ADR 008](008-documentation-ownership.md),
[Timeline finite model checking](../design/examples/capability-models/README.md),
[Build environment](../architecture/build.md),
[Terminal end-to-end suite](../architecture/tui-e2e.md),
[#1938](https://github.com/arcships/dim/issues/1938).
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ original text.
| [022 — Timeline 属性查询与正文重建](022-event-property-queries.md) | Proposed | Supersedes 019's event-only results, skip-based paging and start-only positions, and 020's single-predicate limit; retains 021's read ownership |
| [023 — 上下文用量由独立分支部件维护](023-context-usage.md) | Accepted | Follows 021 and 022; separates context usage statistics from request preparation |
| [024 — Web 抓取层使用请求库,地址策略在请求之前执行](024-web-fetch-transport.md) | Proposed | Follows 006 D1; replaces the hand-written transport and narrows the address policy to a pre-request check |
| [026 — Verification tiers, test coverage and CI governance](026-verification-tiers-and-ci-governance.md) | Proposed | Extends 008; defines three operational test states, verification tiers (L0–L4), form-only doc checks and CI governance |

Source baseline: [initial foundation parent](https://github.com/arcships/dim/commit/aaaffa5768e031d781abb73e45b1915b05dc2aa0).
This baseline includes lifecycle fixes not necessarily present on the default branch.
Loading