@plures/praxis 2.0.0 → 2.0.3
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 +164 -1067
- package/dist/browser/{chunk-6MVRT7CK.js → chunk-IUEKGHQN.js} +13 -3
- package/dist/browser/index.js +1 -1
- package/dist/browser/unified/index.js +1 -1
- package/dist/node/{chunk-6MVRT7CK.js → chunk-IUEKGHQN.js} +13 -3
- package/dist/node/index.cjs +13 -3
- package/dist/node/index.js +1 -1
- package/dist/node/unified/index.cjs +13 -3
- package/dist/node/unified/index.js +1 -1
- package/docs/README.md +58 -102
- package/docs/archive/1.x/CONVERSATIONS_IMPLEMENTATION.md +207 -0
- package/docs/archive/1.x/DECISION_LEDGER_IMPLEMENTATION.md +109 -0
- package/docs/archive/1.x/DECISION_LEDGER_SUMMARY.md +424 -0
- package/docs/archive/1.x/ELEVATION_SUMMARY.md +249 -0
- package/docs/archive/1.x/FEATURE_SUMMARY.md +238 -0
- package/docs/archive/1.x/GOLDEN_PATH_IMPLEMENTATION.md +280 -0
- package/docs/archive/1.x/IMPLEMENTATION.md +166 -0
- package/docs/archive/1.x/IMPLEMENTATION_COMPLETE.md +389 -0
- package/docs/archive/1.x/IMPLEMENTATION_SUMMARY.md +59 -0
- package/docs/archive/1.x/INTEGRATION_ENHANCEMENT_SUMMARY.md +238 -0
- package/docs/archive/1.x/KNO_ENG_REFACTORING_SUMMARY.md +198 -0
- package/docs/archive/1.x/MONOREPO_SUMMARY.md +158 -0
- package/docs/archive/1.x/README.md +28 -0
- package/docs/archive/1.x/SVELTE_INTEGRATION_SUMMARY.md +415 -0
- package/docs/archive/1.x/TASK_1_COMPLETE.md +235 -0
- package/docs/archive/1.x/TASK_1_SUMMARY.md +281 -0
- package/docs/archive/1.x/VERSION_0.2.0_RELEASE_NOTES.md +288 -0
- package/docs/archive/1.x/ValidationChecklist.md +7 -0
- package/package.json +11 -5
- package/src/unified/__tests__/unified-qa.test.ts +761 -0
- package/src/unified/core.ts +19 -2
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Praxis v0.2 — Golden Path Implementation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document summarizes the implementation of the Praxis v0.2 "Golden Path" — a complete pipeline from schema definition to runnable application.
|
|
6
|
+
|
|
7
|
+
## What Was Implemented
|
|
8
|
+
|
|
9
|
+
### 1. Schema System (✅ Complete)
|
|
10
|
+
|
|
11
|
+
**Files:**
|
|
12
|
+
|
|
13
|
+
- `src/core/schema/types.ts` (existing, already complete)
|
|
14
|
+
- `src/core/schema/loader.ts` (new)
|
|
15
|
+
- `src/core/schema/normalize.ts` (new)
|
|
16
|
+
|
|
17
|
+
**Features:**
|
|
18
|
+
|
|
19
|
+
- Schema validation with clear error messages
|
|
20
|
+
- Schema loading from JavaScript files
|
|
21
|
+
- Schema normalization with model resolution
|
|
22
|
+
- Reference expansion and dependency tracking
|
|
23
|
+
|
|
24
|
+
### 2. Code Generators (✅ Complete)
|
|
25
|
+
|
|
26
|
+
**Logic Generator** (`src/core/logic/generator.ts`)
|
|
27
|
+
|
|
28
|
+
- Generates `facts.ts` with typed fact definitions
|
|
29
|
+
- Generates `events.ts` with typed event definitions
|
|
30
|
+
- Generates `rules.ts` with rule scaffolds and TODOs
|
|
31
|
+
- Generates `engine.ts` with context types and engine setup
|
|
32
|
+
- Generates `index.ts` for convenient imports
|
|
33
|
+
|
|
34
|
+
**Component Generator** (`src/core/component/generator.ts`)
|
|
35
|
+
|
|
36
|
+
- Already existed, integrated into pipeline
|
|
37
|
+
- Generates Svelte components from schema
|
|
38
|
+
- Includes TypeScript types and documentation
|
|
39
|
+
- Supports form, list, display, and custom components
|
|
40
|
+
|
|
41
|
+
**PluresDB Generator** (`src/core/pluresdb/generator.ts`)
|
|
42
|
+
|
|
43
|
+
- Generates database configuration
|
|
44
|
+
- Creates stores for each model
|
|
45
|
+
- Defines indexes based on schema
|
|
46
|
+
- Supports sync configuration
|
|
47
|
+
|
|
48
|
+
### 3. CLI Command (✅ Complete)
|
|
49
|
+
|
|
50
|
+
**File:** `src/cli/commands/generate.ts`
|
|
51
|
+
|
|
52
|
+
**Usage:**
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Generate all code from schema
|
|
56
|
+
praxis generate --schema praxis.schema.js
|
|
57
|
+
|
|
58
|
+
# Generate specific target
|
|
59
|
+
praxis generate --schema praxis.schema.js --target logic
|
|
60
|
+
praxis generate --schema praxis.schema.js --target components
|
|
61
|
+
praxis generate --schema praxis.schema.js --target pluresdb
|
|
62
|
+
|
|
63
|
+
# Custom output directory
|
|
64
|
+
praxis generate --schema praxis.schema.js --output ./src/generated
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Features:**
|
|
68
|
+
|
|
69
|
+
- Loads and validates schema
|
|
70
|
+
- Normalizes schema for generation
|
|
71
|
+
- Generates all artifacts or specific targets
|
|
72
|
+
- Clear progress output with ✓ checkmarks
|
|
73
|
+
- Helpful error messages
|
|
74
|
+
|
|
75
|
+
### 4. Tests (✅ Complete)
|
|
76
|
+
|
|
77
|
+
**Schema Tests** (`src/__tests__/schema.test.ts`)
|
|
78
|
+
|
|
79
|
+
- 8 tests covering validation and normalization
|
|
80
|
+
- Tests schema templates
|
|
81
|
+
- Tests model dependency resolution
|
|
82
|
+
- Tests component-model resolution
|
|
83
|
+
|
|
84
|
+
**Generator Tests** (`src/__tests__/generators.test.ts`)
|
|
85
|
+
|
|
86
|
+
- 12 tests covering all generators
|
|
87
|
+
- Tests logic file generation
|
|
88
|
+
- Tests component generation
|
|
89
|
+
- Tests PluresDB config generation
|
|
90
|
+
- Tests options and configuration
|
|
91
|
+
|
|
92
|
+
**Test Results:**
|
|
93
|
+
|
|
94
|
+
- 83 total tests passing
|
|
95
|
+
- 8 test files
|
|
96
|
+
- No failing tests
|
|
97
|
+
- No security vulnerabilities (CodeQL clean)
|
|
98
|
+
|
|
99
|
+
### 5. Example Application (✅ Complete)
|
|
100
|
+
|
|
101
|
+
**Location:** `examples/simple-app/`
|
|
102
|
+
|
|
103
|
+
**Contents:**
|
|
104
|
+
|
|
105
|
+
- `praxis.schema.js` - Complete TodoApp schema
|
|
106
|
+
- `README.md` - Comprehensive guide
|
|
107
|
+
- Generated code demonstrating full pipeline
|
|
108
|
+
|
|
109
|
+
**Schema Includes:**
|
|
110
|
+
|
|
111
|
+
- Models: Todo with typed fields
|
|
112
|
+
- Components: TodoForm, TodoList, TodoItem
|
|
113
|
+
- Logic: Events, facts, rules, and constraints
|
|
114
|
+
- Full CRUD operations
|
|
115
|
+
|
|
116
|
+
## Generated Code Structure
|
|
117
|
+
|
|
118
|
+
When you run `praxis generate`, you get:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
generated/
|
|
122
|
+
├── logic/
|
|
123
|
+
│ ├── facts.ts # Typed fact definitions
|
|
124
|
+
│ ├── events.ts # Typed event definitions
|
|
125
|
+
│ ├── rules.ts # Rule implementations (with TODOs)
|
|
126
|
+
│ ├── engine.ts # Engine setup with context types
|
|
127
|
+
│ └── index.ts # Convenient exports
|
|
128
|
+
├── components/
|
|
129
|
+
│ ├── [Component].svelte # Svelte component
|
|
130
|
+
│ ├── [Component].types.ts # TypeScript types
|
|
131
|
+
│ └── [Component].md # Documentation
|
|
132
|
+
└── pluresdb-config.ts # Database configuration
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Example Workflow
|
|
136
|
+
|
|
137
|
+
### 1. Define Schema
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
// praxis.schema.js
|
|
141
|
+
export const schema = {
|
|
142
|
+
version: '1.0.0',
|
|
143
|
+
name: 'MyApp',
|
|
144
|
+
models: [
|
|
145
|
+
{
|
|
146
|
+
name: 'User',
|
|
147
|
+
fields: [
|
|
148
|
+
{ name: 'id', type: 'string' },
|
|
149
|
+
{ name: 'name', type: 'string' },
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
components: [
|
|
154
|
+
{
|
|
155
|
+
name: 'UserForm',
|
|
156
|
+
type: 'form',
|
|
157
|
+
model: 'User',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
logic: [
|
|
161
|
+
{
|
|
162
|
+
id: 'user-logic',
|
|
163
|
+
events: [{ tag: 'CREATE_USER', payload: { name: 'string' } }],
|
|
164
|
+
facts: [{ tag: 'UserCreated', payload: { userId: 'string' } }],
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 2. Generate Code
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
praxis generate --schema praxis.schema.js
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Output:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
✓ Schema loaded successfully
|
|
180
|
+
✓ Schema normalized
|
|
181
|
+
✓ Logic module generated
|
|
182
|
+
✓ Components generated
|
|
183
|
+
✓ PluresDB config generated
|
|
184
|
+
✅ Generation complete! 12 files generated.
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 3. Use Generated Code
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { createEngine } from './generated/logic/engine.js';
|
|
191
|
+
import { CREATE_USER } from './generated/logic/events.js';
|
|
192
|
+
|
|
193
|
+
const engine = createEngine();
|
|
194
|
+
const result = engine.step([CREATE_USER.create({ name: 'Alice' })]);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Technical Decisions
|
|
198
|
+
|
|
199
|
+
### TypeScript Compilation
|
|
200
|
+
|
|
201
|
+
- Schema files must be JavaScript (.js) or pre-compiled TypeScript
|
|
202
|
+
- This avoids runtime TypeScript compilation complexity
|
|
203
|
+
- Users can compile their schemas with `tsc` if needed
|
|
204
|
+
|
|
205
|
+
### Code Generation Strategy
|
|
206
|
+
|
|
207
|
+
- Generate complete but minimal code
|
|
208
|
+
- Include helpful TODOs where manual work is needed
|
|
209
|
+
- Preserve existing patterns (e.g., defineFact, defineEvent)
|
|
210
|
+
- Type-safe by default
|
|
211
|
+
|
|
212
|
+
### File Organization
|
|
213
|
+
|
|
214
|
+
- Separate files for facts, events, rules
|
|
215
|
+
- Single engine.ts for setup and types
|
|
216
|
+
- Components get separate files per component
|
|
217
|
+
- PluresDB config in single file
|
|
218
|
+
|
|
219
|
+
## Validation & Safety
|
|
220
|
+
|
|
221
|
+
### Schema Validation
|
|
222
|
+
|
|
223
|
+
- Required fields checked (version, name, models)
|
|
224
|
+
- Model fields validated
|
|
225
|
+
- Clear error messages with paths
|
|
226
|
+
|
|
227
|
+
### Generation Validation
|
|
228
|
+
|
|
229
|
+
- Checks for at least one model
|
|
230
|
+
- Validates model fields
|
|
231
|
+
- Type-safe TypeScript output
|
|
232
|
+
|
|
233
|
+
### Security
|
|
234
|
+
|
|
235
|
+
- CodeQL scan: 0 vulnerabilities
|
|
236
|
+
- No eval or dynamic code execution
|
|
237
|
+
- Pure file generation from AST
|
|
238
|
+
|
|
239
|
+
## Next Steps (Future Work)
|
|
240
|
+
|
|
241
|
+
1. **Watch Mode**: Implement file watching for auto-regeneration
|
|
242
|
+
2. **TypeScript Schemas**: Add tsx loader for .ts schema files
|
|
243
|
+
3. **Incremental Generation**: Only regenerate changed files
|
|
244
|
+
4. **Templates**: Custom code templates
|
|
245
|
+
5. **Migrations**: Schema version migrations
|
|
246
|
+
6. **Visual Editor**: CodeCanvas integration
|
|
247
|
+
|
|
248
|
+
## Breaking Changes
|
|
249
|
+
|
|
250
|
+
None - this is a new feature set.
|
|
251
|
+
|
|
252
|
+
## Migration Guide
|
|
253
|
+
|
|
254
|
+
No migration needed. This is v0.2 adding new functionality.
|
|
255
|
+
|
|
256
|
+
## Documentation
|
|
257
|
+
|
|
258
|
+
- Schema types: `src/core/schema/types.ts`
|
|
259
|
+
- Usage examples: `examples/simple-app/README.md`
|
|
260
|
+
- Test examples: `src/__tests__/schema.test.ts`
|
|
261
|
+
|
|
262
|
+
## Metrics
|
|
263
|
+
|
|
264
|
+
- **Files Added**: 8 new source files
|
|
265
|
+
- **Lines of Code**: ~2,500 lines
|
|
266
|
+
- **Tests Added**: 20 new tests
|
|
267
|
+
- **Test Coverage**: All new code tested
|
|
268
|
+
- **Build Time**: <5 seconds
|
|
269
|
+
- **Generation Time**: <1 second
|
|
270
|
+
|
|
271
|
+
## Conclusion
|
|
272
|
+
|
|
273
|
+
The Praxis v0.2 Golden Path is complete and functional. Developers can now:
|
|
274
|
+
|
|
275
|
+
1. Define a schema in JavaScript
|
|
276
|
+
2. Run `praxis generate`
|
|
277
|
+
3. Get complete logic modules, components, and database config
|
|
278
|
+
4. Build and run their application
|
|
279
|
+
|
|
280
|
+
This establishes Praxis as a true full-stack framework with a schema-driven development workflow.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Praxis Implementation Summary
|
|
2
|
+
|
|
3
|
+
This document summarizes the initial implementation of the Praxis TypeScript library.
|
|
4
|
+
|
|
5
|
+
## What Was Implemented
|
|
6
|
+
|
|
7
|
+
### Core Architecture
|
|
8
|
+
|
|
9
|
+
1. **Language-Neutral Protocol** (`src/core/protocol.ts`)
|
|
10
|
+
- `PraxisFact` - Typed propositions about the domain
|
|
11
|
+
- `PraxisEvent` - Temporally ordered facts for state changes
|
|
12
|
+
- `PraxisState` - Current state with context and facts
|
|
13
|
+
- `PraxisStepFn` - Pure, deterministic step function
|
|
14
|
+
- JSON-friendly types for cross-language compatibility
|
|
15
|
+
|
|
16
|
+
2. **Rules and Constraints System** (`src/core/rules.ts`)
|
|
17
|
+
- `RuleFn` - Pure functions that derive new facts
|
|
18
|
+
- `ConstraintFn` - Predicates that check invariants
|
|
19
|
+
- `PraxisRegistry` - Registry for rules and constraints with stable IDs
|
|
20
|
+
- `PraxisModule` - Bundles of rules and constraints
|
|
21
|
+
|
|
22
|
+
3. **Logic Engine** (`src/core/engine.ts`)
|
|
23
|
+
- `LogicEngine<TContext>` - Main engine with strongly-typed context
|
|
24
|
+
- `createPraxisEngine` - Factory function
|
|
25
|
+
- Pure, immutable state updates
|
|
26
|
+
- Automatic rule application and constraint checking
|
|
27
|
+
|
|
28
|
+
4. **Actor System** (`src/core/actors.ts`)
|
|
29
|
+
- `Actor<TContext>` - Interface for effectful units
|
|
30
|
+
- `ActorManager` - Lifecycle management for actors
|
|
31
|
+
- `createTimerActor` - Helper for timer-based actors
|
|
32
|
+
- Bridge between pure logic and side effects
|
|
33
|
+
|
|
34
|
+
### DSL and Helpers
|
|
35
|
+
|
|
36
|
+
5. **DSL Helpers** (`src/dsl/index.ts`)
|
|
37
|
+
- `defineFact<TTag, TPayload>` - Define typed facts with type guards
|
|
38
|
+
- `defineEvent<TTag, TPayload>` - Define typed events with type guards
|
|
39
|
+
- `defineRule` - Define rules with descriptors
|
|
40
|
+
- `defineConstraint` - Define constraints with descriptors
|
|
41
|
+
- `defineModule` - Bundle rules and constraints
|
|
42
|
+
- Helper functions: `findEvent`, `findFact`, `filterEvents`, `filterFacts`
|
|
43
|
+
|
|
44
|
+
### Integrations
|
|
45
|
+
|
|
46
|
+
6. **Svelte v5 Integration** (`src/integrations/svelte.ts`)
|
|
47
|
+
- `createPraxisStore` - Convert engine to Svelte store
|
|
48
|
+
- `createContextStore` - Extract context as store
|
|
49
|
+
- `createDerivedStore` - Derive specific values from context
|
|
50
|
+
- Reactive bindings for Svelte v5
|
|
51
|
+
|
|
52
|
+
7. **PluresDB Integration** (`src/integrations/pluresdb.ts`)
|
|
53
|
+
- Placeholder implementation
|
|
54
|
+
- Interface definitions for future event sourcing
|
|
55
|
+
- Designed for reactive queries and subscriptions
|
|
56
|
+
|
|
57
|
+
### Examples
|
|
58
|
+
|
|
59
|
+
8. **Auth Basic Example** (`src/examples/auth-basic/`)
|
|
60
|
+
- Login/logout logic with facts and events
|
|
61
|
+
- Session management
|
|
62
|
+
- Constraint checking for single sessions
|
|
63
|
+
- Demonstrates basic Praxis usage
|
|
64
|
+
|
|
65
|
+
9. **Cart Example** (`src/examples/cart/`)
|
|
66
|
+
- Shopping cart with multiple items
|
|
67
|
+
- Discount application
|
|
68
|
+
- Complex state derivation
|
|
69
|
+
- Multiple rules and constraints
|
|
70
|
+
- Module composition
|
|
71
|
+
|
|
72
|
+
10. **Svelte Counter Example** (`src/examples/svelte-counter/`)
|
|
73
|
+
- Simple counter with increment/decrement
|
|
74
|
+
- Svelte v5 store integration
|
|
75
|
+
- Reactive state updates
|
|
76
|
+
- History tracking
|
|
77
|
+
|
|
78
|
+
### Testing
|
|
79
|
+
|
|
80
|
+
11. **Test Suite** (`src/__tests__/`)
|
|
81
|
+
- Protocol type tests
|
|
82
|
+
- DSL helper tests
|
|
83
|
+
- Engine integration tests
|
|
84
|
+
- 18 tests, all passing
|
|
85
|
+
- Coverage of core functionality
|
|
86
|
+
|
|
87
|
+
### Documentation
|
|
88
|
+
|
|
89
|
+
12. **README.md**
|
|
90
|
+
- Comprehensive introduction
|
|
91
|
+
- Core concepts explanation
|
|
92
|
+
- Quick start guide
|
|
93
|
+
- API reference
|
|
94
|
+
- Future directions
|
|
95
|
+
- Examples and usage patterns
|
|
96
|
+
|
|
97
|
+
13. **Package Configuration**
|
|
98
|
+
- `package.json` - NPM package metadata
|
|
99
|
+
- `tsconfig.json` - TypeScript configuration
|
|
100
|
+
- `vitest.config.ts` - Test configuration
|
|
101
|
+
- `.gitignore` - Git ignore rules
|
|
102
|
+
- `.npmignore` - NPM publish exclusions
|
|
103
|
+
- `LICENSE` - MIT License
|
|
104
|
+
|
|
105
|
+
## Design Principles Implemented
|
|
106
|
+
|
|
107
|
+
✓ **Strong typing and functional programming**
|
|
108
|
+
|
|
109
|
+
- All core types are strongly typed
|
|
110
|
+
- Rules and constraints are pure functions
|
|
111
|
+
- Immutable state updates
|
|
112
|
+
|
|
113
|
+
✓ **Logic-first architecture**
|
|
114
|
+
|
|
115
|
+
- User-facing API expressed in terms of facts, events, rules, constraints
|
|
116
|
+
- FSMs are an internal implementation detail
|
|
117
|
+
|
|
118
|
+
✓ **Language-agnostic core protocol**
|
|
119
|
+
|
|
120
|
+
- JSON-friendly types
|
|
121
|
+
- Pure, deterministic step function
|
|
122
|
+
- Designed for future C#, PowerShell support
|
|
123
|
+
|
|
124
|
+
✓ **Provable, analyzable, testable**
|
|
125
|
+
|
|
126
|
+
- Pure functions easy to test
|
|
127
|
+
- Comprehensive test coverage
|
|
128
|
+
- Type-safe at compile time
|
|
129
|
+
|
|
130
|
+
✓ **Ecosystem integration ready**
|
|
131
|
+
|
|
132
|
+
- Svelte v5 integration implemented
|
|
133
|
+
- PluresDB integration placeholder
|
|
134
|
+
- Extensible actor system
|
|
135
|
+
|
|
136
|
+
## Build and Test Status
|
|
137
|
+
|
|
138
|
+
- ✅ TypeScript compilation succeeds
|
|
139
|
+
- ✅ All 18 tests pass
|
|
140
|
+
- ✅ Type checking passes (strict mode)
|
|
141
|
+
- ✅ Examples run successfully
|
|
142
|
+
- ✅ Ready for npm publish
|
|
143
|
+
|
|
144
|
+
## Next Steps
|
|
145
|
+
|
|
146
|
+
1. Enhance examples to demonstrate more complex flows
|
|
147
|
+
2. Implement PluresDB integration
|
|
148
|
+
3. Add visualization tools (state graphs, rule graphs)
|
|
149
|
+
4. Create ADP static analysis integration
|
|
150
|
+
5. Develop C# and PowerShell bindings
|
|
151
|
+
6. Add property-based testing
|
|
152
|
+
7. Create documentation site
|
|
153
|
+
8. Build code-canvas integration
|
|
154
|
+
|
|
155
|
+
## File Statistics
|
|
156
|
+
|
|
157
|
+
- Total source files: 11
|
|
158
|
+
- Total test files: 3
|
|
159
|
+
- Lines of TypeScript: ~1,500+
|
|
160
|
+
- Examples: 3
|
|
161
|
+
- Integrations: 2
|
|
162
|
+
- Core modules: 4
|
|
163
|
+
|
|
164
|
+
## API Stability
|
|
165
|
+
|
|
166
|
+
The core protocol (`PraxisFact`, `PraxisEvent`, `PraxisState`, `PraxisStepFn`) is designed to be stable and is the foundation for cross-language support. Higher-level TypeScript APIs may evolve but will maintain backward compatibility where possible.
|