dreamcycle 0.2.0__tar.gz
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.
- dreamcycle-0.2.0/.gitignore +13 -0
- dreamcycle-0.2.0/ARCHITECTURE.md +397 -0
- dreamcycle-0.2.0/AUTHORS.md +5 -0
- dreamcycle-0.2.0/CHANGELOG.md +24 -0
- dreamcycle-0.2.0/CONTRIBUTING.md +34 -0
- dreamcycle-0.2.0/LICENSE +201 -0
- dreamcycle-0.2.0/NOTICE +4 -0
- dreamcycle-0.2.0/PKG-INFO +498 -0
- dreamcycle-0.2.0/README.md +450 -0
- dreamcycle-0.2.0/SECURITY.md +26 -0
- dreamcycle-0.2.0/THIRD_PARTY.md +21 -0
- dreamcycle-0.2.0/docker-compose.yml +35 -0
- dreamcycle-0.2.0/docs/EXTRACTION_PLAN.md +295 -0
- dreamcycle-0.2.0/docs/IMPLEMENTATION_REVIEW.md +82 -0
- dreamcycle-0.2.0/docs/LICENSE_DECISION.md +31 -0
- dreamcycle-0.2.0/docs/PLAN_REVIEW.md +82 -0
- dreamcycle-0.2.0/docs/VENDOR_SDK.md +253 -0
- dreamcycle-0.2.0/docs/VENDOR_SDK_IMPLEMENTATION_REVIEW.md +112 -0
- dreamcycle-0.2.0/docs/VENDOR_SDK_PLAN.md +213 -0
- dreamcycle-0.2.0/docs/VENDOR_SDK_PLAN_REVIEW.md +112 -0
- dreamcycle-0.2.0/docs/report/DreamCycle_Technical_Thesis.md +290 -0
- dreamcycle-0.2.0/examples/basic_cycle.py +59 -0
- dreamcycle-0.2.0/examples/five_minute_memory.py +99 -0
- dreamcycle-0.2.0/examples/memory_only.py +34 -0
- dreamcycle-0.2.0/examples/openai_proxy.env.example +17 -0
- dreamcycle-0.2.0/examples/vendor_sdk.py +30 -0
- dreamcycle-0.2.0/pyproject.toml +102 -0
- dreamcycle-0.2.0/scripts/verify_distribution.py +51 -0
- dreamcycle-0.2.0/src/dreamcycle/__init__.py +48 -0
- dreamcycle-0.2.0/src/dreamcycle/adapters.py +159 -0
- dreamcycle-0.2.0/src/dreamcycle/cycle.py +377 -0
- dreamcycle-0.2.0/src/dreamcycle/dataset.py +125 -0
- dreamcycle-0.2.0/src/dreamcycle/errors.py +37 -0
- dreamcycle-0.2.0/src/dreamcycle/evaluation.py +36 -0
- dreamcycle-0.2.0/src/dreamcycle/events.py +55 -0
- dreamcycle-0.2.0/src/dreamcycle/memory/__init__.py +27 -0
- dreamcycle-0.2.0/src/dreamcycle/memory/base.py +33 -0
- dreamcycle-0.2.0/src/dreamcycle/memory/embeddings.py +91 -0
- dreamcycle-0.2.0/src/dreamcycle/memory/postgres.py +855 -0
- dreamcycle-0.2.0/src/dreamcycle/memory/schema.py +165 -0
- dreamcycle-0.2.0/src/dreamcycle/py.typed +1 -0
- dreamcycle-0.2.0/src/dreamcycle/sdk/__init__.py +12 -0
- dreamcycle-0.2.0/src/dreamcycle/sdk/client.py +192 -0
- dreamcycle-0.2.0/src/dreamcycle/sdk/models.py +72 -0
- dreamcycle-0.2.0/src/dreamcycle/server/__init__.py +42 -0
- dreamcycle-0.2.0/src/dreamcycle/server/app.py +261 -0
- dreamcycle-0.2.0/src/dreamcycle/server/auth.py +57 -0
- dreamcycle-0.2.0/src/dreamcycle/server/cli.py +44 -0
- dreamcycle-0.2.0/src/dreamcycle/server/jobs.py +131 -0
- dreamcycle-0.2.0/src/dreamcycle/server/memory.py +74 -0
- dreamcycle-0.2.0/src/dreamcycle/server/models.py +124 -0
- dreamcycle-0.2.0/src/dreamcycle/server/proxy.py +392 -0
- dreamcycle-0.2.0/src/dreamcycle/server/runtime.py +292 -0
- dreamcycle-0.2.0/src/dreamcycle/server/service.py +102 -0
- dreamcycle-0.2.0/src/dreamcycle/training/__init__.py +18 -0
- dreamcycle-0.2.0/src/dreamcycle/training/base.py +5 -0
- dreamcycle-0.2.0/src/dreamcycle/training/transformers.py +360 -0
- dreamcycle-0.2.0/src/dreamcycle/types.py +223 -0
- dreamcycle-0.2.0/tests/test_adapters.py +52 -0
- dreamcycle-0.2.0/tests/test_cycle.py +188 -0
- dreamcycle-0.2.0/tests/test_dataset.py +83 -0
- dreamcycle-0.2.0/tests/test_imports.py +25 -0
- dreamcycle-0.2.0/tests/test_jobs.py +90 -0
- dreamcycle-0.2.0/tests/test_memory_schema.py +103 -0
- dreamcycle-0.2.0/tests/test_postgres_integration.py +111 -0
- dreamcycle-0.2.0/tests/test_project_metadata.py +34 -0
- dreamcycle-0.2.0/tests/test_proxy.py +258 -0
- dreamcycle-0.2.0/tests/test_runtime_config.py +65 -0
- dreamcycle-0.2.0/tests/test_sdk.py +123 -0
- dreamcycle-0.2.0/tests/test_server_api.py +161 -0
- dreamcycle-0.2.0/tests/test_training_optional.py +20 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
# DreamCycle Architecture
|
|
2
|
+
|
|
3
|
+
DreamCycle is a **memory-native learning loop for local AI**. It lives beside a
|
|
4
|
+
vendor's application and model server, adding durable memory and guarded model
|
|
5
|
+
improvement without taking ownership of the entire platform.
|
|
6
|
+
|
|
7
|
+
Created by **Kenny Jin**.
|
|
8
|
+
|
|
9
|
+
## The Short Version
|
|
10
|
+
|
|
11
|
+
An application sends DreamCycle useful interactions. DreamCycle stores them as
|
|
12
|
+
scoped L2 memories, recalls relevant experience during later requests, and lets
|
|
13
|
+
people explicitly approve the best interactions for training. A dream cycle
|
|
14
|
+
builds a dataset, trains a candidate adapter, evaluates it, and changes the
|
|
15
|
+
active adapter only when the candidate passes the configured gates.
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
Memory makes the model useful across sessions.
|
|
19
|
+
Review makes the data intentional.
|
|
20
|
+
Evaluation makes improvement measurable.
|
|
21
|
+
Rollback makes promotion reversible.
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
DreamCycle improves behavior at three layers:
|
|
25
|
+
|
|
26
|
+
1. **Prompt lift:** retrieved memory changes the context sent to the next model
|
|
27
|
+
request.
|
|
28
|
+
2. **Local weight lift:** reviewed examples train and evaluate local adapters.
|
|
29
|
+
3. **Cloud dataset lift:** approved examples can be exported for provider-owned
|
|
30
|
+
cloud fine-tuning workflows.
|
|
31
|
+
|
|
32
|
+
The first layer can help any OpenAI-compatible endpoint immediately. The second
|
|
33
|
+
layer is directly implemented for local LoRA adapters. The third layer is an
|
|
34
|
+
integration boundary: DreamCycle can produce the reviewed dataset and provenance,
|
|
35
|
+
but the cloud provider still owns upload, hosted training, deployment, billing,
|
|
36
|
+
and model-version policy.
|
|
37
|
+
|
|
38
|
+
## System Map
|
|
39
|
+
|
|
40
|
+
```mermaid
|
|
41
|
+
flowchart TB
|
|
42
|
+
subgraph Vendor["Vendor platform"]
|
|
43
|
+
UI["Product UI, agent, or automation"]
|
|
44
|
+
Runtime["Existing local-model runtime"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
subgraph DreamCycle["DreamCycle add-on"]
|
|
48
|
+
Auth["API-key identity binding"]
|
|
49
|
+
API["Vendor memory API"]
|
|
50
|
+
Proxy["Chat Completions proxy"]
|
|
51
|
+
Memory["Scoped memory service"]
|
|
52
|
+
Jobs["Cycle job manager"]
|
|
53
|
+
Dataset["Reviewed dataset forge"]
|
|
54
|
+
Trainer["Local adapter trainer"]
|
|
55
|
+
Evaluator["Candidate arena"]
|
|
56
|
+
Adapters["Adapter vault and rollback"]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
PG[("PostgreSQL + pgvector")]
|
|
60
|
+
Embed["Local embedding model"]
|
|
61
|
+
Base["Local base model"]
|
|
62
|
+
|
|
63
|
+
UI -->|"SDK calls"| Auth
|
|
64
|
+
UI -->|"OpenAI-compatible request"| Auth
|
|
65
|
+
Auth --> API
|
|
66
|
+
Auth --> Proxy
|
|
67
|
+
API --> Memory
|
|
68
|
+
Proxy --> Memory
|
|
69
|
+
Memory <--> PG
|
|
70
|
+
Memory --> Embed
|
|
71
|
+
Proxy --> Runtime
|
|
72
|
+
API --> Jobs
|
|
73
|
+
Jobs --> Dataset
|
|
74
|
+
Dataset --> PG
|
|
75
|
+
Dataset --> Trainer
|
|
76
|
+
Trainer --> Base
|
|
77
|
+
Trainer --> Evaluator
|
|
78
|
+
Evaluator -->|"pass"| Adapters
|
|
79
|
+
Evaluator -->|"reject"| Jobs
|
|
80
|
+
Adapters -.->|"vendor loads active adapter"| Runtime
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Three Integration Shapes
|
|
84
|
+
|
|
85
|
+
### 1. Drop-In Proxy
|
|
86
|
+
|
|
87
|
+
Use this when the product already supports an OpenAI-compatible Chat
|
|
88
|
+
Completions base URL.
|
|
89
|
+
|
|
90
|
+
```mermaid
|
|
91
|
+
sequenceDiagram
|
|
92
|
+
participant App as Vendor application
|
|
93
|
+
participant DC as DreamCycle proxy
|
|
94
|
+
participant DB as PostgreSQL memory
|
|
95
|
+
participant LM as Local model server
|
|
96
|
+
|
|
97
|
+
App->>DC: POST /v1/chat/completions
|
|
98
|
+
DC->>DC: Bind API key to namespace and user
|
|
99
|
+
opt Retrieve mode
|
|
100
|
+
DC->>DB: Vector recall using latest user text
|
|
101
|
+
DB-->>DC: Scoped L2 memories
|
|
102
|
+
DC->>DC: Add bounded untrusted memory context
|
|
103
|
+
end
|
|
104
|
+
DC->>LM: Forward request with separate upstream key
|
|
105
|
+
LM-->>DC: Completion or SSE stream
|
|
106
|
+
DC-->>App: Preserve model response
|
|
107
|
+
DC->>DB: Atomically store completed user and assistant turn
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The inbound DreamCycle key never goes to the model server. Retrieval or
|
|
111
|
+
post-response recording failures do not erase an otherwise successful model
|
|
112
|
+
response. A stopped proxy is still an availability failure, because an extra
|
|
113
|
+
network hop cannot fail open when the hop itself is gone.
|
|
114
|
+
|
|
115
|
+
### 2. Vendor SDK
|
|
116
|
+
|
|
117
|
+
Use this when the Python platform wants explicit control.
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
DreamCycleClient
|
|
121
|
+
health()
|
|
122
|
+
record()
|
|
123
|
+
record_turn()
|
|
124
|
+
recall()
|
|
125
|
+
review()
|
|
126
|
+
delete()
|
|
127
|
+
start_cycle()
|
|
128
|
+
cycle_status()
|
|
129
|
+
active_adapter()
|
|
130
|
+
rollback_adapter()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The SDK talks only to the sidecar contract. It does not need to import the
|
|
134
|
+
vendor's inference engine or know how its UI works.
|
|
135
|
+
|
|
136
|
+
### 3. Embedded Engine
|
|
137
|
+
|
|
138
|
+
Use this when the host is already Python and does not want another process.
|
|
139
|
+
|
|
140
|
+
```mermaid
|
|
141
|
+
flowchart LR
|
|
142
|
+
Host["Python host process"] --> Memory["PostgresMemory"]
|
|
143
|
+
Host --> Cycle["DreamCycle"]
|
|
144
|
+
Memory <--> PG[("PostgreSQL + pgvector")]
|
|
145
|
+
Cycle --> Trainer["Vendor or built-in trainer"]
|
|
146
|
+
Cycle --> Evaluator["Vendor or built-in evaluator"]
|
|
147
|
+
Cycle --> Adapter["AdapterManager"]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
HTTP, embedding, and training dependencies remain optional. Importing the core
|
|
151
|
+
package does not load those stacks.
|
|
152
|
+
|
|
153
|
+
## Model Improvement Layers
|
|
154
|
+
|
|
155
|
+
```mermaid
|
|
156
|
+
flowchart TB
|
|
157
|
+
Input["Completed interaction"] --> Memory["Scoped L2/L3 memory"]
|
|
158
|
+
|
|
159
|
+
Memory --> Recall["Prompt lift"]
|
|
160
|
+
Recall --> Compatible["Local or OpenAI-compatible endpoint"]
|
|
161
|
+
|
|
162
|
+
Memory --> Review["Human review gate"]
|
|
163
|
+
Review --> Dataset["Approved train/eval dataset"]
|
|
164
|
+
Dataset --> LocalTrain["Local LoRA adapter training"]
|
|
165
|
+
LocalTrain --> Eval["Evaluation gate"]
|
|
166
|
+
Eval -->|"pass"| Promote["Promote local adapter"]
|
|
167
|
+
Eval -->|"fail"| Reject["Keep current adapter"]
|
|
168
|
+
|
|
169
|
+
Dataset -.-> CloudHandoff["Provider dataset handoff"]
|
|
170
|
+
CloudHandoff -.-> Provider["Official cloud fine-tuning workflow"]
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
DreamCycle directly owns memory, review state, dataset assembly, local adapter
|
|
174
|
+
training, evaluation, and local promotion. It does not directly mutate hosted
|
|
175
|
+
model weights. For cloud models, DreamCycle's role is to make the prompt better
|
|
176
|
+
through recall and to make the fine-tuning input cleaner when a vendor chooses
|
|
177
|
+
to use a provider's official training pipeline.
|
|
178
|
+
|
|
179
|
+
## Memory Model
|
|
180
|
+
|
|
181
|
+
DreamCycle treats memory as two related layers rather than one giant prompt
|
|
182
|
+
history.
|
|
183
|
+
|
|
184
|
+
```mermaid
|
|
185
|
+
flowchart LR
|
|
186
|
+
Turn["Completed interaction"] --> L2["L2 episodic memory"]
|
|
187
|
+
L2 --> Recall["Vector recall"]
|
|
188
|
+
L2 --> Review["Human review decision"]
|
|
189
|
+
L2 -->|"provenance"| L3["L3 durable knowledge"]
|
|
190
|
+
Review -->|"approved"| Dataset["Training candidate"]
|
|
191
|
+
Review -->|"rejected"| Stop["Excluded from training"]
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### L2: Episodic Memory
|
|
195
|
+
|
|
196
|
+
L2 stores what happened:
|
|
197
|
+
|
|
198
|
+
- user and assistant content;
|
|
199
|
+
- role and source;
|
|
200
|
+
- conversation and trace identity;
|
|
201
|
+
- importance and success state;
|
|
202
|
+
- review and training approval state;
|
|
203
|
+
- classification and metadata;
|
|
204
|
+
- local embedding and distance score.
|
|
205
|
+
|
|
206
|
+
The user and assistant sides of a completed turn are written in one PostgreSQL
|
|
207
|
+
transaction. Captured assistant turns begin with `reviewed=false` and
|
|
208
|
+
`approved_for_training=false`.
|
|
209
|
+
|
|
210
|
+
### L3: Durable Knowledge
|
|
211
|
+
|
|
212
|
+
L3 stores what the system has intentionally distilled:
|
|
213
|
+
|
|
214
|
+
- vector-searchable knowledge nodes;
|
|
215
|
+
- typed relationships between nodes;
|
|
216
|
+
- confidence and metadata;
|
|
217
|
+
- provenance links back to L2 memories.
|
|
218
|
+
|
|
219
|
+
L3 promotion rejects source IDs outside the current namespace and user scope.
|
|
220
|
+
This keeps a durable claim connected to the evidence that produced it.
|
|
221
|
+
|
|
222
|
+
## Identity Is a Server Decision
|
|
223
|
+
|
|
224
|
+
```mermaid
|
|
225
|
+
flowchart LR
|
|
226
|
+
KeyA["API key A"] --> Alice["namespace: product / user: alice"]
|
|
227
|
+
KeyB["API key B"] --> Bob["namespace: product / user: bob"]
|
|
228
|
+
Alice --> RowsA["Alice memory rows"]
|
|
229
|
+
Bob --> RowsB["Bob memory rows"]
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The API key map lives in sidecar configuration. Request bodies do not contain a
|
|
233
|
+
trusted namespace or user override. Unknown body fields are rejected, and every
|
|
234
|
+
PostgreSQL memory query includes both scope values.
|
|
235
|
+
|
|
236
|
+
This is intentionally simpler than asking every vendor endpoint to reproduce a
|
|
237
|
+
tenant policy system.
|
|
238
|
+
|
|
239
|
+
## The Guarded Dream Cycle
|
|
240
|
+
|
|
241
|
+
The cycle is a model-improvement state machine, not a promise that every fine
|
|
242
|
+
tune deserves promotion.
|
|
243
|
+
|
|
244
|
+
```mermaid
|
|
245
|
+
stateDiagram-v2
|
|
246
|
+
[*] --> Queued
|
|
247
|
+
Queued --> DatasetBuild: worker starts
|
|
248
|
+
DatasetBuild --> Skipped: insufficient reviewed data
|
|
249
|
+
DatasetBuild --> Training: valid train and evaluation split
|
|
250
|
+
Training --> Failed: trainer error
|
|
251
|
+
Training --> Benchmark: candidate adapter produced
|
|
252
|
+
Benchmark --> Rejected: quality gate fails
|
|
253
|
+
Benchmark --> Shadow: shadow evaluation configured
|
|
254
|
+
Benchmark --> Promotion: benchmark passes
|
|
255
|
+
Shadow --> Rejected: shadow gate fails
|
|
256
|
+
Shadow --> Promotion: shadow gate passes
|
|
257
|
+
Promotion --> Completed: active pointer updated
|
|
258
|
+
Promotion --> Failed: atomic activation fails
|
|
259
|
+
Skipped --> [*]
|
|
260
|
+
Rejected --> [*]
|
|
261
|
+
Completed --> [*]
|
|
262
|
+
Failed --> [*]
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Dataset Forge
|
|
266
|
+
|
|
267
|
+
Only successful assistant memories that are explicitly reviewed and approved
|
|
268
|
+
can become candidates. Whole conversations stay on one side of the train and
|
|
269
|
+
held-out evaluation split to reduce leakage.
|
|
270
|
+
|
|
271
|
+
### Candidate Arena
|
|
272
|
+
|
|
273
|
+
The built-in evaluator compares candidate and baseline perplexity. Products can
|
|
274
|
+
replace it with an evaluator that measures coding accuracy, tool selection,
|
|
275
|
+
classification quality, policy adherence, or another domain-specific target.
|
|
276
|
+
|
|
277
|
+
### Adapter Vault
|
|
278
|
+
|
|
279
|
+
Promotion copies a candidate into a versioned directory and atomically updates
|
|
280
|
+
the active pointer. The previous pointer gives the operator one-step rollback.
|
|
281
|
+
Candidate and active paths are constrained to configured roots.
|
|
282
|
+
|
|
283
|
+
## Failure Semantics
|
|
284
|
+
|
|
285
|
+
DreamCycle tries to make failure boring and visible.
|
|
286
|
+
|
|
287
|
+
| Failure | Behavior |
|
|
288
|
+
|---|---|
|
|
289
|
+
| Bad or missing sidecar key | `401`; no memory operation |
|
|
290
|
+
| Namespace/user override in body | Validation error |
|
|
291
|
+
| Missing proxy configuration | `503`; no fake inference success |
|
|
292
|
+
| Upstream connection unavailable | Bounded `502` |
|
|
293
|
+
| Memory recall fails during proxying | Model request continues without recalled context |
|
|
294
|
+
| Memory write fails after model success | Model response remains valid; warning/log is emitted |
|
|
295
|
+
| Stream ends before `[DONE]` | Partial assistant output is not stored as complete |
|
|
296
|
+
| Cycle already active for identity | `409`; no competing local cycle |
|
|
297
|
+
| Training is not configured | `503`; no fake queued job |
|
|
298
|
+
| Candidate fails evaluation | Rejected; active adapter is unchanged |
|
|
299
|
+
| Promotion fails | Failed report; active pointer is not relabeled as success |
|
|
300
|
+
|
|
301
|
+
## Process and Deployment Boundaries
|
|
302
|
+
|
|
303
|
+
```mermaid
|
|
304
|
+
flowchart TB
|
|
305
|
+
subgraph TrustedHost["Trusted local host or private network"]
|
|
306
|
+
App["Vendor application"]
|
|
307
|
+
DC["DreamCycle sidecar"]
|
|
308
|
+
LM["Local model server"]
|
|
309
|
+
DB[("PostgreSQL + pgvector")]
|
|
310
|
+
Models["Local embedding and base models"]
|
|
311
|
+
Data["Per-identity adapter data"]
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
App --> DC
|
|
315
|
+
DC --> LM
|
|
316
|
+
DC --> DB
|
|
317
|
+
DC --> Models
|
|
318
|
+
DC --> Data
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
The sidecar binds to loopback by default. DreamCycle does not provide TLS
|
|
322
|
+
termination, rate limiting, dynamic key reload, or a hosted control plane in
|
|
323
|
+
0.2.0. Operators exposing it beyond a trusted host must add those controls.
|
|
324
|
+
|
|
325
|
+
Cycle jobs and same-identity locks are process-local. They are truthful for one
|
|
326
|
+
sidecar process but are not a distributed scheduler and do not survive restart.
|
|
327
|
+
|
|
328
|
+
## Package Boundaries
|
|
329
|
+
|
|
330
|
+
```text
|
|
331
|
+
dreamcycle/
|
|
332
|
+
adapters.py atomic promotion and rollback
|
|
333
|
+
cycle.py guarded orchestration state machine
|
|
334
|
+
dataset.py reviewed dataset construction
|
|
335
|
+
evaluation.py quality and shadow gates
|
|
336
|
+
memory/
|
|
337
|
+
postgres.py direct L2 and L3 PostgreSQL owner
|
|
338
|
+
embeddings.py local or application-owned embeddings
|
|
339
|
+
schema.py pgvector schema and indexes
|
|
340
|
+
sdk/
|
|
341
|
+
client.py synchronous vendor SDK
|
|
342
|
+
models.py dependency-light SDK results
|
|
343
|
+
server/
|
|
344
|
+
auth.py API-key identity binding
|
|
345
|
+
app.py HTTP contract
|
|
346
|
+
jobs.py asynchronous cycle state
|
|
347
|
+
proxy.py Chat Completions forwarding and capture
|
|
348
|
+
runtime.py environment composition
|
|
349
|
+
service.py transport-independent operations
|
|
350
|
+
training/
|
|
351
|
+
transformers.py optional Transformers and PEFT implementation
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
One module owns one cohesive responsibility. Core imports remain independent of
|
|
355
|
+
FastAPI, HTTPX, Transformers, PEFT, and PyTorch until those features are
|
|
356
|
+
explicitly requested.
|
|
357
|
+
|
|
358
|
+
## What DreamCycle Does Not Own
|
|
359
|
+
|
|
360
|
+
- The vendor's UI, agent framework, or product workflow.
|
|
361
|
+
- The local model server and its availability.
|
|
362
|
+
- Consent, retention, deletion, and permission to train.
|
|
363
|
+
- Model licensing or rights to collected data.
|
|
364
|
+
- Cloud fine-tuning uploads, hosted training jobs, deployment, billing, and
|
|
365
|
+
model-version policy.
|
|
366
|
+
- Production TLS, external authentication, and network policy.
|
|
367
|
+
- Loading the promoted adapter into every possible inference runtime.
|
|
368
|
+
- Proof that a generic metric represents the vendor's real product quality.
|
|
369
|
+
|
|
370
|
+
Those boundaries are deliberate. DreamCycle should be useful as an add-on,
|
|
371
|
+
not become another platform a vendor has to rebuild around.
|
|
372
|
+
|
|
373
|
+
## Design Principles
|
|
374
|
+
|
|
375
|
+
1. **Local first:** model data and model paths stay local by default.
|
|
376
|
+
2. **Scope every memory operation:** identity comes from trusted configuration.
|
|
377
|
+
3. **Review before training:** observation is not consent to fine-tune.
|
|
378
|
+
4. **Evaluate before promotion:** training success is not quality evidence.
|
|
379
|
+
5. **Preserve rollback:** model changes should be reversible.
|
|
380
|
+
6. **Keep failures truthful:** no queued, routed, or partial state becomes fake
|
|
381
|
+
success.
|
|
382
|
+
7. **Stay vendor-neutral:** protocols and HTTP contracts beat framework lock-in.
|
|
383
|
+
8. **Separate prompt lift from weight lift:** recalled context can improve
|
|
384
|
+
behavior immediately, while training and promotion remain explicit workflows.
|
|
385
|
+
|
|
386
|
+
## Current Limits
|
|
387
|
+
|
|
388
|
+
- Chat compatibility is limited to `POST /v1/chat/completions`.
|
|
389
|
+
- The SDK is synchronous in 0.2.0.
|
|
390
|
+
- Cycle state is in process and non-durable.
|
|
391
|
+
- Local model servers may differ in undocumented compatibility behavior.
|
|
392
|
+
- Cloud model fine-tuning is export/integration work, not an automatic hosted
|
|
393
|
+
provider call in the core package.
|
|
394
|
+
- Real model quality depends on the data, base model, evaluator, and hardware.
|
|
395
|
+
|
|
396
|
+
These limits are tracked openly because a credible learning system needs clear
|
|
397
|
+
boundaries as much as it needs ambitious terminology.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to DreamCycle are documented here.
|
|
4
|
+
|
|
5
|
+
## 0.2.0 - 2026-07-16
|
|
6
|
+
|
|
7
|
+
- Added the authenticated vendor SDK and standalone memory sidecar.
|
|
8
|
+
- Added observe and retrieve modes for an OpenAI-compatible Chat Completions proxy.
|
|
9
|
+
- Added asynchronous dream-cycle jobs and adapter status/rollback endpoints.
|
|
10
|
+
- Relicensed the unreleased project from MIT to Apache-2.0 and added `NOTICE`.
|
|
11
|
+
- Added a product-focused README and GitHub-rendered architecture guide.
|
|
12
|
+
- Added a Docker Compose five-minute memory quickstart.
|
|
13
|
+
- Added PyPI trusted publishing through GitHub Actions.
|
|
14
|
+
- Standardized public attribution to Kenny Jin.
|
|
15
|
+
|
|
16
|
+
## 0.1.0 - 2026-07-16
|
|
17
|
+
|
|
18
|
+
- Extracted the Dream Cycle orchestration into an independent Python package.
|
|
19
|
+
- Added direct PostgreSQL/pgvector L2 episodic memory.
|
|
20
|
+
- Added L3 knowledge nodes, relationships, and L2 provenance.
|
|
21
|
+
- Added deterministic reviewed-memory train/evaluation dataset generation.
|
|
22
|
+
- Added guarded adapter evaluation, promotion, and rollback.
|
|
23
|
+
- Added optional Transformers/PEFT LoRA training and perplexity evaluation.
|
|
24
|
+
- Added typed events, reports, examples, tests, and initial project metadata.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contributions should keep DreamCycle independent, local-first, and truthful
|
|
4
|
+
about model quality.
|
|
5
|
+
|
|
6
|
+
## Development Setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
python3 -m venv .venv
|
|
10
|
+
.venv/bin/python -m pip install -e '.[dev]'
|
|
11
|
+
.venv/bin/python -m pytest
|
|
12
|
+
.venv/bin/python -m ruff check .
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The development extra includes the SDK and sidecar test stack. Install
|
|
16
|
+
`.[training]` only when changing the Transformers/PEFT implementation. Use a
|
|
17
|
+
small local Hugging Face model for manual checks; tests must not download models
|
|
18
|
+
or require a GPU.
|
|
19
|
+
|
|
20
|
+
## Change Requirements
|
|
21
|
+
|
|
22
|
+
- Keep one module responsible for one coherent behavior.
|
|
23
|
+
- Preserve namespace and user-scope filters in every database query.
|
|
24
|
+
- Never accept namespace or user scope from an authenticated sidecar request.
|
|
25
|
+
- Never forward the inbound DreamCycle API key to a model server.
|
|
26
|
+
- Add tests for success, rejection, and real failure paths.
|
|
27
|
+
- Do not add cloud egress, model uploads, or credential persistence by default.
|
|
28
|
+
- Do not add AGPL dependencies.
|
|
29
|
+
- Do not report training completion as model improvement without evaluator
|
|
30
|
+
evidence.
|
|
31
|
+
- Update public docs and the changelog when behavior changes.
|
|
32
|
+
|
|
33
|
+
PostgreSQL integration tests require `DREAMCYCLE_TEST_DSN`. They create and
|
|
34
|
+
remove a unique test schema.
|
dreamcycle-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
dreamcycle-0.2.0/NOTICE
ADDED