@rt-tools/agent-kit 0.23.0 → 0.26.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/README.md +8 -2
- package/assets/agents/business-analyst.md +51 -50
- package/assets/agents/conscience.md +37 -35
- package/assets/agents/project-manager.md +49 -48
- package/assets/agents/prose-editor.md +31 -29
- package/assets/agents/qa-engineer.md +50 -48
- package/assets/agents/rules-reviewer.md +63 -58
- package/assets/agents/skill-curator.md +83 -78
- package/assets/agents/spec-critic.md +34 -29
- package/assets/agents/spec-writer.md +35 -32
- package/assets/agents/strict-teacher.md +39 -37
- package/assets/checks/archive-age.mjs +48 -28
- package/assets/checks/archive-prune.mjs +16 -14
- package/assets/checks/board-epics.github.mjs +75 -41
- package/assets/checks/board-folders.mjs +61 -0
- package/assets/checks/board-gh.github.mjs +35 -26
- package/assets/checks/board-long-work.github.mjs +24 -24
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +150 -128
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +179 -157
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +104 -82
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +79 -70
- package/assets/checks/check-glossary.mjs +47 -37
- package/assets/checks/check-hook-scope.mjs +30 -27
- package/assets/checks/check-lib-layers.mjs +22 -21
- package/assets/checks/check-profile-drift.mjs +48 -43
- package/assets/checks/check-prose-style.mjs +125 -33
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +87 -83
- package/assets/checks/check-specs.mjs +155 -134
- package/assets/checks/check-state-next.mjs +66 -52
- package/assets/checks/check-states.mjs +32 -30
- package/assets/checks/check-styles.mjs +52 -51
- package/assets/checks/check-turn-map.mjs +54 -46
- package/assets/checks/lib-boundaries.mjs +32 -30
- package/assets/checks/lib-common.mjs +30 -29
- package/assets/checks/lib-domains.mjs +34 -34
- package/assets/checks/lib-manifests.mjs +17 -15
- package/assets/checks/lib-reexports.mjs +18 -18
- package/assets/checks/rt-kit-checks.config.mjs +174 -142
- package/assets/checks/signals.mjs +43 -39
- package/assets/checks/spec-anchors.mjs +114 -87
- package/assets/checks/spec-common.mjs +128 -84
- package/assets/checks/spec-contract.mjs +30 -30
- package/assets/checks/spec-proposed.mjs +27 -24
- package/assets/checks/spec-scenarios.mjs +51 -28
- package/assets/checks/task-new.github.mjs +85 -56
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +115 -91
- package/assets/defaults/project.sh +228 -178
- package/assets/defaults/shell.sh +85 -65
- package/assets/defaults/turn-map.md +45 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +12 -12
- package/assets/hooks/browser-guard-device-id.sh +46 -14
- package/assets/hooks/browser-guard-no-asking.sh +5 -4
- package/assets/hooks/browser-guard-no-listing.sh +12 -11
- package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
- package/assets/hooks/browser-guard-require-select.sh +34 -23
- package/assets/hooks/claim-guard.sh +62 -56
- package/assets/hooks/commit-msg.sh +11 -10
- package/assets/hooks/conscience-guard.sh +91 -45
- package/assets/hooks/constitution-index.sh +16 -16
- package/assets/hooks/deny-tail.sh +28 -26
- package/assets/hooks/dev-server-guard.sh +46 -43
- package/assets/hooks/dispatch.sh +84 -39
- package/assets/hooks/docs-guard.sh +105 -86
- package/assets/hooks/exam-guard.sh +146 -84
- package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
- package/assets/hooks/git-guard-delivery-draft.sh +85 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +88 -52
- package/assets/hooks/git-guard-delivery.sh +207 -253
- package/assets/hooks/git-guard-main.sh +65 -26
- package/assets/hooks/git-guard-push-tests.sh +133 -75
- package/assets/hooks/glossary-load.sh +23 -22
- package/assets/hooks/grill-gate-ask.sh +12 -11
- package/assets/hooks/grill-gate.sh +94 -87
- package/assets/hooks/guard-note.sh +20 -19
- package/assets/hooks/handoff-entry-guard.sh +26 -24
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +70 -50
- package/assets/hooks/lint-after-edit.sh +95 -61
- package/assets/hooks/observe.sh +28 -26
- package/assets/hooks/override-write-guard.sh +23 -21
- package/assets/hooks/postmortem-guard.sh +42 -39
- package/assets/hooks/profile-check.sh +22 -20
- package/assets/hooks/proposal-guard.sh +57 -49
- package/assets/hooks/prose-style-guard.sh +19 -17
- package/assets/hooks/qa-dataid-guard.sh +52 -49
- package/assets/hooks/rerun-guard.sh +31 -30
- package/assets/hooks/reuse-first-guard.sh +108 -87
- package/assets/hooks/roles.sh +14 -14
- package/assets/hooks/rule-article.sh +36 -34
- package/assets/hooks/rule-source-guard.sh +52 -36
- package/assets/hooks/skill-gate-layers.sh +59 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +6 -6
- package/assets/hooks/sql-guard-parse.sh +68 -66
- package/assets/hooks/sql-guard-request.sh +48 -46
- package/assets/hooks/sql-guard-target.sh +57 -51
- package/assets/hooks/sql-guard-write.sh +84 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +104 -0
- package/assets/hooks/task-context-load.sh +60 -55
- package/assets/hooks/task-flow-context.sh +87 -69
- package/assets/hooks/task-flow-draft-guard.sh +55 -48
- package/assets/hooks/task-flow-guard.sh +67 -64
- package/assets/hooks/turn-entry-load.sh +39 -32
- package/assets/hooks/turn-exit-guard.sh +256 -204
- package/assets/hooks/turn-exit-patterns.sh +53 -0
- package/assets/hooks/utf8.sh +11 -11
- package/assets/hooks/waiting-turn-guard.sh +94 -94
- package/assets/hooks/window-fill-guard.sh +70 -62
- package/assets/hooks/work-start-guard.sh +52 -49
- package/assets/hooks/write-targets.sh +115 -30
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +148 -137
- package/assets/laws/entity-editing.md +52 -50
- package/assets/laws/entity-models.md +14 -13
- package/assets/laws/frontend-application.md +39 -38
- package/assets/laws/lib-imports.md +27 -27
- package/assets/laws/lists.md +31 -29
- package/assets/laws/navigation.md +37 -37
- package/assets/laws/observability.md +41 -40
- package/assets/laws/project-documentation.md +106 -99
- package/assets/laws/reuse-first.md +31 -29
- package/assets/laws/shared-code.md +27 -27
- package/assets/laws/verifiability.md +131 -114
- package/assets/laws/work-conduct.md +250 -250
- package/assets/patterns/admin-lists-screen.md +72 -69
- package/assets/patterns/admin-nav-item.md +51 -46
- package/assets/patterns/angular-patterns-state.md +32 -31
- package/assets/patterns/api-layer-pair.md +33 -31
- package/assets/patterns/autonomous-work-run.md +50 -49
- package/assets/patterns/browser-verification-measure.md +143 -67
- package/assets/patterns/browser-verification-stand.md +181 -128
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +93 -0
- package/assets/patterns/doc-style-sweep.md +82 -79
- package/assets/patterns/doc-style-trace.md +87 -81
- package/assets/patterns/doc-style-write.md +130 -122
- package/assets/patterns/entity-aside.md +77 -63
- package/assets/patterns/entity-models-new.md +37 -37
- package/assets/patterns/entity-store.md +33 -33
- package/assets/patterns/git-workflow-commit.azure.md +94 -75
- package/assets/patterns/git-workflow-commit.github.md +153 -129
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -78
- package/assets/patterns/git-workflow-docker.md +165 -147
- package/assets/patterns/git-workflow-freshness.md +45 -45
- package/assets/patterns/git-workflow-merge.md +99 -86
- package/assets/patterns/git-workflow-migration.md +54 -52
- package/assets/patterns/git-workflow-pr-ready.md +57 -56
- package/assets/patterns/git-workflow-pr.azure.md +126 -121
- package/assets/patterns/git-workflow-pr.github.md +179 -175
- package/assets/patterns/git-workflow-pr.gitlab.md +138 -131
- package/assets/patterns/git-workflow-restart.md +35 -31
- package/assets/patterns/git-workflow-secrets.md +80 -73
- package/assets/patterns/git-workflow-stack.md +131 -106
- package/assets/patterns/lib-layers-move.md +62 -53
- package/assets/patterns/lib-layers-new.md +59 -45
- package/assets/patterns/observability-record.md +72 -67
- package/assets/patterns/platform-access-di.md +31 -29
- package/assets/patterns/reuse-first-extend.md +66 -61
- package/assets/patterns/shared-code-new.md +39 -38
- package/assets/patterns/spec-driven-domain.md +161 -151
- package/assets/patterns/spec-driven-rule.md +179 -168
- package/assets/patterns/spec-driven-sweep.md +41 -39
- package/assets/patterns/status-report-table.github.md +37 -36
- package/assets/patterns/styling-bem-component.md +42 -42
- package/assets/patterns/styling-bem-layout.md +39 -34
- package/assets/patterns/styling-bem-sheet.md +59 -58
- package/assets/patterns/task-flow-archive.md +222 -215
- package/assets/patterns/task-flow-close.md +215 -203
- package/assets/patterns/task-flow-handoff.md +154 -145
- package/assets/patterns/task-flow-resume.md +138 -133
- package/assets/patterns/task-flow-start.md +204 -192
- package/assets/patterns/testing-e2e.md +103 -92
- package/assets/patterns/testing-unit.md +77 -70
- package/assets/patterns/ts-procedure.md +32 -29
- package/assets/patterns/turn-entry-map.md +50 -48
- package/assets/pitfalls/agent-kit.md +152 -141
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +264 -234
- package/assets/pitfalls/git-workflow.gitlab.md +49 -45
- package/assets/pitfalls/spec-driven.md +73 -71
- package/assets/pitfalls/styling-bem.md +46 -40
- package/assets/pitfalls/task-flow.md +262 -246
- package/assets/pitfalls/testing.md +99 -92
- package/assets/pitfalls/turn-conduct.md +96 -81
- package/assets/rules/angular-patterns.md +81 -80
- package/assets/rules/api-layer.md +77 -74
- package/assets/rules/autonomous-work.md +75 -74
- package/assets/rules/browser-verification.md +223 -188
- package/assets/rules/component-structure.md +72 -69
- package/assets/rules/dependencies.md +74 -67
- package/assets/rules/deploy-flow.azure.md +118 -108
- package/assets/rules/deploy-flow.github.md +145 -135
- package/assets/rules/deploy-flow.gitlab.md +120 -110
- package/assets/rules/doc-style.md +209 -148
- package/assets/rules/entity-conventions.needs-admin.md +81 -79
- package/assets/rules/entity-models.md +73 -70
- package/assets/rules/git-workflow.azure.md +224 -228
- package/assets/rules/git-workflow.github.md +250 -242
- package/assets/rules/git-workflow.gitlab.md +218 -217
- package/assets/rules/lib-layers.md +85 -86
- package/assets/rules/lists.md +101 -97
- package/assets/rules/navigation.md +78 -78
- package/assets/rules/observability.needs-app.md +165 -153
- package/assets/rules/platform-access.md +76 -75
- package/assets/rules/reuse-first.md +153 -137
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +272 -260
- package/assets/rules/status-report.md +55 -58
- package/assets/rules/styling-bem.md +83 -72
- package/assets/rules/task-flow.md +282 -270
- package/assets/rules/testing.md +224 -188
- package/assets/rules/turn-conduct.md +255 -258
- package/assets/rules/turn-entry.md +92 -87
- package/assets/rules/typescript-conventions.md +94 -88
- package/assets/samples/specs/_template/spec.md +47 -47
- package/assets/samples/tasks/_template/grill.md +20 -20
- package/assets/samples/tasks/_template/plan.md +32 -30
- package/assets/samples/tasks/_template/progress.md +16 -16
- package/assets/skills/agent-kit-extend.md +129 -113
- package/assets/skills/agent-kit.md +236 -222
- package/assets/skills/write-a-skill.md +76 -71
- package/assets/templates/findings.md +19 -19
- package/assets/templates/gate-map.sh +16 -14
- package/assets/templates/implementation.md +28 -27
- package/assets/templates/pattern.md +17 -17
- package/assets/templates/pitfalls.md +6 -6
- package/assets/templates/postmortem.md +24 -23
- package/assets/templates/project.sh +24 -24
- package/assets/templates/proposal.md +62 -60
- package/assets/templates/rule.md +38 -38
- package/assets/workflows/feature.js +46 -46
- package/assets/workflows/plan.js +54 -54
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +4 -3
- package/lib/catalog.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +68 -4
- package/lib/commands.js.map +1 -1
- package/lib/companion.js +3 -2
- package/lib/companion.js.map +1 -1
- package/lib/enroll.d.ts +7 -1
- package/lib/enroll.d.ts.map +1 -1
- package/lib/enroll.js +13 -4
- package/lib/enroll.js.map +1 -1
- package/lib/observations.d.ts +10 -1
- package/lib/observations.d.ts.map +1 -1
- package/lib/observations.js +1 -0
- package/lib/observations.js.map +1 -1
- package/lib/override-marks.d.ts +24 -0
- package/lib/override-marks.d.ts.map +1 -0
- package/lib/override-marks.js +98 -0
- package/lib/override-marks.js.map +1 -0
- package/lib/plan.d.ts +11 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +10 -1
- package/lib/plan.js.map +1 -1
- package/lib/ship.d.ts +0 -7
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +10 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.js +7 -3
- package/lib/shipment.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +45 -11
- package/lib/sync.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.26.0.tgz +0 -0
- package/rt-tools-agent-kit-0.23.0.tgz +0 -0
|
@@ -2,98 +2,107 @@
|
|
|
2
2
|
name: lib-layers-move
|
|
3
3
|
kind: pattern
|
|
4
4
|
rule: lib-layers
|
|
5
|
-
description:
|
|
5
|
+
description: Pattern of rule lib-layers. Load when moving code or a symbol between libs — where to start, in which order to move domains, what to do with boundaries, imports and the README of both libs, and what to check with. Creating and removing a lib itself — pattern lib-layers-new.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# Moving code between libs
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Pattern of the rule `lib-layers`. What must be true — the law
|
|
11
11
|
`docs/constitution/lib-imports.md`.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## When to use
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
15
|
+
- A symbol moves from one lib to another.
|
|
16
|
+
- A domain is moved into a new layout.
|
|
17
|
+
- Shared code is collected from copies into one place.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Start with `docs/plans/`
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
grep -rn "
|
|
22
|
+
grep -rn "<lib name>" docs/
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
`libs/common/util`,
|
|
28
|
-
|
|
25
|
+
The decision about where the code moves is often already made and written down, and one made
|
|
26
|
+
anew drifts from it. That is why the move of the list utilities was done twice: the first edition
|
|
27
|
+
put them into `libs/common/util`, which the very first item of that same plan forbids, and it had
|
|
28
|
+
to be rolled back whole.
|
|
29
29
|
|
|
30
|
-
##
|
|
30
|
+
## The order is set by the dependency graph, not by the list in the plan
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
A domain is moved after everyone it depends on. Domain lists in plans are sorted by importance,
|
|
33
|
+
and following them head-on forces the boundaries to be widened for a while.
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
grep -rn "
|
|
36
|
+
grep -rn "@<scope>/<family>/<domain>" libs/ apps/ | sed 's/:.*//' | sort -u
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
The edges are written out by grepping the domain aliases and sorted topologically. Every
|
|
40
|
+
temporary line in the boundaries is a weakened mechanical check — the one the cutting was started
|
|
41
|
+
for.
|
|
41
42
|
|
|
42
|
-
##
|
|
43
|
+
## Where exactly the shared goes
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
A lib of its own is created when no existing lib sees the code.
|
|
45
46
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
47
|
+
| Who needs it | Where |
|
|
48
|
+
| ----------------------------------------------- | ----------------------------------------------------------- |
|
|
49
|
+
| the backend or both frontends, without Angular | `libs/common/util` |
|
|
50
|
+
| the frontends only, pulls Angular | `common/platform` — a service and a token, `common/ui` — a component |
|
|
51
|
+
| a subject that already has a lib | into it: `site-routing`, `i18n`, `photo`, `captcha` |
|
|
52
|
+
| every domain of one family | the family base `<family>/core` |
|
|
53
|
+
| the whole backend | the `util` layer already listed with every domain |
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
No new lines appear in the boundaries with such a move — except the right to see the contract,
|
|
56
|
+
if the code reads it.
|
|
56
57
|
|
|
57
|
-
##
|
|
58
|
+
## After the move
|
|
58
59
|
|
|
59
|
-
1. **README
|
|
60
|
-
|
|
61
|
-
2.
|
|
62
|
-
|
|
60
|
+
1. **The README of both libs.** The one the file left and the one it came to: the README lists
|
|
61
|
+
what lies in the lib and who calls it. No check reads these texts.
|
|
62
|
+
2. **Import order.** Moving an alias breaks it, and it arrives as a `prettier/prettier` error
|
|
63
|
+
from the lint, not from the build:
|
|
63
64
|
|
|
64
65
|
```bash
|
|
65
66
|
npx nx lint <project> --fix
|
|
66
67
|
```
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
`test` and `build` have no `--fix` flag, so it cannot be passed to `run-many -t lint test` —
|
|
70
|
+
the whole call fails.
|
|
70
71
|
|
|
71
|
-
3.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
3. **Lint over all touched projects, not over one application.** The script errs silently and
|
|
73
|
+
not the way a person does: the import line is not rewritten, it disappears whole. When the
|
|
74
|
+
list utilities were moved, imports vanished this way in six files out of eight, and the run
|
|
75
|
+
over the project list found them — the build of one application never reached these files.
|
|
75
76
|
|
|
76
77
|
```bash
|
|
77
|
-
npx nx run-many -t lint --projects
|
|
78
|
+
npx nx run-many -t lint --projects=<list by changed files>
|
|
78
79
|
```
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
This run is quick, hot on the heels of the move, and it never serves as the set before the
|
|
82
|
+
push: a set assembled by changed files skips what the edit reached through dependencies.
|
|
83
|
+
Before the push goes the same set the pipeline runs, by the same commands.
|
|
83
84
|
|
|
84
|
-
##
|
|
85
|
+
## Check
|
|
85
86
|
|
|
86
87
|
```bash
|
|
87
88
|
npm run check:layers
|
|
88
89
|
npm run check:dupes
|
|
89
90
|
```
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
The second is mandatory: a move is the very moment when a copy stays in the old place.
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
**Moved routes are checked by the screen, by the whole scenario: open the panel, close it, go
|
|
95
|
+
back with the browser.** The outlet address is assembled at runtime, and neither the linter, nor
|
|
96
|
+
the build, nor the layout check looks into it: a panel that stayed closed throws no error and
|
|
97
|
+
leaves the browser output clean. The three actions check three different places — opening takes
|
|
98
|
+
the command from the current route, closing goes from its parent, going back reads the address
|
|
99
|
+
from the browser history. After a move each of them breaks apart from the other two.
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
101
|
+
## Common misses
|
|
102
|
+
|
|
103
|
+
- A new address chosen without reading `docs/plans/` — drifts from the decision already made.
|
|
104
|
+
- The move order taken from the list in the plan — the boundaries have to be widened for a while.
|
|
105
|
+
- The README fixed in only one lib.
|
|
106
|
+
- Lint run over the application, not over the list of touched projects — vanished imports are
|
|
107
|
+
not seen.
|
|
108
|
+
- A copy left in the old place, and `check:dupes` not run.
|
|
@@ -2,81 +2,95 @@
|
|
|
2
2
|
name: lib-layers-new
|
|
3
3
|
kind: pattern
|
|
4
4
|
rule: lib-layers
|
|
5
|
-
description:
|
|
5
|
+
description: Pattern of rule lib-layers. Load when creating, renaming or removing a lib — the generator instead of bare nx g, the tag, the alias, the barrel, the README, and how to finish a removal. Moving code between existing libs — pattern lib-layers-move.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# Creating or removing a lib
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Pattern of the rule `lib-layers`. What must be true — the law
|
|
11
11
|
`docs/constitution/lib-imports.md`.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## When to use
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
15
|
+
- A new domain or a new layer of an existing domain is created.
|
|
16
|
+
- A lib is renamed.
|
|
17
|
+
- A lib is removed.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## First — is a lib needed at all
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
A domain has screens, state and requests. Mechanics shared by several domains is not started as
|
|
22
|
+
a domain: the layers under it would stay empty forever.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
The sign: if there is nothing to fill `feature`, `data-access` or `api` with — these are
|
|
25
|
+
utilities, and their place is the lib that already sees them. The frontend always has such a
|
|
26
|
+
lib — the family base; the backend — the `util` layer already listed with every domain.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
`project.json`, `vitest.config.mts`,
|
|
28
|
+
That is how the `list` domain lived as nine libs for three files of code: seven libs empty, and
|
|
29
|
+
each with its own `project.json`, `vitest.config.mts`, barrel, tag and alias.
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Created by the generator, not by bare `nx g`
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
34
|
node tools/generate-domain-lib.mjs
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
`nx run-many -t test`
|
|
40
|
-
|
|
37
|
+
The generator lays out `project.json`, `tsconfig.json`, `vitest.config.mts` and the barrel. Bare
|
|
38
|
+
`nx g` gives a vitest config without `passWithNoTests`, and a lib that has no tests yet fails
|
|
39
|
+
`nx run-many -t test` with the line "No test files found". The layout check looks at the
|
|
40
|
+
presence of the file, not at its content, so it lets such a lib through.
|
|
41
41
|
|
|
42
|
-
##
|
|
42
|
+
## What is added by hand
|
|
43
43
|
|
|
44
|
-
1.
|
|
45
|
-
|
|
46
|
-
2.
|
|
47
|
-
3. README
|
|
44
|
+
1. The tag in `eslint/boundaries/domains/<family>-<domain>.config.mjs` — one per lib, equal to
|
|
45
|
+
the name and the path.
|
|
46
|
+
2. The alias in `tsconfig.base.json`.
|
|
47
|
+
3. The lib's README: what lies in it and who calls it.
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
Rights to foreign libs are written out as lines with a comment saying why. An import that "just
|
|
50
|
+
worked" means the tag is not narrowed yet.
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## Removing and moving a lib
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
git rm -r libs
|
|
56
|
-
rm -rf libs
|
|
55
|
+
git rm -r libs/<family>/<domain>/<layer>
|
|
56
|
+
rm -rf libs/<family>/<domain>/<layer>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
`git rm -r`
|
|
60
|
-
|
|
59
|
+
`git rm -r` leaves `node_modules/.vite` inside the removed directory, and the layout check keeps
|
|
60
|
+
seeing it as a domain without layers. Finish with `rm -rf`.
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Then the tag, the alias and the rights lines of everyone who saw the lib are removed.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
**A move is the same action plus a graph reset.** A directory moved by `mv` is not recounted by
|
|
65
|
+
the builder's graph: the project stays in the cache under the old path, and under the new one it
|
|
66
|
+
does not exist at all.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
mv <old lib path> <new lib path>
|
|
70
|
+
npx nx reset
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Without the reset the run over all projects stays green and goes over one project fewer: it
|
|
74
|
+
takes the set from the graph cache, and the dropped project is no longer there. Such a run can
|
|
75
|
+
be told from a full one only by the number of projects in its output — it does not name the
|
|
76
|
+
missing one, and the miss lives until the first edit in the dropped lib.
|
|
77
|
+
|
|
78
|
+
## Check
|
|
65
79
|
|
|
66
80
|
```bash
|
|
67
81
|
npm run check:layers
|
|
68
82
|
```
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
`vitest.config.mts`
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
The check looks at the layers, the single tag = name = path, the alias, the presence of
|
|
85
|
+
`project.json`, `vitest.config.mts` and `src/index.ts`, the empty dependency list of
|
|
86
|
+
`common/util`, the family base boundaries and re-exports. Seconds — run after any creation,
|
|
87
|
+
rename or removal.
|
|
74
88
|
|
|
75
|
-
##
|
|
89
|
+
## Common misses
|
|
76
90
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
- A lib created for mechanics: the layers are empty and there is nothing to fill them with.
|
|
92
|
+
- Bare `nx g` — a vitest config without `passWithNoTests`, and the shared test run goes red.
|
|
93
|
+
- Removal without `rm -rf` — the check sees the ghost of a domain without layers.
|
|
94
|
+
- **A lib nobody imports is checked by nothing.** `nx lint` and `nx test` check the lib itself,
|
|
95
|
+
not its contract with the consumer. The first importer is the first check: the models layer is
|
|
96
|
+
accepted after `nx build` and a live run of the scenario, not by a green `lint test`.
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
name: observability-record
|
|
3
3
|
kind: pattern
|
|
4
4
|
rule: observability
|
|
5
|
-
description:
|
|
5
|
+
description: Pattern of rule observability. Load when a new log line is added in code — the ready-made logger call, choosing the level, the line name, fields as an object, an external service failure and the wait limit. Not for editing the logger itself and the request context — that is rule observability.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# A new log line
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Pattern of the rule `observability`. What must be true — the law
|
|
11
11
|
`docs/constitution/observability.md`.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## When to use
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
-
|
|
15
|
+
- A place appeared in the domain that the owner must learn about: an automatic step did not
|
|
16
|
+
fire, an external service refused, a procedure fell.
|
|
17
|
+
- One wants to put a `console.log` — a log line is put instead.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## The domain logger is taken once
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
22
|
const LOG_CONTEXT: string = 'PageCache';
|
|
@@ -28,49 +28,51 @@ constructor(logger: AppLoggerService) {
|
|
|
28
28
|
}
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
The context is set once and as a module constant, not as a literal in the call: neighbouring
|
|
32
|
+
classes of one domain write under the same source, and the failure selection judges exactly by
|
|
33
|
+
it. The request number, the procedure and who is in the system the logger substitutes itself —
|
|
34
|
+
there is no need to pass them as fields.
|
|
34
35
|
|
|
35
|
-
##
|
|
36
|
+
## The line name is constant, everything that changes goes into the fields
|
|
36
37
|
|
|
37
38
|
```ts
|
|
38
39
|
✓ this.#log.warn('cache.refresh.rejected', { url, attempt, status, durationMs });
|
|
39
40
|
✗ this.#log.warn(`cache refresh rejected for ${url} after ${attempt} attempts`);
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
The first argument is the line name, not a sentence. By it the lines about the same thing are
|
|
44
|
+
gathered together, and by it they collapse into one row of the failure feed. A value substituted
|
|
45
|
+
into the name makes every line unique.
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
The name is written with dots from the general to the particular: `cache.refresh.rejected`,
|
|
48
|
+
`mail.owner.skipped`.
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
—
|
|
50
|
-
|
|
50
|
+
The fields are scrubbed automatically. The line name passes scrubbing only on its way to the
|
|
51
|
+
failure store — in the output it is printed as is — so substituting values into it is forbidden
|
|
52
|
+
for this reason too.
|
|
51
53
|
|
|
52
|
-
##
|
|
54
|
+
## A lower-level line needs an entry in the selected list
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
The failure level and everything above it goes to the failure store by itself. A line of a lower
|
|
57
|
+
level gets there only if its name stands in the list of selected names. The list is compared by
|
|
58
|
+
the start of the name and edited by the same commit as the place that writes this line.
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
Forgot to append — the line stays only in the container output, and the owner never learns of it.
|
|
61
|
+
Nothing checks this.
|
|
60
62
|
|
|
61
|
-
##
|
|
63
|
+
## The level is chosen by whether something broke
|
|
62
64
|
|
|
63
|
-
|
|
|
64
|
-
| ----------- |
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
65
|
+
| Level | When |
|
|
66
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
67
|
+
| failure | the application did not do what it must: a procedure fell, a write to the storage did not go through |
|
|
68
|
+
| below | an automatic step did not fire: a translation, a cache refresh, a poll of an external service. Also a failure on input and rights |
|
|
69
|
+
| message | an action that took place and is worth knowing about: the call went through, the mail went out |
|
|
70
|
+
| detail | what is needed in an investigation and not needed in production |
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
A guest failing a check, a miss in a form and "not found" are the level below failure. The check
|
|
73
|
+
fired, the application works.
|
|
72
74
|
|
|
73
|
-
##
|
|
75
|
+
## An external service failure is written parsed
|
|
74
76
|
|
|
75
77
|
```ts
|
|
76
78
|
} catch (error: unknown) {
|
|
@@ -78,46 +80,49 @@ constructor(logger: AppLoggerService) {
|
|
|
78
80
|
}
|
|
79
81
|
```
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
Parsing the cause puts the class, the text, the code and a trimmed stack in one shape — the same as
|
|
84
|
+
the other failures have. Substituting the error into text (`` `failed: ${String(error)}` ``) is
|
|
85
|
+
forbidden: that way a foreign text goes into the log whole, together with the guest's address, key
|
|
86
|
+
or mail.
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
Mail is masked at the call site if it comes as a separate value: scrubbing recognises it by field
|
|
89
|
+
name, and a name like `to` does not look like mail.
|
|
87
90
|
|
|
88
|
-
##
|
|
91
|
+
## A failure comes only when the call has a wait limit
|
|
89
92
|
|
|
90
93
|
```ts
|
|
91
94
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
+
* Waiting for the rates source. The rate is a reference value and is refreshed once
|
|
96
|
+
* a day: five seconds of waiting with the previous rate in place is better than
|
|
97
|
+
* five minutes of a busy schedule.
|
|
95
98
|
*/
|
|
96
99
|
const RATES_TIMEOUT_MS: number = 5_000;
|
|
97
100
|
|
|
98
101
|
const response: Response = await fetch(RATES_URL, { signal: AbortSignal.timeout(RATES_TIMEOUT_MS) });
|
|
99
102
|
```
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
`catch`
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
104
|
+
Without a limit the connection to a silent service lives up to the environment default — minutes
|
|
105
|
+
— and all that time `catch` does not come: there is nothing to write. The number stands next to
|
|
106
|
+
the client with its own reason, because the price of waiting differs per service: a guest inside a
|
|
107
|
+
request waits differently from a night schedule.
|
|
108
|
+
|
|
109
|
+
## Common misses
|
|
110
|
+
|
|
111
|
+
- **The same line name stands in two places.** Then two different situations read as one. Either
|
|
112
|
+
the names differ, or the place is one.
|
|
113
|
+
- **`console.log` instead of a log line.** It has neither a level nor a request number, and it
|
|
114
|
+
does not get into the selection. In production it is a line nobody will see.
|
|
115
|
+
- **The level is chosen by how unpleasant it is.** A guest failing a check is unpleasant, but the
|
|
116
|
+
application works meanwhile.
|
|
117
|
+
- **The error is put into a field as is, without parsing the cause.** The error object serialises
|
|
118
|
+
into an empty `{}`, and neither the text nor the class is left in the log.
|
|
119
|
+
- **An unfilled part of the group key stands as an omission, not as an empty string.** Two
|
|
120
|
+
failures without a procedure and without a work subject must fall into one group; with an
|
|
121
|
+
omission in the key each opens its own, and the feed fills with single rows about the same
|
|
122
|
+
thing.
|
|
123
|
+
- **Identical failures that came at once give two groups.** Between "no such group yet" and the
|
|
124
|
+
insert the second one gets through, so the case is handled not by a check before the insert but
|
|
125
|
+
after the insert did not go through.
|
|
126
|
+
- **A log line name longer than the key limit is not written at all.** It is assembled by
|
|
127
|
+
substitution and limited by nothing, while the key has a limit: without trimming, a failure
|
|
128
|
+
with a long name is lost silently — no row in the feed, no failure in the logs.
|