@oleksandr.rudnychenko/sync_loop 0.2.5 → 0.3.2
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 +25 -4
- package/bin/cli.js +3 -128
- package/bin/cli.ts +171 -0
- package/dist/bin/cli.d.ts +15 -0
- package/dist/bin/cli.js +137 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/src/init.d.ts +24 -0
- package/dist/src/init.js +410 -0
- package/dist/src/init.js.map +1 -0
- package/dist/src/server.d.ts +13 -0
- package/dist/src/server.js +265 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/template/.agent-loop/README.md +75 -0
- package/dist/src/template/.agent-loop/feedback.md +395 -0
- package/dist/src/template/.agent-loop/glossary.md +113 -0
- package/dist/src/template/.agent-loop/patterns/api-standards.md +132 -0
- package/dist/src/template/.agent-loop/patterns/code-patterns.md +300 -0
- package/dist/src/template/.agent-loop/patterns/refactoring-workflow.md +114 -0
- package/dist/src/template/.agent-loop/patterns/testing-guide.md +258 -0
- package/dist/src/template/.agent-loop/patterns.md +256 -0
- package/dist/src/template/.agent-loop/reasoning-kernel.md +521 -0
- package/dist/src/template/.agent-loop/validate-env.md +332 -0
- package/dist/src/template/.agent-loop/validate-n.md +321 -0
- package/dist/src/template/AGENTS.md +157 -0
- package/dist/src/template/README.md +144 -0
- package/dist/src/template/bootstrap-prompt.md +37 -0
- package/dist/src/template/protocol-summary.md +54 -0
- package/dist/src/template/wiring/agents-claude.md +203 -0
- package/dist/src/template/wiring/agents-github.md +211 -0
- package/dist/src/template/wiring/api-standards.md +15 -0
- package/dist/src/template/wiring/code-patterns.md +15 -0
- package/dist/src/template/wiring/feedback.md +18 -0
- package/dist/src/template/wiring/glossary.md +11 -0
- package/dist/src/template/wiring/patterns.md +18 -0
- package/dist/src/template/wiring/reasoning-kernel.md +18 -0
- package/dist/src/template/wiring/refactoring-workflow.md +15 -0
- package/dist/src/template/wiring/testing-guide.md +15 -0
- package/dist/src/template/wiring/validate-env.md +17 -0
- package/dist/src/template/wiring/validate-n.md +17 -0
- package/package.json +48 -34
- package/src/template/wiring/agents-claude.md +203 -0
- package/src/template/wiring/agents-github.md +211 -0
- package/src/template/wiring/api-standards.md +15 -0
- package/src/template/wiring/code-patterns.md +15 -0
- package/src/template/wiring/feedback.md +18 -0
- package/src/template/wiring/glossary.md +11 -0
- package/src/template/wiring/patterns.md +18 -0
- package/src/template/wiring/reasoning-kernel.md +18 -0
- package/src/template/wiring/refactoring-workflow.md +15 -0
- package/src/template/wiring/testing-guide.md +15 -0
- package/src/template/wiring/validate-env.md +17 -0
- package/src/template/wiring/validate-n.md +17 -0
- package/src/init.js +0 -569
- package/src/server.js +0 -292
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Pattern Registry & Routing Index
|
|
2
|
+
|
|
3
|
+
Central pattern index for GKP routing and LEARN persistence.
|
|
4
|
+
Referenced from [reasoning-kernel.md](reasoning-kernel.md).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Pattern Families
|
|
9
|
+
|
|
10
|
+
| IDs | Family | Primary Spec |
|
|
11
|
+
|-----|--------|--------------|
|
|
12
|
+
| **P1–P11** | Core code architecture patterns | [patterns/code-patterns.md](patterns/code-patterns.md) |
|
|
13
|
+
| **R1–R3** | Refactoring, testing, and API quality patterns | [patterns/refactoring-workflow.md](patterns/refactoring-workflow.md), [patterns/testing-guide.md](patterns/testing-guide.md), [patterns/api-standards.md](patterns/api-standards.md) |
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Architecture Baseline
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
Routes → Services → Repositories → Libs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
{Replace with actual project layers during bootstrap.}
|
|
24
|
+
|
|
25
|
+
### Layer Intent
|
|
26
|
+
- **Routes**: Transport/boundary only. No business logic.
|
|
27
|
+
- **Services**: Business orchestration. Domain logic lives here.
|
|
28
|
+
- **Repositories**: Data access contracts.
|
|
29
|
+
- **Libs**: Infrastructure utilities. No imports from app modules.
|
|
30
|
+
|
|
31
|
+
### Non-Bypass Rules
|
|
32
|
+
- Never import across incompatible layers
|
|
33
|
+
- Never bypass the service layer from transport handlers
|
|
34
|
+
- Never change public APIs without explicit approval
|
|
35
|
+
|
|
36
|
+
{Add project-specific non-bypass rules here.}
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Core Code Patterns (P1–P11)
|
|
41
|
+
|
|
42
|
+
> Full spec with examples → [patterns/code-patterns.md](patterns/code-patterns.md)
|
|
43
|
+
|
|
44
|
+
#### P1 · Port/Adapter
|
|
45
|
+
|
|
46
|
+
Infrastructure abstraction via interface protocols (ports) with concrete implementations (adapters).
|
|
47
|
+
|
|
48
|
+
**Use when:** Adding external service · Swapping infrastructure impl · Writing tests that mock I/O · Reviewing layer boundary compliance · Creating a new infrastructure package
|
|
49
|
+
|
|
50
|
+
#### P2 · Domain Module
|
|
51
|
+
|
|
52
|
+
Standard multi-file layout for each business domain. Enforces separation of concerns within features.
|
|
53
|
+
|
|
54
|
+
**Use when:** Creating a new feature module · Adding a file to existing module · Checking module completeness · Reviewing cross-module dependencies · Moving logic out of routes into services
|
|
55
|
+
|
|
56
|
+
#### P3 · Background Task Boundary
|
|
57
|
+
|
|
58
|
+
Async background processing with runtime dependency injection. Task handlers stay thin; business logic lives in services.
|
|
59
|
+
|
|
60
|
+
**Use when:** Adding a background processing task · Debugging task dependency injection · Understanding task status tracking · Reviewing task error handling and retry logic
|
|
61
|
+
|
|
62
|
+
#### P4 · App Context / Composition Root
|
|
63
|
+
|
|
64
|
+
Global dependency container initialized once at startup. Provides config, session factory, and shared services.
|
|
65
|
+
|
|
66
|
+
**Use when:** Understanding runtime dependency wiring · Adding a new global dependency · Debugging initialization errors · Writing test fixtures that reset global state
|
|
67
|
+
|
|
68
|
+
#### P5 · Transport Route
|
|
69
|
+
|
|
70
|
+
Boundary endpoints using dependency injection for service access. Routes contain only transport concerns.
|
|
71
|
+
|
|
72
|
+
**Use when:** Adding a new endpoint · Wiring a service into a route · Reviewing route-to-service boundary · Adding request/response validation
|
|
73
|
+
|
|
74
|
+
#### P6 · Typed Models
|
|
75
|
+
|
|
76
|
+
Domain entities with explicit types, default factories for collections, and serialization methods.
|
|
77
|
+
|
|
78
|
+
**Use when:** Defining a new entity or value object · Adding fields to existing model · Reviewing serialization behavior · Deciding model type (dataclass vs schema model)
|
|
79
|
+
|
|
80
|
+
#### P7 · Collection/Enum Safety
|
|
81
|
+
|
|
82
|
+
Type-safe namespace references replacing magic strings with enums/constants.
|
|
83
|
+
|
|
84
|
+
**Use when:** Adding a new namespace/collection · Debugging name mismatches · Reviewing normalization logic
|
|
85
|
+
|
|
86
|
+
#### P8 · Error Handling
|
|
87
|
+
|
|
88
|
+
Layered exception hierarchy: domain base → specific errors. Routes catch domain errors and map to transport status codes.
|
|
89
|
+
|
|
90
|
+
**Use when:** Adding error handling · Defining domain exceptions · Mapping service errors to transport responses · Reviewing error propagation across layers
|
|
91
|
+
|
|
92
|
+
#### P9 · Type Hints Everywhere
|
|
93
|
+
|
|
94
|
+
All functions require complete type annotations: parameters, returns, generics. No bare `Any` without justification.
|
|
95
|
+
|
|
96
|
+
**Use when:** Writing any new function · Fixing type checker errors · Reviewing type completeness · Using project-specific type aliases
|
|
97
|
+
|
|
98
|
+
#### P10 · Service Orchestration
|
|
99
|
+
|
|
100
|
+
Services accept all dependencies via constructor. No hidden imports or global access in service methods.
|
|
101
|
+
|
|
102
|
+
**Use when:** Creating a new service · Making a service testable · Wiring mocks in test fixtures · Reviewing service constructor signatures
|
|
103
|
+
|
|
104
|
+
#### P11 · Config Isolation
|
|
105
|
+
|
|
106
|
+
Environment-based config with centralized source and startup validation.
|
|
107
|
+
|
|
108
|
+
**Use when:** Adding environment variable · Understanding config overrides · Debugging config initialization
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Process Patterns (R1–R3)
|
|
113
|
+
|
|
114
|
+
#### R1 · Refactoring Workflow
|
|
115
|
+
|
|
116
|
+
4-phase checklist for safe file moves, import changes, and module restructuring.
|
|
117
|
+
|
|
118
|
+
**Use when:** Moving a file · Renaming a module · Splitting a large file · Merging modules · Running post-refactor validation
|
|
119
|
+
|
|
120
|
+
**Spec:** [patterns/refactoring-workflow.md](patterns/refactoring-workflow.md)
|
|
121
|
+
|
|
122
|
+
#### R2 · Testing Guide
|
|
123
|
+
|
|
124
|
+
Test patterns covering the full test pyramid with fixtures, factories, mocks, and parameterized tests.
|
|
125
|
+
|
|
126
|
+
**Use when:** Writing a new test · Setting up fixtures · Creating mock adapters · Deciding test layer · Reviewing naming conventions · Structuring parameterized tests
|
|
127
|
+
|
|
128
|
+
**Spec:** [patterns/testing-guide.md](patterns/testing-guide.md)
|
|
129
|
+
|
|
130
|
+
#### R3 · API / Boundary Standards
|
|
131
|
+
|
|
132
|
+
Documentation and contract requirements for boundary endpoints: typed models, docstrings, schema generation.
|
|
133
|
+
|
|
134
|
+
**Use when:** Adding a new endpoint · Documenting existing routes · Reviewing response models · Generating or updating specs
|
|
135
|
+
|
|
136
|
+
**Spec:** [patterns/api-standards.md](patterns/api-standards.md)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## GKP Routing Table
|
|
141
|
+
|
|
142
|
+
| If task involves… | Use IDs | Read this first |
|
|
143
|
+
|-------------------|---------|-----------------|
|
|
144
|
+
| Ports/adapters and layering | P1, P2, P10 | [patterns/code-patterns.md](patterns/code-patterns.md) |
|
|
145
|
+
| Task orchestration/runtime composition | P3, P4 | [patterns/code-patterns.md](patterns/code-patterns.md) |
|
|
146
|
+
| Boundary contracts and typing | P5, P6, P9 | [patterns/code-patterns.md](patterns/code-patterns.md) |
|
|
147
|
+
| Error policies and config safety | P8, P11 | [patterns/code-patterns.md](patterns/code-patterns.md) |
|
|
148
|
+
| File moves and API-safe refactors | R1 | [patterns/refactoring-workflow.md](patterns/refactoring-workflow.md) |
|
|
149
|
+
| Verification strategy | R2 | [patterns/testing-guide.md](patterns/testing-guide.md) |
|
|
150
|
+
| Interface docs/schema discipline | R3 | [patterns/api-standards.md](patterns/api-standards.md) |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Artifact Placement
|
|
155
|
+
|
|
156
|
+
### Application Code
|
|
157
|
+
|
|
158
|
+
| Artifact Type | Location |
|
|
159
|
+
|---------------|----------|
|
|
160
|
+
| Domain models | `{modules}/{domain}/models.*` |
|
|
161
|
+
| Business services | `{modules}/{domain}/services.*` |
|
|
162
|
+
| Transport routes | `{modules}/{domain}/routes.*` |
|
|
163
|
+
| Infrastructure ports | `{libs}/{component}/port.*` |
|
|
164
|
+
| Infrastructure adapters | `{libs}/{component}/{impl}.*` |
|
|
165
|
+
| Utilities | `{libs}/utils/` |
|
|
166
|
+
|
|
167
|
+
### Tests
|
|
168
|
+
|
|
169
|
+
| Test Type | Location | Purpose |
|
|
170
|
+
|-----------|----------|---------|
|
|
171
|
+
| Unit | `tests/unit/test_{component}.*` | Pure logic, no I/O |
|
|
172
|
+
| Integration | `tests/integration/test_{feature}.*` | Multi-component workflows |
|
|
173
|
+
| API/Endpoint | `tests/api/test_{endpoint}.*` | Transport endpoint tests |
|
|
174
|
+
| Fixtures | `tests/conftest.*` | Shared test fixtures |
|
|
175
|
+
| Factories | `tests/factories.*` | Test data builders |
|
|
176
|
+
| Mocks | `tests/mocks.*` | Mock adapters |
|
|
177
|
+
|
|
178
|
+
### Documentation & Agent Loop
|
|
179
|
+
|
|
180
|
+
| Doc Type | Location |
|
|
181
|
+
|----------|----------|
|
|
182
|
+
| Architecture overview | `docs/ARCHITECTURE.md` |
|
|
183
|
+
| Engineering reports | `docs/reports/YYYY-MM-DD-*.md` |
|
|
184
|
+
| Report artifacts | `docs/reports/artifacts/` |
|
|
185
|
+
| Pattern index + learned fixes | `.agent-loop/patterns.md` |
|
|
186
|
+
| Pattern detail specs | `.agent-loop/patterns/*.md` |
|
|
187
|
+
| Domain terminology | `.agent-loop/glossary.md` |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Naming Anti-Patterns
|
|
192
|
+
|
|
193
|
+
| Anti-Pattern | Correct Approach | Reason |
|
|
194
|
+
|--------------|------------------|--------|
|
|
195
|
+
| `*_v1.py`, `*_v2.py` | Update existing or rename clearly | Git handles versions |
|
|
196
|
+
| `*_new.py`, `*_old.py` | Refactor into `*_next.py` then swap | "New" becomes old quickly |
|
|
197
|
+
| `test_*_v2.py` | `test_<original_name>.py` | 1:1 mapping to source module |
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Learned Patterns (LEARN writes here)
|
|
202
|
+
|
|
203
|
+
### Auto-Fixes
|
|
204
|
+
|
|
205
|
+
| Trigger | Root Cause | Minimal Safe Fix | Auto-Apply |
|
|
206
|
+
|---------|------------|------------------|------------|
|
|
207
|
+
| Missing explicit return type | Signature drift | Add concrete return annotation | ✅ |
|
|
208
|
+
| Stray debug artifact | Temporary local instrumentation left in patch | Remove or replace with standard logging | ✅ |
|
|
209
|
+
| Caller mismatch after rename | Incomplete refactor propagation | Update all known call sites before merge | ⚠️ |
|
|
210
|
+
|
|
211
|
+
### Common Errors
|
|
212
|
+
|
|
213
|
+
| Symptom | Why It Happens | Prevention Heuristic |
|
|
214
|
+
|---------|----------------|----------------------|
|
|
215
|
+
| Gate keeps failing with small patch changes | Symptoms fixed, not root cause | Patch the first cause in dependency chain |
|
|
216
|
+
| Neighbor break after “safe” refactor | Consumer map incomplete | Run validate-n immediately after structural edits |
|
|
217
|
+
| Quality regressions in fast fixes | No targeted test sequence | Start with narrow tests, then expand |
|
|
218
|
+
|
|
219
|
+
### Heuristics
|
|
220
|
+
|
|
221
|
+
| Do More | Do Less |
|
|
222
|
+
|---------|---------|
|
|
223
|
+
| Compress context into explicit constraints | Carry large raw snippets forward |
|
|
224
|
+
| Validate boundaries early | Delay compatibility checks |
|
|
225
|
+
| Keep patches reversible | Mix refactor and feature changes together |
|
|
226
|
+
|
|
227
|
+
### Pruning Records
|
|
228
|
+
|
|
229
|
+
Populated by [feedback.md §Branch Pruning Protocol](feedback.md) during the LEARN phase when a failed approach is pruned.
|
|
230
|
+
|
|
231
|
+
| Attempt | Strategy | Failure Reason | Constraint Added |
|
|
232
|
+
|---------|----------|----------------|------------------|
|
|
233
|
+
| — | — | — | — |
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Pattern Addition Policy
|
|
238
|
+
|
|
239
|
+
Add a new pattern when all are true:
|
|
240
|
+
1. The approach is reusable across multiple tasks
|
|
241
|
+
2. It reduces failure recurrence
|
|
242
|
+
3. It has clear constraints and examples
|
|
243
|
+
|
|
244
|
+
Write location:
|
|
245
|
+
- Short rule: table in this file
|
|
246
|
+
- Deep implementation: dedicated section/file under `patterns/`
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Related Documents
|
|
251
|
+
|
|
252
|
+
| Document | Purpose |
|
|
253
|
+
|----------|---------|
|
|
254
|
+
| [reasoning-kernel.md](reasoning-kernel.md) | End-to-end protocol and mode selection |
|
|
255
|
+
| [feedback.md](feedback.md) | Failure-to-learning bridge |
|
|
256
|
+
| [glossary.md](glossary.md) | Canonical naming and ambiguity resolution |
|