@cratis/pi 7.190.3 → 7.191.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,29 +15,27 @@ paths:
15
15
 
16
16
  # Code Health floor
17
17
 
18
- Applies when CodeScene tools (`code_health_review`, `code_health_score`,
19
- `pre_commit_code_health_safeguard`, `analyze_change_set`) are available. Without them or
20
- an account, say so in the report and continue; never block. MCP setup, approval-gated
21
- tools and tool-output handling are in [codescene.md](../../../rules/codescene.md).
18
+ Apply [criticality tiers](./criticality-tiers.instructions.md) first: score Tier A code and
19
+ maintained Tier B code when CodeScene is available. Tier C requires no scoring or
20
+ uplift. Without tools or an account, report that and continue; never block.
21
+ MCP setup, approval-gated tools and tool-output handling: [codescene.md](../../../rules/codescene.md).
22
22
 
23
23
  ## The floor
24
24
 
25
- - Every file a change creates or modifies ends at Code Health **9.5 or higher**; new files aim for 10. A touched file never declines.
26
- - A touched file that starts below 9.5 is raised to 9.5 in the same change by behavior-preserving refactoring with specs behind it (`guiding-refactoring-with-code-health` where the profile provides it).
27
- - If that is too large for the task (a red or yellow legacy file), raise it as far as is safe, report before and after, and add the file to the repository's Code Health uplift issue ("Code Health: raise all files to 9.5"; create it if none exists).
28
- - Urgent security and production fixes may ship below 9.5, but report the gap and file the uplift.
25
+ - In-scope code ends at Code Health **9.5 or higher**; new code aims for 10. A touched file never declines.
26
+ - Uplift safely with behavior-preserving refactoring and specs. A narrow fix does not require unrelated legacy uplift. If 9.5 exceeds safe scope, report the gap and suggest a follow-up; do not widen the change.
29
27
  - Never refactor generated code. A "could not determine" Code Health score is not a failure. Other Cratis rules win over a finding.
30
28
  - CodeScene has no floor setting, so the check is ours.
31
29
 
32
30
  ## Checking
33
31
 
34
- - Run `code_health_review` on each changed file while shaping it, then `code_health_score` on each changed file before delivery, then `pre_commit_code_health_safeguard` (or `analyze_change_set` against the base branch).
32
+ - For in-scope code, run `code_health_review` while shaping it, `code_health_score` before delivery, then `pre_commit_code_health_safeguard` (or `analyze_change_set` against the base branch).
35
33
  - The delivery report has a table: file, score before, score after; name each exception with its reason.
36
34
 
37
35
  ## No fix loops
38
36
 
39
- - **Once, before the gate.** Handle Code Health once per touched file: review while shaping the code (design for the score, do not write first and fix later), refactor, then one `code_health_score`. The gate and review then run once on the final shape.
37
+ - **Once, before the gate.** Handle Code Health once per in-scope file: review while shaping the code (design for the score, do not write first and fix later), refactor, then one `code_health_score`. The gate and review then run once on the final shape.
40
38
  - **Never a cycle.** No gate, score, refactor, gate loops. A score check never triggers an extra build or test run on its own; batch score fixes with the other fixes.
41
- - **One refactor pass per file per change.** If it does not reach 9.5, report the before and after and the reason, add the file to the uplift issue, and stop.
42
- - **A reported reason closes the item.** Reviewers flag only a touched file below 9.5 with no reason, together with the round's other findings, never as a review round of its own.
39
+ - **One refactor pass per file per change.** If it does not reach 9.5, report before/after and the reason, suggest the uplift follow-up, and stop.
40
+ - **A reported reason closes the item.** Reviewers flag only an in-scope file below 9.5 with no reason, together with the round's other findings, never as a review round of its own.
43
41
  - **A second Code Health round is itself a finding.** Name the cause (wrong approach, file too large for the task, tool problem) instead of iterating.
@@ -0,0 +1,39 @@
1
+ ---
2
+ applyTo: "**/*"
3
+ paths:
4
+ - "**/*"
5
+ ---
6
+ <!-- cratis-ai: generated Copilot instructions. Do not edit; rules/ is the source. -->
7
+
8
+ <!-- Copyright (c) Cratis. All rights reserved. -->
9
+ <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
10
+
11
+ # Criticality tiers
12
+
13
+ Judgment-shaped: classify by failure consequences, not repository name.
14
+
15
+ - **Tier A — Critical:** product runtime, auth/credentials, data integrity/migrations,
16
+ production deployment or automation able to disrupt all CI. Require focused
17
+ behavior/rejection specs, independent review and security/product CI. Full local gates
18
+ run only for changed inputs/dependency closure; reuse valid unchanged-input results.
19
+ - **Tier B — Operational but bounded:** internal tooling with limited, recoverable
20
+ impact (e.g. ordinary runner management). Require bounded smoke/regression checks
21
+ for meaningful behavior; review elevated permissions, broad impact or the escalation
22
+ below. No unrelated product gate; Code Health only for maintained, non-disposable code.
23
+ - **Tier C — Disposable or advisory:** noncritical dashboards, reports, local helpers,
24
+ demos/samples, experiments, prose and corpus style checks. No mandatory new specs,
25
+ review/artifacts, Code Health scoring/uplift or full local gate. Smoke checks are
26
+ optional absent specific failure risk; cheap checks may remain, cosmetics are advisory.
27
+
28
+ A change in any tier that touches credentials or secrets, authentication or authorization,
29
+ workflow permissions or untrusted-PR triggers (`pull_request_target`, `workflow_run`,
30
+ forked-PR inputs), data exposure, a trust boundary, or a destructive or irreversible action
31
+ is Tier A for that part and needs independent review, whatever the tool's tier.
32
+ Critical subcomponents inherit Tier A; unknown critical dependencies fail closed to
33
+ the higher tier. Narrow fixes need no unrelated legacy uplift. No artifacts needed
34
+ to claim a tier.
35
+
36
+ Security, secrets, authorization, destructive-action safeguards and required CI
37
+ status-check contracts remain binding. Irrelevant CI execution must report explicit
38
+ success/not-applicable rather than leave a required check pending; preserve required
39
+ product/integration coverage until a validated narrower replacement exists.
@@ -59,8 +59,8 @@ Repo conventions follow from this: `Source/DotNET` + `Source/JavaScript` for dua
59
59
 
60
60
  ## Quality gates (framework)
61
61
 
62
- - Build clean (Debug and Release) with **zero warnings, zero errors**.
63
- - Specs pass for affected projects (C# spec executables (VSTest only: `dotnet test <project> --no-build`); TS packages via their test command; Components also `build-storybook`).
62
+ - Select gates by [criticality tier](./criticality-tiers.instructions.md), changed inputs and dependency closure; these product gates are not a blanket local mandate for tooling or prose.
63
+ - Applicable Debug/Release builds have **zero warnings, zero errors**; specs in scope pass (built C# spec executables; VSTest only: `dotnet test <project> --no-build`; TS package tests; Components also `build-storybook`).
64
64
  - For public-facing changes (APIs, attributes, generated output, component props): update the product documentation and verify it.
65
65
  - Match the repo's existing patterns; when a deep architectural question isn't answered by the universal rules or this file, consult the **repo's own docs/CONTRIBUTING** or ask — do not infer framework internals from a single call site.
66
66
 
@@ -5,7 +5,7 @@ applyTo: "**/*"
5
5
 
6
6
  # How to Do Pull Requests
7
7
 
8
- **Before writing any commit message, committing, pushing, or creating/editing a PR, read the `cratis-commits-and-pull-requests` skill.** It holds the description shape, forbidden list, examples, labels, grouping and release-action windows. Commit rules: [git-commits.md](./git-commits.instructions.md).
8
+ **Before writing any commit message, committing, pushing, or creating/editing a PR, read the `cratis-commits-and-pull-requests` skill.** Commit rules: [git-commits.md](./git-commits.instructions.md).
9
9
 
10
10
  ## The description is the release note
11
11
 
@@ -33,5 +33,6 @@ applyTo: "**/*"
33
33
  ## Before you create or edit a PR
34
34
 
35
35
  - Run `node .cratis/ai/hooks/scripts/cratis-check-pr.mjs --body-file <file> --label <intent>`; it applies the exact `policy / verify` release-note rules and the Bash hook runs it on `gh pr create` and `gh pr edit`. If it fails, fix the description, not the code. Before every body edit, run `git diff --stat origin/main...HEAD` and delete bullets the diff no longer supports.
36
- - Run the affected-project gates before marking work ready (build, built specs, lint and type-check; zero warnings), and the repository's required CI checks after an authorized push. `no-release` and documentation-only PRs still satisfy every required check; none is a blanket exemption from red CI.
36
+ - Run the affected-project gates before marking work ready. Scope gates and independent review by [criticality tier](./criticality-tiers.instructions.md) and affected inputs/dependencies; reuse valid unchanged-input results. When specs run, use built spec runners.
37
+ - Run the repository's required CI checks after an authorized push. Of all labels and PR types, none is a blanket exemption from red CI. Irrelevant checks report success/not-applicable, never pending.
37
38
  - The release train is the PR: fold finished branches into the repository's one train (see the skill). Open it once, when verified, as the orchestrator (`cratis-engineering-release-trains`) with `--assignee @me`. Split only for a named major, an urgent security fix authorized in writing, or an accepted outsider issue (patch or minor, own release).
@@ -14,6 +14,10 @@ paths:
14
14
 
15
15
  # Shared review reports
16
16
 
17
+ [Criticality tiers](./criticality-tiers.instructions.md) determine when independent review is
18
+ required; Tier C needs no review or review document. The following governs requested
19
+ or required reviews.
20
+
17
21
  Use this report shape for code, security, performance, and repository-investigation
18
22
  reviews. Domain-specific risk labels refine findings, not the report or verdict
19
23
  vocabulary. Review the change within the declared scope, not unrelated existing debt.
@@ -86,10 +90,9 @@ See `cratis-engineering-review-rounds` for dispatch and writer-pause mechanics.
86
90
 
87
91
  An uncited behavior change on a trust-boundary or wire/protocol surface is a blocker (`published-contracts.md`).
88
92
 
89
- Code Health (`code-health.md`) never earns a round of its own: flag a touched file below
90
- 9.5 with no reported reason only together with the round's other findings. A file below 9.5
91
- with a reason and an uplift entry is closed; a second Code Health round is a finding that
92
- names its cause.
93
+ Code Health (`code-health.md`) applies only within the tier's scope and never earns
94
+ a round of its own. Flag an in-scope file below 9.5 without a reason alongside other
95
+ findings; a reported reason closes it. A second Code Health round is a finding.
93
96
 
94
97
  ## Reviewer independence
95
98
 
@@ -8,6 +8,9 @@ paths:
8
8
 
9
9
  # How to Write Specs
10
10
 
11
+ [Criticality tiers](./criticality-tiers.instructions.md) determine when specs are required.
12
+ The conventions below govern writing specs, not whether every change needs them.
13
+
11
14
  We call automated tests **specs** (specifications), not tests. This is deliberate — specs are executable documentation that describe what the system *does*, written in the language of the domain. A new developer should be able to read the spec folder structure like a table of contents and understand the system's behavior without opening a single source file.
12
15
 
13
16
  This philosophy comes from Specification by Example and BDD (Behavior Driven Development). The goal is human-readable, navigable specifications that double as a living contract.
@@ -10,20 +10,16 @@ paths:
10
10
  Verification answers whether changed behavior works. It does not establish who
11
11
  authored a file or preserve a chain of evidence about how it arrived.
12
12
 
13
- - Run the narrowest relevant build, type check, lint, and specifications while iterating; explain when a wider gate is required before completion or push/PR.
14
- - Run one phase per command with its real exit status. Budget targeted checks around 120 seconds and build/test phases around 300 seconds; explain any longer budget first, and obtain explicit approval before a phase exceeds 600 seconds. Stop on a failure; do not blindly retry or repeat passing tests on unchanged inputs without a flaky-test hypothesis or required matrix.
15
- - **[contract] Never iterate through CI:** never push to see failures or wait on runs; iterate on narrow local checks, reproduce CI failures locally, run Tier 1 once before pushing and integration when the repository's policy requires it. Integration may wait for CI only when the repository allows it, CI demonstrably runs that coverage and it passes before merge; say it was deferred to CI, never call it a local pass. If integration is required but has neither local proof nor enforced CI coverage, treat it as unverified and stop. A stricter repository policy, such as local-only integration, wins. On a shared machine cap parallelism, one heavy phase at once (`cratis-engineering-ci-gates`).
16
- - Separate status/fetch from builds, Debug from Release, each test project, and frontend lint/compile/test/build. Do not combine these into an opaque command with a large outer timeout. Expose progress and cancellation; report the precise failed or timed-out phase and do not continue dependent phases after failure.
17
- - Never use `build/test | grep | sort/head/tail` as gate evidence. Capture the producer's exit status before summarising output; `pipefail` alone is insufficient with early-closing consumers such as `head`. Printed zero-error counts are not proof of success. Preserve needed full diagnostics in task-scoped `.ai-work/` logs rather than hiding them in `/tmp`.
18
- - Fast feedback is a product requirement: a spec takes milliseconds, the suite seconds; specs share setup and run in parallel; analyzers must not halt builds. CI builds the spec path without analyzers and enforces them, warnings as errors, in a parallel required job; the pre-push gate runs them. A slowdown is a defect.
19
- - Add a focused specification for every behavior or rejection rule you change.
13
+ - Select specs, review and local checks by [criticality tier](./criticality-tiers.instructions.md).
14
+ - Run one bounded phase per command with its real exit status; stop on failure. Read **cratis-engineering-ci-gates** for deadlines, phase selection and diagnostic handling.
15
+ - **[contract] Never iterate through CI:** never push to see failures; reproduce relevant CI failures locally. Run applicable local gates before pushing; required product/integration CI still passes before merge. Integration may wait for CI only when repository policy permits and CI enforces it; call it deferred, never a local pass. Required coverage without local proof or enforced CI is unverified. On a shared machine cap parallelism, one heavy phase at once (`cratis-engineering-ci-gates`).
16
+ - Never use filtered build/test output or printed zero-error counts as gate evidence; preserve the producer's exit status and needed diagnostics in `.ai-work/`.
17
+ - Keep specs fast; follow [fast-feedback.md](./fast-feedback.instructions.md).
20
18
  - Keep each check deterministic and runnable locally and in CI.
21
- - Never replace a real behavior check with a checksum, inventory, generated
22
- receipt, or provenance record.
23
- - Documentary evidence — a receipt, ledger, attestation, hash inventory,
24
- snapshot, escrow copy, or ad-hoc `verify-*` script — is not verification and
25
- is not produced unless a repository workflow (such as a governed release) or
26
- the user asks for it. The check's own output is the evidence.
19
+ - Check output is evidence; checksums, inventories, receipts, ledgers, attestations,
20
+ snapshots, escrow copies and provenance records cannot replace behavior checks.
21
+ Do not produce these or ad-hoc `verify-*` scripts unless a repository workflow or
22
+ the user asks.
27
23
  - Report the conclusion and any real uncertainty in a line or two, not the
28
24
  audit trail. Show the output when asked, when a claim is contested, or when
29
25
  the check failed. Report failures and skipped checks honestly.
@@ -14,29 +14,27 @@ paths:
14
14
 
15
15
  # Code Health floor
16
16
 
17
- Applies when CodeScene tools (`code_health_review`, `code_health_score`,
18
- `pre_commit_code_health_safeguard`, `analyze_change_set`) are available. Without them or
19
- an account, say so in the report and continue; never block. MCP setup, approval-gated
20
- tools and tool-output handling are in [codescene.md](./codescene.md).
17
+ Apply [criticality tiers](./criticality-tiers.md) first: score Tier A code and
18
+ maintained Tier B code when CodeScene is available. Tier C requires no scoring or
19
+ uplift. Without tools or an account, report that and continue; never block.
20
+ MCP setup, approval-gated tools and tool-output handling: [codescene.md](./codescene.md).
21
21
 
22
22
  ## The floor
23
23
 
24
- - Every file a change creates or modifies ends at Code Health **9.5 or higher**; new files aim for 10. A touched file never declines.
25
- - A touched file that starts below 9.5 is raised to 9.5 in the same change by behavior-preserving refactoring with specs behind it (`guiding-refactoring-with-code-health` where the profile provides it).
26
- - If that is too large for the task (a red or yellow legacy file), raise it as far as is safe, report before and after, and add the file to the repository's Code Health uplift issue ("Code Health: raise all files to 9.5"; create it if none exists).
27
- - Urgent security and production fixes may ship below 9.5, but report the gap and file the uplift.
24
+ - In-scope code ends at Code Health **9.5 or higher**; new code aims for 10. A touched file never declines.
25
+ - Uplift safely with behavior-preserving refactoring and specs. A narrow fix does not require unrelated legacy uplift. If 9.5 exceeds safe scope, report the gap and suggest a follow-up; do not widen the change.
28
26
  - Never refactor generated code. A "could not determine" Code Health score is not a failure. Other Cratis rules win over a finding.
29
27
  - CodeScene has no floor setting, so the check is ours.
30
28
 
31
29
  ## Checking
32
30
 
33
- - Run `code_health_review` on each changed file while shaping it, then `code_health_score` on each changed file before delivery, then `pre_commit_code_health_safeguard` (or `analyze_change_set` against the base branch).
31
+ - For in-scope code, run `code_health_review` while shaping it, `code_health_score` before delivery, then `pre_commit_code_health_safeguard` (or `analyze_change_set` against the base branch).
34
32
  - The delivery report has a table: file, score before, score after; name each exception with its reason.
35
33
 
36
34
  ## No fix loops
37
35
 
38
- - **Once, before the gate.** Handle Code Health once per touched file: review while shaping the code (design for the score, do not write first and fix later), refactor, then one `code_health_score`. The gate and review then run once on the final shape.
36
+ - **Once, before the gate.** Handle Code Health once per in-scope file: review while shaping the code (design for the score, do not write first and fix later), refactor, then one `code_health_score`. The gate and review then run once on the final shape.
39
37
  - **Never a cycle.** No gate, score, refactor, gate loops. A score check never triggers an extra build or test run on its own; batch score fixes with the other fixes.
40
- - **One refactor pass per file per change.** If it does not reach 9.5, report the before and after and the reason, add the file to the uplift issue, and stop.
41
- - **A reported reason closes the item.** Reviewers flag only a touched file below 9.5 with no reason, together with the round's other findings, never as a review round of its own.
38
+ - **One refactor pass per file per change.** If it does not reach 9.5, report before/after and the reason, suggest the uplift follow-up, and stop.
39
+ - **A reported reason closes the item.** Reviewers flag only an in-scope file below 9.5 with no reason, together with the round's other findings, never as a review round of its own.
42
40
  - **A second Code Health round is itself a finding.** Name the cause (wrong approach, file too large for the task, tool problem) instead of iterating.
@@ -15,10 +15,10 @@ not opted in.
15
15
 
16
16
  ## Thresholds and checking
17
17
 
18
- The floor (touched files end at Code Health 9.5 or higher), the checking steps and the
19
- no-fix-loops process are the universal rule [code-health.md](./code-health.md). The
20
- `safeguarding-ai-generated-code` instruction to refactor when a review reports problems
21
- applies to every touched file, not only to problems the change introduced.
18
+ Scope follows [criticality tiers](./criticality-tiers.md); the floor, checking steps
19
+ and no-fix-loops process are in [code-health.md](./code-health.md). Tier C requires
20
+ no Code Health scoring or uplift; a narrow fix does not require unrelated legacy uplift.
21
+ Vendored refactoring instructions do not expand that scope.
22
22
 
23
23
  CodeScene categories, for reference: **10 optimal**, **9–9.9 green**, **4–8.9 yellow**,
24
24
  **1–3.9 red**. Project target: **Hotspot Code Health at least 9**, with no downward trend.
@@ -0,0 +1,38 @@
1
+ ---
2
+ applyTo: "**/*"
3
+ paths:
4
+ - "**/*"
5
+ ---
6
+
7
+ <!-- Copyright (c) Cratis. All rights reserved. -->
8
+ <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
9
+
10
+ # Criticality tiers
11
+
12
+ Judgment-shaped: classify by failure consequences, not repository name.
13
+
14
+ - **Tier A — Critical:** product runtime, auth/credentials, data integrity/migrations,
15
+ production deployment or automation able to disrupt all CI. Require focused
16
+ behavior/rejection specs, independent review and security/product CI. Full local gates
17
+ run only for changed inputs/dependency closure; reuse valid unchanged-input results.
18
+ - **Tier B — Operational but bounded:** internal tooling with limited, recoverable
19
+ impact (e.g. ordinary runner management). Require bounded smoke/regression checks
20
+ for meaningful behavior; review elevated permissions, broad impact or the escalation
21
+ below. No unrelated product gate; Code Health only for maintained, non-disposable code.
22
+ - **Tier C — Disposable or advisory:** noncritical dashboards, reports, local helpers,
23
+ demos/samples, experiments, prose and corpus style checks. No mandatory new specs,
24
+ review/artifacts, Code Health scoring/uplift or full local gate. Smoke checks are
25
+ optional absent specific failure risk; cheap checks may remain, cosmetics are advisory.
26
+
27
+ A change in any tier that touches credentials or secrets, authentication or authorization,
28
+ workflow permissions or untrusted-PR triggers (`pull_request_target`, `workflow_run`,
29
+ forked-PR inputs), data exposure, a trust boundary, or a destructive or irreversible action
30
+ is Tier A for that part and needs independent review, whatever the tool's tier.
31
+ Critical subcomponents inherit Tier A; unknown critical dependencies fail closed to
32
+ the higher tier. Narrow fixes need no unrelated legacy uplift. No artifacts needed
33
+ to claim a tier.
34
+
35
+ Security, secrets, authorization, destructive-action safeguards and required CI
36
+ status-check contracts remain binding. Irrelevant CI execution must report explicit
37
+ success/not-applicable rather than leave a required check pending; preserve required
38
+ product/integration coverage until a validated narrower replacement exists.
@@ -58,8 +58,8 @@ Repo conventions follow from this: `Source/DotNET` + `Source/JavaScript` for dua
58
58
 
59
59
  ## Quality gates (framework)
60
60
 
61
- - Build clean (Debug and Release) with **zero warnings, zero errors**.
62
- - Specs pass for affected projects (C# spec executables (VSTest only: `dotnet test <project> --no-build`); TS packages via their test command; Components also `build-storybook`).
61
+ - Select gates by [criticality tier](./criticality-tiers.md), changed inputs and dependency closure; these product gates are not a blanket local mandate for tooling or prose.
62
+ - Applicable Debug/Release builds have **zero warnings, zero errors**; specs in scope pass (built C# spec executables; VSTest only: `dotnet test <project> --no-build`; TS package tests; Components also `build-storybook`).
63
63
  - For public-facing changes (APIs, attributes, generated output, component props): update the product documentation and verify it.
64
64
  - Match the repo's existing patterns; when a deep architectural question isn't answered by the universal rules or this file, consult the **repo's own docs/CONTRIBUTING** or ask — do not infer framework internals from a single call site.
65
65
 
@@ -90,11 +90,10 @@ the plugin marketplaces) are in [ai-distribution.md](./ai-distribution.md):
90
90
 
91
91
  ## Verification Discipline
92
92
 
93
- A claim is only as good as the signal behind it — a build result, a test run, a lint pass, observed app behavior — not the model's own confidence. Internal reasoning *plans* the work; external signals *confirm* it.
93
+ Verify claims with build, spec, lint or observed-behavior signals, not confidence.
94
94
 
95
95
  - **Confirm "done"/"fixed"/"correct" against a fresh signal — never self-assessment.** Run the relevant gate and observe it pass *this time*.
96
- - **Check at the right frequency.** Run affected-project checks while iterating; a prompt ending is not task completion. Before claiming a task complete or pushing/opening a PR, run the full CI-equivalent gates required for that repository (including its Tier 1/2 policy where applicable). A change-selected hook gate is not a substitute for the repository's full CI matrix. After a fix, re-run the gate that failed. Don't argue yourself to green.
97
- - **Gate configuration:** shipped defaults `.cratis/ai/hooks/scripts/quality-gates.json`; project overrides `.cratis/ai/quality-gates.project.json` shallow-merge by gate id (command without requires drops inherited packageScripts). `CRATIS_HOOKS_GATES` replaces defaults; project overrides still apply.
96
+ - **Scope checks by [criticality tier](./criticality-tiers.md);** follow [verification-discipline.md](./verification-discipline.md) for execution and evidence.
98
97
  - **A green build is not behavioral correctness.** Compilation proves it builds, not that the slice does the right thing — that's what specs and exercising the UI are for.
99
98
  - **Incidents:** analyse the cause first; choose the narrowest fix for it; state its cost and when it can be removed (**cratis-engineering-post-mortem**).
100
99
  - **Report the conclusion and what you didn't verify, in a line or two.** Show output when asked, contested or failed — see [verification-discipline.md](./verification-discipline.md).
@@ -118,10 +117,8 @@ A claim is only as good as the signal behind it — a build result, a test run,
118
117
 
119
118
  ## Definition of Done
120
119
 
121
- - The affected solution/project builds with zero warnings and zero errors.
122
- - Relevant specs for every affected project pass.
123
- - For public-facing changes (clients, SDKs, public APIs, developer-facing behavior), documentation is added or updated and its verification passes.
124
- - When CodeScene tools are available, touched files end at Code Health >= 9.5 and never decline; handle it once, before the gate, and report before/after (`code-health.md`).
120
+ - Within the [tier's scope](./criticality-tiers.md), builds have zero warnings/errors, specs pass and [Code Health](./code-health.md) shortfalls are reported.
121
+ - For public-facing behavior, update documentation and verify it.
125
122
 
126
123
  ## Where to Look
127
124
 
@@ -141,7 +138,7 @@ A claim is only as good as the signal behind it — a build result, a test run,
141
138
  | Build and spec-run speed: parallel-safe specs, no per-spec startup, cheap analyzers | `fast-feedback.md` |
142
139
  | Spec patterns — the four `*Scenario` helpers (application only) | `specs.scenarios.csharp.md` |
143
140
  | Strongly-typed values (`ConceptAs<T>`, `EventSourceId<T>`); shared term definitions (event, projection, reducer, reactor, observer, DCB, …) | `concepts.md`; `glossary.md` |
144
- | Files an AI change touches (Code Health with CodeScene); behavior at a trust boundary or wire/protocol surface (cite and conform to the published contract and vectors) | `code-health.md`; `published-contracts.md` |
141
+ | Specs, review, Code Health and local gate scope; trust boundaries and wire/protocol contracts | `criticality-tiers.md`; `code-health.md`; `published-contracts.md` |
145
142
  | OpenTelemetry traces, metrics and telemetry code | `observability.md` |
146
143
  | Diagnosing a misbehaving slice | read model stale or startup crash: **cratis-chronicle-projection** (*Startup-crash traps*); reactor paused or quarantined: **cratis-chronicle-reactor** (*Failure behavior*); proxy missing: **cratis-arc-command** (*Generate the TypeScript proxy*) |
147
144
  | Inspecting or operating a **running** Chronicle store (failed partitions, replays, browsing events) with the `cratis` CLI | the **cratis-chronicle-cli-operations** and **cratis-cli-terminal-workbench** skills |
@@ -6,6 +6,6 @@ profile: cratis/engineering
6
6
 
7
7
  CI/CD is shared and finite: it confirms, it is not a feedback loop.
8
8
 
9
- - Build, run specs and lint locally; never push to find out if it works, and reproduce a CI failure locally before pushing again.
10
- - Push and open a PR only when ready: local gates passed on the exact head. No draft, placeholder or WIP PRs.
9
+ - Use [criticality tiers](./criticality-tiers.md) for local gates; reuse valid unchanged-input results. Never push as a feedback loop; reproduce relevant CI failures locally.
10
+ - Push and open a PR only when applicable checks pass for its inputs. Required CI remains binding. No draft, placeholder or WIP PRs.
11
11
  - One PR per repository. As orchestrator, brief sub-agents to commit verified work to the shared branch and never push or open a PR; you verify the combination and open the one PR ([pull-requests.md](./pull-requests.md) lists the split exceptions).
@@ -4,7 +4,7 @@ applyTo: "**/*"
4
4
 
5
5
  # How to Do Pull Requests
6
6
 
7
- **Before writing any commit message, committing, pushing, or creating/editing a PR, read the `cratis-commits-and-pull-requests` skill.** It holds the description shape, forbidden list, examples, labels, grouping and release-action windows. Commit rules: [git-commits.md](./git-commits.md).
7
+ **Before writing any commit message, committing, pushing, or creating/editing a PR, read the `cratis-commits-and-pull-requests` skill.** Commit rules: [git-commits.md](./git-commits.md).
8
8
 
9
9
  ## The description is the release note
10
10
 
@@ -32,5 +32,6 @@ applyTo: "**/*"
32
32
  ## Before you create or edit a PR
33
33
 
34
34
  - Run `node .cratis/ai/hooks/scripts/cratis-check-pr.mjs --body-file <file> --label <intent>`; it applies the exact `policy / verify` release-note rules and the Bash hook runs it on `gh pr create` and `gh pr edit`. If it fails, fix the description, not the code. Before every body edit, run `git diff --stat origin/main...HEAD` and delete bullets the diff no longer supports.
35
- - Run the affected-project gates before marking work ready (build, built specs, lint and type-check; zero warnings), and the repository's required CI checks after an authorized push. `no-release` and documentation-only PRs still satisfy every required check; none is a blanket exemption from red CI.
35
+ - Run the affected-project gates before marking work ready. Scope gates and independent review by [criticality tier](./criticality-tiers.md) and affected inputs/dependencies; reuse valid unchanged-input results. When specs run, use built spec runners.
36
+ - Run the repository's required CI checks after an authorized push. Of all labels and PR types, none is a blanket exemption from red CI. Irrelevant checks report success/not-applicable, never pending.
36
37
  - The release train is the PR: fold finished branches into the repository's one train (see the skill). Open it once, when verified, as the orchestrator (`cratis-engineering-release-trains`) with `--assignee @me`. Split only for a named major, an urgent security fix authorized in writing, or an accepted outsider issue (patch or minor, own release).
@@ -13,6 +13,10 @@ paths:
13
13
 
14
14
  # Shared review reports
15
15
 
16
+ [Criticality tiers](./criticality-tiers.md) determine when independent review is
17
+ required; Tier C needs no review or review document. The following governs requested
18
+ or required reviews.
19
+
16
20
  Use this report shape for code, security, performance, and repository-investigation
17
21
  reviews. Domain-specific risk labels refine findings, not the report or verdict
18
22
  vocabulary. Review the change within the declared scope, not unrelated existing debt.
@@ -85,10 +89,9 @@ See `cratis-engineering-review-rounds` for dispatch and writer-pause mechanics.
85
89
 
86
90
  An uncited behavior change on a trust-boundary or wire/protocol surface is a blocker (`published-contracts.md`).
87
91
 
88
- Code Health (`code-health.md`) never earns a round of its own: flag a touched file below
89
- 9.5 with no reported reason only together with the round's other findings. A file below 9.5
90
- with a reason and an uplift entry is closed; a second Code Health round is a finding that
91
- names its cause.
92
+ Code Health (`code-health.md`) applies only within the tier's scope and never earns
93
+ a round of its own. Flag an in-scope file below 9.5 without a reason alongside other
94
+ findings; a reported reason closes it. A second Code Health round is a finding.
92
95
 
93
96
  ## Reviewer independence
94
97
 
@@ -7,6 +7,9 @@ paths:
7
7
 
8
8
  # How to Write Specs
9
9
 
10
+ [Criticality tiers](./criticality-tiers.md) determine when specs are required.
11
+ The conventions below govern writing specs, not whether every change needs them.
12
+
10
13
  We call automated tests **specs** (specifications), not tests. This is deliberate — specs are executable documentation that describe what the system *does*, written in the language of the domain. A new developer should be able to read the spec folder structure like a table of contents and understand the system's behavior without opening a single source file.
11
14
 
12
15
  This philosophy comes from Specification by Example and BDD (Behavior Driven Development). The goal is human-readable, navigable specifications that double as a living contract.
@@ -9,20 +9,16 @@ paths:
9
9
  Verification answers whether changed behavior works. It does not establish who
10
10
  authored a file or preserve a chain of evidence about how it arrived.
11
11
 
12
- - Run the narrowest relevant build, type check, lint, and specifications while iterating; explain when a wider gate is required before completion or push/PR.
13
- - Run one phase per command with its real exit status. Budget targeted checks around 120 seconds and build/test phases around 300 seconds; explain any longer budget first, and obtain explicit approval before a phase exceeds 600 seconds. Stop on a failure; do not blindly retry or repeat passing tests on unchanged inputs without a flaky-test hypothesis or required matrix.
14
- - **[contract] Never iterate through CI:** never push to see failures or wait on runs; iterate on narrow local checks, reproduce CI failures locally, run Tier 1 once before pushing and integration when the repository's policy requires it. Integration may wait for CI only when the repository allows it, CI demonstrably runs that coverage and it passes before merge; say it was deferred to CI, never call it a local pass. If integration is required but has neither local proof nor enforced CI coverage, treat it as unverified and stop. A stricter repository policy, such as local-only integration, wins. On a shared machine cap parallelism, one heavy phase at once (`cratis-engineering-ci-gates`).
15
- - Separate status/fetch from builds, Debug from Release, each test project, and frontend lint/compile/test/build. Do not combine these into an opaque command with a large outer timeout. Expose progress and cancellation; report the precise failed or timed-out phase and do not continue dependent phases after failure.
16
- - Never use `build/test | grep | sort/head/tail` as gate evidence. Capture the producer's exit status before summarising output; `pipefail` alone is insufficient with early-closing consumers such as `head`. Printed zero-error counts are not proof of success. Preserve needed full diagnostics in task-scoped `.ai-work/` logs rather than hiding them in `/tmp`.
17
- - Fast feedback is a product requirement: a spec takes milliseconds, the suite seconds; specs share setup and run in parallel; analyzers must not halt builds. CI builds the spec path without analyzers and enforces them, warnings as errors, in a parallel required job; the pre-push gate runs them. A slowdown is a defect.
18
- - Add a focused specification for every behavior or rejection rule you change.
12
+ - Select specs, review and local checks by [criticality tier](./criticality-tiers.md).
13
+ - Run one bounded phase per command with its real exit status; stop on failure. Read **cratis-engineering-ci-gates** for deadlines, phase selection and diagnostic handling.
14
+ - **[contract] Never iterate through CI:** never push to see failures; reproduce relevant CI failures locally. Run applicable local gates before pushing; required product/integration CI still passes before merge. Integration may wait for CI only when repository policy permits and CI enforces it; call it deferred, never a local pass. Required coverage without local proof or enforced CI is unverified. On a shared machine cap parallelism, one heavy phase at once (`cratis-engineering-ci-gates`).
15
+ - Never use filtered build/test output or printed zero-error counts as gate evidence; preserve the producer's exit status and needed diagnostics in `.ai-work/`.
16
+ - Keep specs fast; follow [fast-feedback.md](./fast-feedback.md).
19
17
  - Keep each check deterministic and runnable locally and in CI.
20
- - Never replace a real behavior check with a checksum, inventory, generated
21
- receipt, or provenance record.
22
- - Documentary evidence — a receipt, ledger, attestation, hash inventory,
23
- snapshot, escrow copy, or ad-hoc `verify-*` script — is not verification and
24
- is not produced unless a repository workflow (such as a governed release) or
25
- the user asks for it. The check's own output is the evidence.
18
+ - Check output is evidence; checksums, inventories, receipts, ledgers, attestations,
19
+ snapshots, escrow copies and provenance records cannot replace behavior checks.
20
+ Do not produce these or ad-hoc `verify-*` scripts unless a repository workflow or
21
+ the user asks.
26
22
  - Report the conclusion and any real uncertainty in a line or two, not the
27
23
  audit trail. Show the output when asked, when a claim is contested, or when
28
24
  the check failed. Report failures and skipped checks honestly.
@@ -11,14 +11,19 @@ compatibility: Requires git and the GitHub CLI (gh).
11
11
  # Run the gate once, then watch the exact run
12
12
 
13
13
  Operate checks; do not redesign workflows here. Read
14
- [verification-discipline.md](../../rules/verification-discipline.md) for phase
15
- budgets and exit-status handling, and
14
+ [verification-discipline.md](../../rules/verification-discipline.md) for verification
15
+ contracts, and
16
16
  [pull-requests.md](../cratis-commits-and-pull-requests/references/pr-labels-and-release.md#quality-gates) for required checks.
17
17
  Read [capability-is-not-authority.md](../../rules/capability-is-not-authority.md)
18
18
  before an external effect. A request to verify does not authorize a push.
19
19
 
20
20
  ## Derive the local gate
21
21
 
22
+ Hook gate configuration: shipped defaults `.cratis/ai/hooks/scripts/quality-gates.json`;
23
+ project overrides `.cratis/ai/quality-gates.project.json` shallow-merge by gate id
24
+ (command without requires drops inherited packageScripts). `CRATIS_HOOKS_GATES`
25
+ replaces defaults; project overrides still apply.
26
+
22
27
  1. Read `.github/workflows/` and the repository's tier policy. Follow reusable
23
28
  workflows and invoked scripts. Extract commands, solution and test selection,
24
29
  configuration, warning settings, analyzers, lint and formatting checks.
@@ -72,8 +77,26 @@ When several deliveries form one candidate, the assembler runs the final gate
72
77
  on the assembled state; deliveries bring targeted results. A changed state after
73
78
  a failure needs the required gate again.
74
79
 
75
- Keep build, lint and test phases separate, each with a deadline. Stop on failure;
76
- do not run dependent phases or hide a producer's exit status behind a filter.
80
+ ## Phase execution
81
+
82
+ - Budget targeted checks around 120 seconds and build/test phases around 300 seconds;
83
+ explain any longer budget first, and obtain explicit approval before a phase exceeds
84
+ 600 seconds. Do not blindly retry or repeat passing tests on unchanged inputs without
85
+ a flaky-test hypothesis or required matrix.
86
+ - Separate status/fetch from builds, Debug from Release, each test project, and frontend
87
+ lint/compile/test/build. Do not combine these into an opaque command with a large
88
+ outer timeout. Expose progress and cancellation; report the precise failed or
89
+ timed-out phase and do not continue dependent phases after failure.
90
+ - Capture the producer's exit status before summarizing output; `pipefail` alone is
91
+ insufficient with early-closing consumers such as `head`. Never use
92
+ `build/test | grep | sort/head/tail` as gate evidence. Printed zero-error counts are
93
+ not proof of success. Preserve needed full diagnostics in task-scoped `.ai-work/`
94
+ logs rather than hiding them in `/tmp`.
95
+ - Fast feedback is a product requirement: a spec takes milliseconds, the suite seconds;
96
+ specs share setup and run in parallel; analyzers must not halt builds. CI builds the
97
+ spec path without analyzers and enforces them, warnings as errors, in a parallel
98
+ required job; the pre-push gate runs them. A slowdown is a defect.
99
+
77
100
  Report the exact command and result. Put verification and deferred coverage in
78
101
  reviewer comments, not the release-note description.
79
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.190.3",
3
+ "version": "7.191.1",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [