@srobroek/pi-code-quality 0.21.0 → 0.22.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## quality [0.22.0](https://github.com/srobroek/harness-plugins/compare/quality--v0.21.0...quality--v0.22.0) (2026-11-30)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **business-rules:** add the business-rules plugin ([e88e8ac](https://github.com/srobroek/harness-plugins/commit/e88e8aced560ebb0f6cf781d8f7083c20dee7142))
|
|
6
|
+
|
|
1
7
|
## quality [0.21.0](https://github.com/srobroek/harness-plugins/compare/quality--v0.20.1...quality--v0.21.0) (2026-11-29)
|
|
2
8
|
|
|
3
9
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srobroek/pi-code-quality",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Code design and review guidance, a code-quality policy, testing standards and a test audit, performance profiling, and throwaway logic prototypes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -41,7 +41,7 @@ References live in `references/` beside this file; the links below are relative
|
|
|
41
41
|
| Logs, traces, metrics, or a new service, worker, CLI or Lambda function → [telemetry.md](references/telemetry.md) | OpenTelemetry by default: setup, export, propagation, sampling, flushing, span/metric/log rules, telemetry tests; SDK packages live in `lang-<language>-libraries` |
|
|
42
42
|
| Feature flags, rollout decisions, outage defaults or flag storage → [feature-flags.md](references/feature-flags.md) | Typed flag module, edge decisions, safe defaults, storage, testing, telemetry and removal; process lives in `trunk-dev-feature-flags` |
|
|
43
43
|
| Database state, transitions, migrations, dynamic SQL, or persistence tests → [persistence.md](references/persistence.md) | DB as the record, compare-and-set updates, append-only migrations, bound queries, real-database tests |
|
|
44
|
-
| A serialized or published contract (HTTP API, config or file format, record, CLI or tool JSON output, event, MCP tool schema); generated bindings, IPC command names, wire casing, or client/server contract tests → [contracts.md](references/contracts.md) | TypeSpec
|
|
44
|
+
| A serialized or published contract (HTTP API, config or file format, record, CLI or tool JSON output, event, MCP tool schema); generated bindings, IPC command names, wire casing, or client/server contract tests → [contracts.md](references/contracts.md) | TypeSpec source, codegen drift check, CEL types, pattern dialect, generator issues, name conformance, one casing, real-surface tests, stubs |
|
|
45
45
|
| Plan/approve/apply flows, bulk or destructive file operations, path checks, audit trails → [safe-mutation.md](references/safe-mutation.md) | Apply-time approval tokens, freshness checks, traversal, append-only audit, reversible deletes |
|
|
46
46
|
| Contracts, internal knowledge, naming, errors, or effects → [supporting-principles.md](references/supporting-principles.md) | Design by Contract, least knowledge, predictability, command-query separation; researched sources and limits |
|
|
47
47
|
| Go code → [go.md](references/go.md) | Consumer interfaces, structs, composition, package boundaries, errors |
|
|
@@ -46,6 +46,28 @@ Observed on the spike's 29 fixtures for one contract, 2026-11-25. None beat Type
|
|
|
46
46
|
| `ogen` orders open-object extras randomly | Compare parsed JSON, not bytes, in golden tests (this fixes key order only) |
|
|
47
47
|
| Fractions longer than 6 digits (Pydantic) or 9 digits (typify, ogen) are truncated on round trip | Comparing parsed JSON does not recover lost precision. Test the significant fractional digits, then constrain the precision in the contract or use a lossless representation (an integer count or a string) |
|
|
48
48
|
|
|
49
|
+
## Generate CEL types from the published schemas
|
|
50
|
+
|
|
51
|
+
A CEL rule that reads a contract's records needs an environment built from the published JSON Schema.
|
|
52
|
+
|
|
53
|
+
**Do:**
|
|
54
|
+
|
|
55
|
+
- Generate the CEL environment from that schema.
|
|
56
|
+
- Let the generator write a FileDescriptorSet and one profile manifest per rule scope.
|
|
57
|
+
- Validate each record against its schema first.
|
|
58
|
+
- Skip the type for a scope whose reachable nodes differ in shape.
|
|
59
|
+
|
|
60
|
+
Rules see only valid records.
|
|
61
|
+
The `business-rules-cel` skill in the `business-rules` plugin gives the pipeline and the standard.
|
|
62
|
+
|
|
63
|
+
**Do not:**
|
|
64
|
+
|
|
65
|
+
- Hand-write a CEL environment.
|
|
66
|
+
- Type a field `dyn`.
|
|
67
|
+
- Keep a hand-written `.proto` for rules next to the TypeSpec source.
|
|
68
|
+
|
|
69
|
+
The generator output includes the `.proto` files. Check them for drift like every other generated file.
|
|
70
|
+
|
|
49
71
|
## Pattern dialect
|
|
50
72
|
|
|
51
73
|
Schema `pattern` values run in a different regex engine in each language (ECMAScript, Rust `regex`, RE2, Python `re`, pydantic-core), and they disagree on `\d`, `\w`, `\s`, `$` and Unicode classes. Spike evidence, 9 engines, 2026-11-24.
|
|
@@ -84,7 +106,7 @@ Read when a consumer is built before the provider exists. When to stub and how t
|
|
|
84
106
|
**Do:** put the dependency behind the contract's interface (trait, interface, protocol). Consumers take the interface, so a swap changes only wiring. Use the contract's shared types (generated from the schema, or the one shared types module).
|
|
85
107
|
**Do not:** copy a contract type into a stub or consumer, or define the interface inside the stub.
|
|
86
108
|
|
|
87
|
-
**Do:** mark each stub `// STUB(<task-id>): what this fakes` (`#` in Python, TOML and YAML). One marker names one task
|
|
109
|
+
**Do:** mark each stub `// STUB(<task-id>): what this fakes` (`#` in Python, TOML and YAML). One marker names one task. One task owns one or more markers. Keep stubs minimal and deterministic: implement the contract, nothing more.
|
|
88
110
|
**Do not:** let a stub on a production path silently return plausible fake data. Where it affects behavior, say so with a capability flag or a "not yet supported" error.
|
|
89
111
|
|
|
90
112
|
Drift checks above still apply: regenerate shared types in the same change as a contract change. When two languages share a contract, both consume the same generated schema files: `toolchain-api` has the gates and `quality-testing`'s `shared-contracts.md` the tests. Language examples: [rust.md](rust.md), [python.md](python.md), [typescript.md](typescript.md), [go.md](go.md).
|
|
@@ -58,5 +58,6 @@ fixes, load the `quality-test-audit` skill.
|
|
|
58
58
|
| Changing, removing or refactoring tested code; bug fixes, legacy code, flaky tests | [maintenance.md](references/maintenance.md) |
|
|
59
59
|
| Choosing a fake, stub, spy or mock, or a double for a contract | [doubles.md](references/doubles.md) |
|
|
60
60
|
| Two languages or processes share a message contract: one schema, a shared corpus, cross-language tests | [shared-contracts.md](references/shared-contracts.md) |
|
|
61
|
+
| Testing business rules or CEL expressions: rule case tables, the supported-profile suite per engine, presence and bundle cases | the `business-rules-testing` skill of the `business-rules` plugin |
|
|
61
62
|
| Coverage, mutation testing, property tests, fuzzing | [signals.md](references/signals.md) |
|
|
62
63
|
| Reviewing the test changes in a diff or pull request | [review-tests.md](references/review-tests.md) |
|