@cratis/pi 7.144.1 → 7.146.0

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.
@@ -29,7 +29,7 @@ This is a read-only review role: propose corrections and refactors in the report
29
29
  You are the **Code Reviewer** for Cratis-based projects.
30
30
  Your responsibility is to review all changed files and ensure they meet project standards before merge.
31
31
 
32
- Select only diff-relevant, profile-applicable canonical rules in `.cratis/ai/rules/` (and `general.md`): `vertical-slices.md`, `csharp.md`, `code-quality.md` (+ `.csharp`/`.typescript`), `specs.md` (+ `.csharp`/`.typescript`), `frontend-testing.md`, `typescript.md`, `react.md`, `components.md`, `dialogs.md`, `frontend-quality.md`, `concepts.md`, `mongodb.md` (when MongoDB is used), `efcore.md`/`efcore.specs.md`.
32
+ Select only diff-relevant, profile-applicable canonical rules in `.cratis/ai/rules/` (and `general.md`): `vertical-slices.md`, `csharp.md`, `code-quality.md` (+ `.csharp`/`.typescript`), `code-health.md` (flag a touched file below 9.5 with no reported reason only together with the round's other findings), `specs.md` (+ `.csharp`/`.typescript`), `frontend-testing.md`, `typescript.md`, `react.md`, `components.md`, `dialogs.md`, `frontend-quality.md`, `concepts.md`, `mongodb.md` (when MongoDB is used), `efcore.md`/`efcore.specs.md`.
33
33
 
34
34
  ---
35
35
 
@@ -148,7 +148,7 @@ For an implemented application slice, require the applicable changed-lane gates
148
148
 
149
149
  For large features with many slices, use these techniques to keep context manageable:
150
150
 
151
- - **`/compact`** after completing each phase to free context space. Add focus notes: `/compact focus on remaining slices and unresolved issues`.
151
+ - Keep a state note and hand off between phases: follow `cratis-session-handoff`.
152
152
  - **`/fork`** before exploring an alternative design approach, so the original plan is preserved.
153
153
  - Use bounded source inspection for routine research. Request an independent researcher from the parent only when the scope justifies it and the host supports it.
154
154
 
@@ -0,0 +1,43 @@
1
+ ---
2
+ applyTo: "**/*.cs,**/*.ts,**/*.tsx,**/*.go,**/*.kt,**/*.kts,**/*.java,**/*.ex,**/*.exs"
3
+ paths:
4
+ - "**/*.cs"
5
+ - "**/*.ts"
6
+ - "**/*.tsx"
7
+ - "**/*.go"
8
+ - "**/*.kt"
9
+ - "**/*.kts"
10
+ - "**/*.java"
11
+ - "**/*.ex"
12
+ - "**/*.exs"
13
+ ---
14
+ <!-- cratis-ai: generated Copilot instructions. Do not edit; rules/ is the source. -->
15
+
16
+ # Code Health floor
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).
22
+
23
+ ## The floor
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.
29
+ - Never refactor generated code. A "could not determine" Code Health score is not a failure. Other Cratis rules win over a finding.
30
+ - CodeScene has no floor setting, so the check is ours.
31
+
32
+ ## Checking
33
+
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).
35
+ - The delivery report has a table: file, score before, score after; name each exception with its reason.
36
+
37
+ ## No fix loops
38
+
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.
40
+ - **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.
43
+ - **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.
@@ -88,7 +88,7 @@ profile includes neither Screenplay nor Stage.
88
88
  | Profile ID | Description | Automatically Includes |
89
89
  |---|---|---|
90
90
  | `cratis/engineering` | Engineering conventions and workflows | `cratis/engineering/core`, `cratis/engineering/csharp`, `cratis/engineering/elixir`, `cratis/engineering/go`, `cratis/engineering/kotlin`, `cratis/engineering/react`, `cratis/engineering/typescript` |
91
- | `cratis/engineering/core` | Shared engineering method skills: `cratis-ci-pipeline-performance`, `cratis-documentation-writing`, `cratis-engineering-ci-gates`, `cratis-engineering-consolidation-guard`, `cratis-engineering-decision-record`, `cratis-engineering-docs-authoring`, `cratis-engineering-effect-boundaries`, `cratis-engineering-issue-hygiene`, `cratis-engineering-issue-design-note`, `cratis-engineering-local-cross-repo-verification`, `cratis-engineering-regression-cluster`, `cratis-engineering-release-trains`, `cratis-engineering-review-rounds`, `cratis-release-notes`, `cratis-technical-examples` | (no child profiles) |
91
+ | `cratis/engineering/core` | Shared engineering method skills: `cratis-ci-pipeline-performance`, `cratis-documentation-writing`, `cratis-engineering-ci-gates`, `cratis-engineering-consolidation-guard`, `cratis-engineering-decision-record`, `cratis-engineering-docs-authoring`, `cratis-engineering-effect-boundaries`, `cratis-engineering-issue-hygiene`, `cratis-engineering-issue-design-note`, `cratis-engineering-local-cross-repo-verification`, `cratis-engineering-regression-cluster`, `cratis-engineering-release-trains`, `cratis-engineering-review-rounds`, `cratis-release-notes`, `cratis-session-handoff`, `cratis-technical-examples` | (no child profiles) |
92
92
  | `cratis/engineering/csharp` | C# engineering conventions, .NET engineering skills, and framework Orleans jobs (`cratis-orleans-jobs`, alongside `orleans.md`) | `cratis/engineering/core`, `cratis/engineering/dotnet` |
93
93
  | `cratis/engineering/dotnet` | Upstream .NET engineering workflows | `cratis/engineering/dotnet/performance`, `cratis/engineering/dotnet/diagnostics`, `cratis/engineering/dotnet/msbuild`, `cratis/engineering/dotnet/orleans`, `cratis/engineering/dotnet/testing`, `cratis/engineering/dotnet/refactoring` |
94
94
  | `cratis/engineering/dotnet/performance` | Microbenchmarking, performance patterns, SIMD, and profiling | (no child profiles) |
@@ -234,7 +234,8 @@ language policy always follows the consuming repository's `go.mod` minimum.
234
234
  Select `cratis/codescene` explicitly to load the four upstream CodeScene skills:
235
235
  `safeguarding-ai-generated-code`, `guiding-refactoring-with-code-health`,
236
236
  `prioritizing-technical-debt` and `risk-based-testing-with-code-health`.
237
- The [CodeScene policy](../../../rules/codescene.md) overrides those skills where they differ.
237
+ The [CodeScene policy](../../../rules/codescene.md) overrides those skills where they differ. The Code Health
238
+ floor itself is the universal rule [code-health.md](./code-health.instructions.md); the profile supplies the skills and server.
238
239
  No other profile, including `cratis` and `cratis/full`, composes it.
239
240
 
240
241
  The profile selects the `codescene` stdio server (`cs-mcp`, no arguments) from
@@ -81,6 +81,11 @@ and exhaustion never imply approval. Verify cancellation before replacement; esc
81
81
  unresolved disputes instead of looping. Suggestions alone do not justify another round.
82
82
  See `cratis-engineering-review-rounds` for dispatch and writer-pause mechanics.
83
83
 
84
+ Code Health (`code-health.md`) never earns a round of its own: flag a touched file below
85
+ 9.5 with no reported reason only together with the round's other findings. A file below 9.5
86
+ with a reason and an uplift entry is closed; a second Code Health round is a finding that
87
+ names its cause.
88
+
84
89
  ## Reviewer independence
85
90
 
86
91
  - **[contract]** Run a reviewer on a different provider family than the author's model
@@ -26,7 +26,7 @@ This is a read-only review role: propose corrections and refactors in the report
26
26
  You are the **Code Reviewer** for Cratis-based projects.
27
27
  Your responsibility is to review all changed files and ensure they meet project standards before merge.
28
28
 
29
- Select only diff-relevant, profile-applicable canonical rules in `.cratis/ai/rules/` (and `general.md`): `vertical-slices.md`, `csharp.md`, `code-quality.md` (+ `.csharp`/`.typescript`), `specs.md` (+ `.csharp`/`.typescript`), `frontend-testing.md`, `typescript.md`, `react.md`, `components.md`, `dialogs.md`, `frontend-quality.md`, `concepts.md`, `mongodb.md` (when MongoDB is used), `efcore.md`/`efcore.specs.md`.
29
+ Select only diff-relevant, profile-applicable canonical rules in `.cratis/ai/rules/` (and `general.md`): `vertical-slices.md`, `csharp.md`, `code-quality.md` (+ `.csharp`/`.typescript`), `code-health.md` (flag a touched file below 9.5 with no reported reason only together with the round's other findings), `specs.md` (+ `.csharp`/`.typescript`), `frontend-testing.md`, `typescript.md`, `react.md`, `components.md`, `dialogs.md`, `frontend-quality.md`, `concepts.md`, `mongodb.md` (when MongoDB is used), `efcore.md`/`efcore.specs.md`.
30
30
 
31
31
  ---
32
32
 
@@ -144,7 +144,7 @@ For an implemented application slice, require the applicable changed-lane gates
144
144
 
145
145
  For large features with many slices, use these techniques to keep context manageable:
146
146
 
147
- - **`/compact`** after completing each phase to free context space. Add focus notes: `/compact focus on remaining slices and unresolved issues`.
147
+ - Keep a state note and hand off between phases: follow `cratis-session-handoff`.
148
148
  - **`/fork`** before exploring an alternative design approach, so the original plan is preserved.
149
149
  - Use bounded source inspection for routine research. Request an independent researcher from the parent only when the scope justifies it and the host supports it.
150
150
 
@@ -0,0 +1,42 @@
1
+ ---
2
+ applyTo: "**/*.cs,**/*.ts,**/*.tsx,**/*.go,**/*.kt,**/*.kts,**/*.java,**/*.ex,**/*.exs"
3
+ paths:
4
+ - "**/*.cs"
5
+ - "**/*.ts"
6
+ - "**/*.tsx"
7
+ - "**/*.go"
8
+ - "**/*.kt"
9
+ - "**/*.kts"
10
+ - "**/*.java"
11
+ - "**/*.ex"
12
+ - "**/*.exs"
13
+ ---
14
+
15
+ # Code Health floor
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).
21
+
22
+ ## The floor
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.
28
+ - Never refactor generated code. A "could not determine" Code Health score is not a failure. Other Cratis rules win over a finding.
29
+ - CodeScene has no floor setting, so the check is ours.
30
+
31
+ ## Checking
32
+
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).
34
+ - The delivery report has a table: file, score before, score after; name each exception with its reason.
35
+
36
+ ## No fix loops
37
+
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.
39
+ - **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.
42
+ - **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,37 +15,33 @@ CodeScene needs an account and OAuth `login`. Without an account or available
15
15
  CodeScene tools, skip these steps and say so; never block contributors who have
16
16
  not opted in.
17
17
 
18
- ## Judge the change, not the file
18
+ ## Thresholds and checking
19
19
 
20
- The gate is **no Code Health decline in changed files and no new code smells in
21
- touched functions**. Pre-existing findings are not a reason to refactor. The
22
- `safeguarding-ai-generated-code` instruction to refactor when a review reports
23
- problems means problems introduced by the change, not existing debt.
20
+ The floor (touched files end at Code Health 9.5 or higher), the checking steps and the
21
+ no-fix-loops process are the universal rule [code-health.md](./code-health.md). The
22
+ `safeguarding-ai-generated-code` instruction to refactor when a review reports problems
23
+ applies to every touched file, not only to problems the change introduced.
24
24
 
25
- ## Thresholds
26
-
27
- - New files: at least **9.0**, aiming for **10**.
28
- - Changed files: **no decline**.
29
- - Uplift red (below 4) or yellow (4–8.9) files only through a dedicated,
30
- issue-tracked task with tests behind it, using
31
- `guiding-refactoring-with-code-health`.
32
- - Project target: **Hotspot Code Health at least 9**, with no downward trend.
33
- - CodeScene categories, for reference: **10 optimal**, **9–9.9 green**,
34
- **4–8.9 yellow**, **1–3.9 red**.
35
-
36
- ## When to check
37
-
38
- Use the `codescene` MCP server's `code_health_review` on changed files after
39
- editing. Before declaring work done or opening a PR, run
40
- `pre_commit_code_health_safeguard`, or `analyze_change_set` against the base
41
- branch. Name any decline the user explicitly accepts in the report or PR comment;
42
- never hide it.
25
+ CodeScene categories, for reference: **10 optimal**, **9–9.9 green**, **4–8.9 yellow**,
26
+ **1–3.9 red**. Project target: **Hotspot Code Health at least 9**, with no downward trend.
27
+ Name any shortfall the user explicitly accepts in the report or PR comment; never hide it.
43
28
 
44
29
  ## Exclusions and precedence
45
30
 
46
31
  Never refactor generated code: proto/gRPC contracts, generated proxies or `obj/`.
47
32
  "Could not determine Code Health score" is not a failure.
48
33
 
34
+ Optional recipe for generated code CodeScene still scores: a root `.codescene/code-health-rules.json`
35
+ with one `rule_sets` entry whose `matching_content_path` is the generated glob (`**/*.g.cs`,
36
+ `**/Generated/**`, `**/Proxies/**`) and `rules` listing every rule at `"weight": 0.0` scores those
37
+ files 10 and leaves others unchanged (verified). Names: Bumpy Road Ahead, Complex Conditional,
38
+ Complex Method, Constructor Over-Injection, Code Duplication, Deep, Nested Complexity, Excess Number
39
+ of Function Arguments, Large Method, Large Assertion Blocks, Duplicated Assertion Blocks, Low
40
+ Cohesion, Brain Class, Brain Method, Overall Code Complexity, Primitive Obsession, String Heavy
41
+ Function Arguments, Lines of Code in a Single File, Number of Functions in a Single Module, Global
42
+ Conditionals, Missing Arguments Abstractions. Run `rules_config_validate` first; never exclude domain
43
+ code such as Chronicle `Migrations`. The corpus cannot install this file.
44
+
49
45
  Other Cratis rules take precedence over findings. One-file vertical slices make
50
46
  "Lines of Code in a Single File" expected; do not rewrite `ConceptAs` usage or
51
47
  spec conventions to satisfy a finding.
@@ -123,6 +123,7 @@ A claim is only as good as the signal behind it — a build result, a test run,
123
123
  - The affected solution/project builds with zero warnings and zero errors.
124
124
  - Relevant specs for every affected project pass.
125
125
  - For public-facing changes (clients, SDKs, public APIs, developer-facing behavior), documentation is added or updated and its verification passes.
126
+ - 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`).
126
127
 
127
128
  ## Where to Look
128
129
 
@@ -141,8 +142,8 @@ A claim is only as good as the signal behind it — a build result, a test run,
141
142
  | Spec patterns — universal `Specification` base (both profiles) | `specs.md`, `specs.csharp.md`, `specs.typescript.md` |
142
143
  | Build and spec-run speed: parallel-safe specs, no per-spec startup, cheap analyzers | `fast-feedback.md` |
143
144
  | Spec patterns — the four `*Scenario` helpers (application only) | `specs.scenarios.csharp.md` |
144
- | Strongly-typed values (`ConceptAs<T>`, `EventSourceId<T>`) | `concepts.md` |
145
- | Shared term definitions (event, projection, reducer, reactor, observer, DCB, …) | `glossary.md` |
145
+ | Strongly-typed values (`ConceptAs<T>`, `EventSourceId<T>`); shared term definitions (event, projection, reducer, reactor, observer, DCB, …) | `concepts.md`; `glossary.md` |
146
+ | Files an AI change touches (Code Health with CodeScene) | `code-health.md` |
146
147
  | 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
148
  | 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 |
148
149
  | EF Core read models / migrations | `efcore.md`, `efcore.specs.md` |
@@ -162,8 +163,7 @@ A claim is only as good as the signal behind it — a build result, a test run,
162
163
  | Code-level event modeling / schema migration / calling commands from code / paging / cross-cutting metadata / multi-tenancy | the matching skills |
163
164
  | Building or changing behavior in an opted-in repository (see Model first above), or designing an information system, business process or information flow: **model first** | the **cratis-screenplay-event-modeling** skill (decision rule), then **cratis-screenplay-modeling-lifecycle** and one phase skill; per-surface `cratis-screenplay-*` skills for syntax |
164
165
  | Building or changing behavior in a Cratis application that is not opted in | `application-profile.md` Phase 0, then the code skills (**cratis-arc-command**, **cratis-chronicle-projection**, ...) |
165
- | Reviewing or explaining a `.play` model | the **cratis-screenplay-model-review** skill |
166
- | Turning an existing system into a model | the **cratis-screenplay-legacy-extraction** skill |
166
+ | Reviewing or explaining a `.play` model; turning an existing system into a model | the **cratis-screenplay-model-review** skill; the **cratis-screenplay-legacy-extraction** skill |
167
167
  | Rendering or gap-filling an accepted model | the **cratis-screenplay-render-and-gap-fill** skill, then **cratis-stage-rendering-and-sandbox** for renderer facts |
168
168
  | Code, security, performance and repository-investigation review reports | `review-reports.md` |
169
169
  | Authoring or reviewing skills, rules, agents or prompts | `authoring-skills.md` |
@@ -87,7 +87,7 @@ profile includes neither Screenplay nor Stage.
87
87
  | Profile ID | Description | Automatically Includes |
88
88
  |---|---|---|
89
89
  | `cratis/engineering` | Engineering conventions and workflows | `cratis/engineering/core`, `cratis/engineering/csharp`, `cratis/engineering/elixir`, `cratis/engineering/go`, `cratis/engineering/kotlin`, `cratis/engineering/react`, `cratis/engineering/typescript` |
90
- | `cratis/engineering/core` | Shared engineering method skills: `cratis-ci-pipeline-performance`, `cratis-documentation-writing`, `cratis-engineering-ci-gates`, `cratis-engineering-consolidation-guard`, `cratis-engineering-decision-record`, `cratis-engineering-docs-authoring`, `cratis-engineering-effect-boundaries`, `cratis-engineering-issue-hygiene`, `cratis-engineering-issue-design-note`, `cratis-engineering-local-cross-repo-verification`, `cratis-engineering-regression-cluster`, `cratis-engineering-release-trains`, `cratis-engineering-review-rounds`, `cratis-release-notes`, `cratis-technical-examples` | (no child profiles) |
90
+ | `cratis/engineering/core` | Shared engineering method skills: `cratis-ci-pipeline-performance`, `cratis-documentation-writing`, `cratis-engineering-ci-gates`, `cratis-engineering-consolidation-guard`, `cratis-engineering-decision-record`, `cratis-engineering-docs-authoring`, `cratis-engineering-effect-boundaries`, `cratis-engineering-issue-hygiene`, `cratis-engineering-issue-design-note`, `cratis-engineering-local-cross-repo-verification`, `cratis-engineering-regression-cluster`, `cratis-engineering-release-trains`, `cratis-engineering-review-rounds`, `cratis-release-notes`, `cratis-session-handoff`, `cratis-technical-examples` | (no child profiles) |
91
91
  | `cratis/engineering/csharp` | C# engineering conventions, .NET engineering skills, and framework Orleans jobs (`cratis-orleans-jobs`, alongside `orleans.md`) | `cratis/engineering/core`, `cratis/engineering/dotnet` |
92
92
  | `cratis/engineering/dotnet` | Upstream .NET engineering workflows | `cratis/engineering/dotnet/performance`, `cratis/engineering/dotnet/diagnostics`, `cratis/engineering/dotnet/msbuild`, `cratis/engineering/dotnet/orleans`, `cratis/engineering/dotnet/testing`, `cratis/engineering/dotnet/refactoring` |
93
93
  | `cratis/engineering/dotnet/performance` | Microbenchmarking, performance patterns, SIMD, and profiling | (no child profiles) |
@@ -233,7 +233,8 @@ language policy always follows the consuming repository's `go.mod` minimum.
233
233
  Select `cratis/codescene` explicitly to load the four upstream CodeScene skills:
234
234
  `safeguarding-ai-generated-code`, `guiding-refactoring-with-code-health`,
235
235
  `prioritizing-technical-debt` and `risk-based-testing-with-code-health`.
236
- The [CodeScene policy](./codescene.md) overrides those skills where they differ.
236
+ The [CodeScene policy](./codescene.md) overrides those skills where they differ. The Code Health
237
+ floor itself is the universal rule [code-health.md](./code-health.md); the profile supplies the skills and server.
237
238
  No other profile, including `cratis` and `cratis/full`, composes it.
238
239
 
239
240
  The profile selects the `codescene` stdio server (`cs-mcp`, no arguments) from
@@ -80,6 +80,11 @@ and exhaustion never imply approval. Verify cancellation before replacement; esc
80
80
  unresolved disputes instead of looping. Suggestions alone do not justify another round.
81
81
  See `cratis-engineering-review-rounds` for dispatch and writer-pause mechanics.
82
82
 
83
+ Code Health (`code-health.md`) never earns a round of its own: flag a touched file below
84
+ 9.5 with no reported reason only together with the round's other findings. A file below 9.5
85
+ with a reason and an uplift entry is closed; a second Code Health round is a finding that
86
+ names its cause.
87
+
83
88
  ## Reviewer independence
84
89
 
85
90
  - **[contract]** Run a reviewer on a different provider family than the author's model
@@ -105,10 +105,10 @@ Everything else a lane decides, records and reports.
105
105
 
106
106
  ## Context handoff
107
107
 
108
- When a lane must stop and another session continues, write a handoff that keeps
109
- verified facts apart from plans and states its preconditions. Read
110
- [references/context-handoff.md](references/context-handoff.md) when writing or resuming from one. The
111
- preconditions rule itself lives in
108
+ When a lane must stop and another session continues, write a handoff named
109
+ `handoff-<lane-id>.md` under the task folder. Structure, filling rules and
110
+ resuming follow [cratis-session-handoff](../cratis-session-handoff/SKILL.md);
111
+ the preconditions rule lives in
112
112
  [local-work-artifacts.md](../../rules/local-work-artifacts.md).
113
113
 
114
114
  ## Roll call
@@ -8,7 +8,7 @@
8
8
  { "kind": "skill-contains", "value": "Record every takeover in the register" },
9
9
  { "kind": "skill-contains", "value": "references/inbox-and-handover.md" },
10
10
  { "kind": "skill-contains", "value": "references/lane-brief.md" },
11
- { "kind": "skill-contains", "value": "references/context-handoff.md" },
11
+ { "kind": "skill-contains", "value": "../cratis-session-handoff/SKILL.md" },
12
12
  { "kind": "skill-contains", "value": "Stopping and escalating never wait" },
13
13
  { "kind": "skill-contains", "value": "Answer from evidence, not memory" }
14
14
  ]
@@ -0,0 +1,2 @@
1
+ Copyright (c) Cratis. All rights reserved.
2
+ Licensed under the MIT license. See LICENSE file in the canonical Cratis/AI repository for the full license text.
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: cratis-session-handoff
3
+ description: Use when a long session nears its context limit, a milestone ends, or work must continue in a fresh session; also for keeping a running state note. Not for coordinating parallel lanes (cratis-orchestration-lanes).
4
+ license: LICENSE
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
+ # Hand off a session without losing state
11
+
12
+ A session ends sooner than the task does. The state that matters (running jobs,
13
+ other worktrees, unanswered questions, the user's exact words) lives only in
14
+ the session's context, so it is written down while the session is healthy, not
15
+ reconstructed after it degrades. This skill covers one agent continuing its own
16
+ task in a later session. Parallel lanes with claims, leases and inboxes use
17
+ `cratis-orchestration-lanes`, which reuses the template here.
18
+
19
+ Work records live under `.ai-work/` as defined in
20
+ [local-work-artifacts.md](../../rules/local-work-artifacts.md), which also owns
21
+ the preconditions every handoff opens with.
22
+
23
+ ## Keep a state note
24
+
25
+ Default: keep `.ai-work/<task>/STATE.md` from the start of any task expected to
26
+ span more than one sitting. It holds the same sections as the handoff template,
27
+ so a handoff is a copy plus a verification, not a reconstruction.
28
+
29
+ Update it at each milestone and before any long wait. Also update it
30
+ immediately after:
31
+
32
+ - launching a job, subagent or CI watch (record its immutable id and what to do
33
+ when it finishes);
34
+ - receiving a user instruction (quote it verbatim);
35
+ - asking or answering a question (record the question and its status).
36
+
37
+ A note updated only at the end is the one that is missing when the session is
38
+ cut off.
39
+
40
+ ## When to hand off
41
+
42
+ Hand off at a milestone, or when the context is nearly full: by default at
43
+ about 60-70% used or when the harness warns. A repository or brief may set
44
+ another threshold; harnesses differ in how they report usage. Hand off at a
45
+ boundary, never mid-atomic-step: a half-finished edit or half-run command
46
+ cannot be described reliably.
47
+
48
+ When the context is nearly full:
49
+
50
+ 1. Finish the current atomic step.
51
+ 2. Update `STATE.md`.
52
+ 3. Write the handoff from it. Read
53
+ [references/handoff-template.md](references/handoff-template.md) for the
54
+ fixed structure, the rules for filling it and a worked example.
55
+ 4. Verify it: check every precondition against `git`, confirm each section is
56
+ present, confirm every running job has a full watch row.
57
+ 5. End the session, or reset it with your harness's compaction or new-session
58
+ command, starting from the handoff.
59
+
60
+ ## Session hygiene
61
+
62
+ - One repository and one task per session. A second task makes the handoff
63
+ ambiguous about what is current.
64
+ - At a milestone, start a fresh session from a handoff instead of running one
65
+ session all day; quality drops as context fills.
66
+ - Delegate log, diff and CI digests where the harness allows it; reading raw
67
+ output spends context on bytes the decision does not need.
68
+ - A truncated view is never gate evidence. Read the full result or the exit
69
+ code before claiming a check passed.
70
+ - Explore an alternative design in a branch of the session or a fresh one, so
71
+ the original plan is preserved.
72
+
73
+ ## Resuming
74
+
75
+ Start from the handoff, not from memory:
76
+
77
+ 1. Run `git rev-parse --show-toplevel`, `git rev-parse HEAD`,
78
+ `git branch --show-current` and `git worktree list`; compare with the
79
+ preconditions and the repositories table.
80
+ 2. Read the finished, unread results first.
81
+ 3. Reconcile every watch row against the real state of its target; decide each
82
+ action from that state.
83
+ 4. Re-read the verbatim constraints and instructions before the next command.
84
+
85
+ A stale handoff is not a lost one: a mismatch means the work moved. Find it
86
+ through branches, the reflog and open pull requests before recreating or
87
+ resetting anything.
88
+
89
+ ## Pitfalls
90
+
91
+ - **Unrecorded jobs and subagents.** A job started and never written down is
92
+ orphaned by the reset. Record it the moment it starts.
93
+ - **Other repositories and worktrees.** Work in a second checkout is invisible
94
+ to a note that names only the current one; list every path in the table.
95
+ - **Questions from earlier sessions.** An open question forgotten is a
96
+ decision made by default. Carry it forward with who asked and its status.
97
+ - **Paraphrased user words.** A summary drops the condition that mattered.
98
+ Quote constraints and instructions exactly.
99
+
100
+ ## Verification
101
+
102
+ A handoff is complete when every heading of the template is present in order,
103
+ the repositories and watch tables use the exact header rows, every running job,
104
+ CI watch and subagent has a row with an immutable target, and each user quote
105
+ is verbatim.
@@ -0,0 +1,135 @@
1
+ <!-- Copyright (c) Cratis. All rights reserved. -->
2
+ <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
3
+
4
+ # Handoff template
5
+
6
+ ## Contents
7
+
8
+ - Template
9
+ - Rules for filling it in
10
+ - Filled example
11
+
12
+ A handoff lets a fresh session continue work. Save it as
13
+ `.ai-work/<task>/handoff.md`; a lane uses `.ai-work/<task>/handoff-<lane-id>.md`.
14
+ It opens with the preconditions (repository, branch, expected `HEAD`, worktree
15
+ paths, date) required by
16
+ [local-work-artifacts.md](../../../rules/local-work-artifacts.md). The next
17
+ session compares them with `git` before acting; a mismatch means the handoff is
18
+ stale, not that the work is lost.
19
+
20
+ The structure is fixed so a tool can check it: the headings below appear
21
+ exactly as spelled, in this order, and the table headers are not reworded.
22
+ Every section is present even when empty; write `none` so an absence is
23
+ detectable and never ambiguous.
24
+
25
+ ## Template
26
+
27
+ ```markdown
28
+ # Handoff: <task>
29
+
30
+ **Preconditions:** repository `<repo>`, branch `<branch>`, HEAD `<full-sha>`,
31
+ worktrees `<paths>`, written `<date>`.
32
+
33
+ ## Goal
34
+ <one sentence>
35
+
36
+ ## Repositories and worktrees
37
+ | Path | Repository | Branch | HEAD (full SHA) | State | Ahead/behind |
38
+ |---|---|---|---|---|---|
39
+ | <path> | <repository> | <branch> | <full-sha> | <clean or dirty> | <ahead/behind> |
40
+
41
+ ## Verified facts (with evidence)
42
+ - <fact>: <evidence: command run, SHA, run id>
43
+
44
+ ## Plans and hypotheses (not verified)
45
+ - <plan or guess>
46
+
47
+ ## Watch and action
48
+ | Id | Target (immutable) | Action on completion | How to cancel |
49
+ |---|---|---|---|
50
+ | <job, run or subagent id> | <run id, head SHA or job id> | <what to do> | <command or step> |
51
+
52
+ ## Finished, results not yet read
53
+ - <job id>: <where the result lives>
54
+
55
+ ## Open questions carried forward
56
+ - <question>: <who asked and when>, <status>
57
+
58
+ ## User constraints (verbatim)
59
+ > <quoted exactly, never paraphrased>
60
+
61
+ ## User instructions since the last handoff (verbatim)
62
+ > <quoted exactly, or none>
63
+
64
+ ## Next commands
65
+ 1. `<command>`
66
+
67
+ ## Files to read
68
+ - `<path>`
69
+ ```
70
+
71
+ ## Rules for filling it in
72
+
73
+ - State is `clean` or `dirty`, nothing else. Ahead/behind is relative to the
74
+ branch's upstream.
75
+ - Facts and plans stay in separate sections. A claim without evidence is a plan.
76
+ - The watch table has one row per running job, CI watch or subagent. The target
77
+ is an immutable identifier (run id, pull request head SHA, job id), never
78
+ "latest" or "the PR", because the thing it points to moves.
79
+ - When nothing runs, the watch table keeps one row whose cells say `none`.
80
+ - Results that finished but were never read go under their own heading so the
81
+ next session reads them first.
82
+ - Quote user words exactly. A paraphrase loses the constraint's edges.
83
+
84
+ ## Filled example
85
+
86
+ ```markdown
87
+ # Handoff: export retry cap
88
+
89
+ **Preconditions:** repository `export-service`, branch `export-retry`, HEAD
90
+ `0123456789abcdef0123456789abcdef01234567`, worktrees
91
+ `../.worktrees/export-retry` and `../.worktrees/export-docs-retry`, written
92
+ 2025-01-01.
93
+
94
+ ## Goal
95
+ Cap export retries at five and surface the final failure.
96
+
97
+ ## Repositories and worktrees
98
+ | Path | Repository | Branch | HEAD (full SHA) | State | Ahead/behind |
99
+ |---|---|---|---|---|---|
100
+ | ../.worktrees/export-retry | export-service | export-retry | 0123456789abcdef0123456789abcdef01234567 | clean | 2/0 |
101
+ | ../.worktrees/export-docs-retry | export-docs | export-retry-docs | 89abcdef0123456789abcdef0123456789abcdef | dirty | 1/0 |
102
+
103
+ ## Verified facts (with evidence)
104
+ - Cap and spec committed: `git log -1` shows the SHA above.
105
+ - Spec project passes: `./Source/Export.Specs/bin/Debug/net10.0/Export.Specs` exit 0 at that SHA.
106
+ - Pull request is open: `gh pr list --head export-retry` shows one entry.
107
+
108
+ ## Plans and hypotheses (not verified)
109
+ - The integration job may need the same cap; not inspected.
110
+
111
+ ## Watch and action
112
+ | Id | Target (immutable) | Action on completion | How to cancel |
113
+ |---|---|---|---|
114
+ | ci-1 | CI run `1234567890` on head `0123456789abcdef0123456789abcdef01234567` | fails: read the failing job log, fix in owned files; passes: report ready | `gh run cancel 1234567890` |
115
+
116
+ ## Finished, results not yet read
117
+ - review-1: findings are in `.ai-work/export-retry/review-1.md`
118
+
119
+ ## Open questions carried forward
120
+ - Should the cap be configurable per tenant: asked by the user in the first session, unanswered.
121
+
122
+ ## User constraints (verbatim)
123
+ > Do not change the public job interface.
124
+
125
+ ## User instructions since the last handoff (verbatim)
126
+ > none
127
+
128
+ ## Next commands
129
+ 1. `git rev-parse HEAD` and compare with the preconditions
130
+ 2. `gh run view 1234567890 --json status,conclusion`
131
+
132
+ ## Files to read
133
+ - `Source/Export/ExportJob.cs`
134
+ - `.ai-work/export-retry/STATE.md`
135
+ ```
@@ -0,0 +1,13 @@
1
+ {
2
+ "skill": "cratis-session-handoff",
3
+ "input": "A long single session is nearly out of context with a CI run in progress and an unanswered question; hand it off.",
4
+ "fixtures": [],
5
+ "assertions": [
6
+ { "kind": "skill-contains", "value": ".ai-work/<task>/STATE.md" },
7
+ { "kind": "skill-contains", "value": "references/handoff-template.md" },
8
+ { "kind": "skill-contains", "value": "never mid-atomic-step" },
9
+ { "kind": "skill-contains", "value": "A stale handoff is not a lost one" },
10
+ { "kind": "skill-contains", "value": "A truncated view is never gate evidence" },
11
+ { "kind": "skill-contains", "value": "cratis-orchestration-lanes" }
12
+ ]
13
+ }
@@ -1110,6 +1110,7 @@
1110
1110
  "cratis-engineering-release-trains",
1111
1111
  "cratis-engineering-review-rounds",
1112
1112
  "cratis-release-notes",
1113
+ "cratis-session-handoff",
1113
1114
  "cratis-technical-examples"
1114
1115
  ],
1115
1116
  "languages": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.144.1",
3
+ "version": "7.146.0",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,85 +0,0 @@
1
- <!-- Copyright (c) Cratis. All rights reserved. -->
2
- <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
3
-
4
- # Context handoff
5
-
6
- A handoff lets a fresh session continue work. Save it as
7
- `<work-root>/<task>/handoff-<lane-id>.md`. It opens with the preconditions
8
- (repository, branch, expected `HEAD`, worktree paths, date) required by
9
- [local-work-artifacts.md](../../../rules/local-work-artifacts.md). The next
10
- session compares them with `git` before acting; a mismatch means the handoff is
11
- stale, not that the work is lost.
12
-
13
- ## Template
14
-
15
- ```markdown
16
- # Handoff: <task>, lane <lane-id>
17
-
18
- **Preconditions:** repository `<repo>`, branch `<branch>`, HEAD `<full-sha>`,
19
- worktrees `<paths>`, written `<date>`.
20
-
21
- ## Goal
22
- <one sentence>
23
-
24
- ## Verified facts (with evidence)
25
- - <fact>: <evidence: command run, SHA, run id>
26
-
27
- ## Plans and hypotheses (not verified)
28
- - <plan or guess>
29
-
30
- ## Watch and action
31
- | Watch | When it changes | Action |
32
- |---|---|---|
33
- | <thing to observe> | <condition> | <what to do> |
34
-
35
- ## User constraints (verbatim)
36
- > <quoted exactly, never paraphrased>
37
-
38
- ## Next commands
39
- 1. `<command>`
40
-
41
- ## Files to read
42
- - `<path>`
43
- ```
44
-
45
- Keep facts and plans in separate sections. A claim without evidence belongs
46
- under plans.
47
-
48
- ## Filled example
49
-
50
- ```markdown
51
- # Handoff: export retry cap, lane A1
52
-
53
- **Preconditions:** repository `<repo>`, branch `export-retry`, HEAD
54
- `0123456789abcdef0123456789abcdef01234567`, worktree `../.worktrees/export-retry`,
55
- written 2025-01-01.
56
-
57
- ## Goal
58
- Cap export retries at five and surface the final failure.
59
-
60
- ## Verified facts (with evidence)
61
- - Cap and spec committed: `git log -1` shows the SHA above.
62
- - Spec project passes: `./Source/Export.Specs/bin/Debug/net10.0/Export.Specs` exit 0 at that SHA.
63
- - Pull request is open: `gh pr list --head export-retry` shows one entry; CI run
64
- `1234567890` is in progress.
65
-
66
- ## Plans and hypotheses (not verified)
67
- - The integration job may need the same cap; not inspected.
68
-
69
- ## Watch and action
70
- | Watch | When it changes | Action |
71
- |---|---|---|
72
- | CI run `1234567890` | fails | read the failing job log, fix in owned files |
73
- | PR review | blocking finding | start a delta round, not a restart |
74
-
75
- ## User constraints (verbatim)
76
- > Do not change the public job interface.
77
-
78
- ## Next commands
79
- 1. `git rev-parse HEAD` and compare with the preconditions
80
- 2. `gh run view 1234567890 --json status,conclusion`
81
-
82
- ## Files to read
83
- - `Source/Export/ExportJob.cs`
84
- - `.ai-work/export-retry/brief-A1.md`
85
- ```