@plures/praxis 1.2.10 → 1.2.11
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 +83 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -239,6 +239,67 @@ npx praxis generate --schema src/schemas/app.schema.ts
|
|
|
239
239
|
npx praxis canvas src/schemas/app.schema.ts
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
+
## Decision Ledger (Behavior Contracts)
|
|
243
|
+
|
|
244
|
+
Document, validate, and track the evolution of your rules and constraints with explicit behavioral contracts.
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
import { defineContract, defineRule } from '@plures/praxis';
|
|
248
|
+
|
|
249
|
+
// Define a contract with explicit behavior, examples, and invariants
|
|
250
|
+
const loginContract = defineContract({
|
|
251
|
+
ruleId: 'auth.login',
|
|
252
|
+
behavior: 'Process login events and create user session facts',
|
|
253
|
+
examples: [
|
|
254
|
+
{
|
|
255
|
+
given: 'User provides valid credentials',
|
|
256
|
+
when: 'LOGIN event is received',
|
|
257
|
+
then: 'UserSessionCreated fact is emitted'
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
invariants: ['Session must have unique ID'],
|
|
261
|
+
assumptions: [
|
|
262
|
+
{
|
|
263
|
+
id: 'assume-unique-username',
|
|
264
|
+
statement: 'Usernames are unique across the system',
|
|
265
|
+
confidence: 0.9,
|
|
266
|
+
justification: 'Standard authentication practice',
|
|
267
|
+
impacts: ['spec', 'tests', 'code'],
|
|
268
|
+
status: 'active'
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Attach contract to rule
|
|
274
|
+
const loginRule = defineRule({
|
|
275
|
+
id: 'auth.login',
|
|
276
|
+
description: 'Process login events',
|
|
277
|
+
impl: (state, events) => { /* ... */ },
|
|
278
|
+
contract: loginContract
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Validate contracts in CI/CD:**
|
|
283
|
+
```bash
|
|
284
|
+
# Validate all contracts
|
|
285
|
+
npx praxis validate --strict
|
|
286
|
+
|
|
287
|
+
# Generate SARIF for GitHub Actions
|
|
288
|
+
npx praxis validate --output sarif > results.sarif
|
|
289
|
+
|
|
290
|
+
# Reverse engineer contracts from existing code
|
|
291
|
+
npx praxis reverse --interactive
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Key features:**
|
|
295
|
+
- ✅ Explicit behavior documentation with Given/When/Then examples
|
|
296
|
+
- ✅ Assumption tracking with confidence levels
|
|
297
|
+
- ✅ Immutable ledger for change history
|
|
298
|
+
- ✅ Build-time validation and CI/CD integration
|
|
299
|
+
- ✅ Auto-generation from existing code
|
|
300
|
+
|
|
301
|
+
See [src/decision-ledger/README.md](./src/decision-ledger/README.md) for complete documentation.
|
|
302
|
+
|
|
242
303
|
## Exports map
|
|
243
304
|
- `@plures/praxis` → main engine (ESM/CJS/types)
|
|
244
305
|
- `@plures/praxis/svelte` → Svelte 5 integrations
|
|
@@ -251,6 +312,7 @@ npx praxis canvas src/schemas/app.schema.ts
|
|
|
251
312
|
## Documentation
|
|
252
313
|
- [Getting Started](./GETTING_STARTED.md)
|
|
253
314
|
- [Framework Guide](./FRAMEWORK.md)
|
|
315
|
+
- [Decision Ledger Guide](./src/decision-ledger/README.md)
|
|
254
316
|
- [Examples](./examples/)
|
|
255
317
|
|
|
256
318
|
## Contributing
|
|
@@ -570,6 +632,27 @@ Demonstrates real-time synchronization with Praxis Cloud relay service.
|
|
|
570
632
|
|
|
571
633
|
See [examples/cloud-sync/README.md](./examples/cloud-sync/README.md)
|
|
572
634
|
|
|
635
|
+
### 13. Decision Ledger (`examples/decision-ledger`)
|
|
636
|
+
|
|
637
|
+
Demonstrates behavior contracts for rules and constraints with validation and immutable ledger tracking.
|
|
638
|
+
|
|
639
|
+
Features:
|
|
640
|
+
- Contract definition with behavior, examples, and invariants
|
|
641
|
+
- Assumption tracking with confidence levels
|
|
642
|
+
- Validation and reporting (console, JSON, SARIF)
|
|
643
|
+
- Immutable logic ledger for change history
|
|
644
|
+
- CLI integration for CI/CD pipelines
|
|
645
|
+
|
|
646
|
+
```bash
|
|
647
|
+
npm run build
|
|
648
|
+
node examples/decision-ledger/index.js
|
|
649
|
+
|
|
650
|
+
# Validate contracts
|
|
651
|
+
npx praxis validate --registry examples/sample-registry.js
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
See [examples/decision-ledger/README.md](./examples/decision-ledger/README.md)
|
|
655
|
+
|
|
573
656
|
## API Reference
|
|
574
657
|
|
|
575
658
|
### Core Types
|
package/package.json
CHANGED