@plures/praxis 1.2.0 → 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 +93 -96
- package/dist/browser/{adapter-TM4IS5KT.js → adapter-CIMBGDC7.js} +5 -3
- package/dist/browser/{chunk-LE2ZJYFC.js → chunk-K377RW4V.js} +76 -0
- package/dist/{node/chunk-JQ64KMLN.js → browser/chunk-MBVHLOU2.js} +12 -1
- package/dist/browser/index.d.ts +32 -5
- package/dist/browser/index.js +15 -7
- package/dist/browser/integrations/svelte.d.ts +2 -2
- package/dist/browser/integrations/svelte.js +1 -1
- package/dist/browser/{reactive-engine.svelte-C9OpcTHf.d.ts → reactive-engine.svelte-9aS0kTa8.d.ts} +136 -1
- package/dist/node/{adapter-K6DOX6XS.js → adapter-75ISSMWD.js} +5 -3
- package/dist/node/chunk-5RH7UAQC.js +486 -0
- package/dist/{browser/chunk-JQ64KMLN.js → node/chunk-MBVHLOU2.js} +12 -1
- package/dist/node/{chunk-LE2ZJYFC.js → chunk-PRPQO6R5.js} +3 -72
- package/dist/node/chunk-R2PSBPKQ.js +150 -0
- package/dist/node/chunk-WZ6B3LZ6.js +638 -0
- package/dist/node/cli/index.cjs +2316 -832
- package/dist/node/cli/index.js +18 -0
- package/dist/node/components/index.d.cts +3 -2
- package/dist/node/components/index.d.ts +3 -2
- package/dist/node/index.cjs +620 -38
- package/dist/node/index.d.cts +259 -5
- package/dist/node/index.d.ts +259 -5
- package/dist/node/index.js +55 -65
- package/dist/node/integrations/svelte.cjs +76 -0
- package/dist/node/integrations/svelte.d.cts +2 -2
- package/dist/node/integrations/svelte.d.ts +2 -2
- package/dist/node/integrations/svelte.js +2 -1
- package/dist/node/{reactive-engine.svelte-1M4m_C_v.d.cts → reactive-engine.svelte-BFIZfawz.d.cts} +199 -1
- package/dist/node/{reactive-engine.svelte-ChNFn4Hj.d.ts → reactive-engine.svelte-CRNqHlbv.d.ts} +199 -1
- package/dist/node/reverse-W7THPV45.js +193 -0
- package/dist/node/{terminal-adapter-CWka-yL8.d.ts → terminal-adapter-B-UK_Vdz.d.ts} +28 -3
- package/dist/node/{terminal-adapter-CDzxoLKR.d.cts → terminal-adapter-BQSIF5bf.d.cts} +28 -3
- package/dist/node/validate-CNHUULQE.js +180 -0
- package/docs/core/pluresdb-integration.md +15 -15
- package/docs/decision-ledger/BEHAVIOR_LEDGER.md +225 -0
- package/docs/decision-ledger/DecisionLedger.tla +180 -0
- package/docs/decision-ledger/IMPLEMENTATION_SUMMARY.md +217 -0
- package/docs/decision-ledger/LATEST.md +166 -0
- package/docs/guides/cicd-pipeline.md +142 -0
- package/package.json +2 -2
- package/src/__tests__/cli-validate.test.ts +197 -0
- package/src/__tests__/decision-ledger.test.ts +485 -0
- package/src/__tests__/reverse-generator.test.ts +189 -0
- package/src/__tests__/scanner.test.ts +215 -0
- package/src/cli/commands/reverse.ts +289 -0
- package/src/cli/commands/validate.ts +264 -0
- package/src/cli/index.ts +47 -0
- package/src/core/pluresdb/adapter.ts +45 -2
- package/src/core/rules.ts +133 -0
- package/src/decision-ledger/README.md +400 -0
- package/src/decision-ledger/REVERSE_ENGINEERING.md +484 -0
- package/src/decision-ledger/facts-events.ts +121 -0
- package/src/decision-ledger/index.ts +70 -0
- package/src/decision-ledger/ledger.ts +246 -0
- package/src/decision-ledger/logic-ledger.ts +158 -0
- package/src/decision-ledger/reverse-generator.ts +426 -0
- package/src/decision-ledger/scanner.ts +506 -0
- package/src/decision-ledger/types.ts +247 -0
- package/src/decision-ledger/validation.ts +336 -0
- package/src/dsl/index.ts +13 -2
- package/src/index.browser.ts +2 -0
- package/src/index.ts +36 -0
- package/src/integrations/pluresdb.ts +14 -2
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Decision Ledger Integration - Implementation Summary
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Decision Ledger Integration has been successfully implemented for the Praxis framework, providing contract-based validation and documentation for rules and constraints.
|
|
6
|
+
|
|
7
|
+
## Implementation Status
|
|
8
|
+
|
|
9
|
+
✅ **COMPLETE** - All components implemented, tested, and integrated
|
|
10
|
+
|
|
11
|
+
## Deliverables
|
|
12
|
+
|
|
13
|
+
### 1. Behavior Documentation
|
|
14
|
+
|
|
15
|
+
✅ **Behavior Ledger** (`docs/decision-ledger/BEHAVIOR_LEDGER.md`)
|
|
16
|
+
- Canonical behavior specification with examples and invariants
|
|
17
|
+
- 5 documented assumptions with confidence levels and traceability
|
|
18
|
+
- Complete Given/When/Then examples for all core use cases
|
|
19
|
+
|
|
20
|
+
✅ **LATEST Snapshot** (`docs/decision-ledger/LATEST.md`)
|
|
21
|
+
- Non-authoritative summary derived from behavior ledger
|
|
22
|
+
- Quick start guide with API reference
|
|
23
|
+
- Configuration examples
|
|
24
|
+
|
|
25
|
+
✅ **TLA+ Specification** (`docs/decision-ledger/DecisionLedger.tla`)
|
|
26
|
+
- Formal specification of core invariants
|
|
27
|
+
- Model-checkable properties for ledger immutability and validation determinism
|
|
28
|
+
- Documented safety and liveness properties
|
|
29
|
+
|
|
30
|
+
### 2. Core Implementation
|
|
31
|
+
|
|
32
|
+
✅ **Type Definitions** (`src/decision-ledger/types.ts`)
|
|
33
|
+
- `Contract` interface with behavior, examples, invariants, assumptions, references
|
|
34
|
+
- `Assumption` tracking with confidence levels and impact analysis
|
|
35
|
+
- `ValidationReport` with complete/incomplete/missing categorization
|
|
36
|
+
- JSON-serializable, cross-language compatible
|
|
37
|
+
|
|
38
|
+
✅ **Facts and Events** (`src/decision-ledger/facts-events.ts`)
|
|
39
|
+
- `ContractMissing` fact for tracking gaps
|
|
40
|
+
- `AcknowledgeContractGap` event for explicit acknowledgment
|
|
41
|
+
- `ContractValidated`, `ContractGapAcknowledged` facts
|
|
42
|
+
- `ContractAdded`, `ContractUpdated` events
|
|
43
|
+
|
|
44
|
+
✅ **Validation Engine** (`src/decision-ledger/validation.ts`)
|
|
45
|
+
- Build-time and runtime validation
|
|
46
|
+
- Multiple output formats: console, JSON, SARIF
|
|
47
|
+
- Configurable severity levels and required fields
|
|
48
|
+
- Deterministic validation results
|
|
49
|
+
|
|
50
|
+
✅ **Behavior Ledger** (`src/decision-ledger/ledger.ts`)
|
|
51
|
+
- Immutable, append-only storage
|
|
52
|
+
- Entry superseding with version tracking
|
|
53
|
+
- Assumption tracking and impact analysis
|
|
54
|
+
- JSON export/import for persistence
|
|
55
|
+
|
|
56
|
+
### 3. CLI Integration
|
|
57
|
+
|
|
58
|
+
✅ **Validate Command** (`src/cli/commands/validate.ts`)
|
|
59
|
+
- `praxis validate` command implementation
|
|
60
|
+
- Support for `--output` (console/json/sarif), `--strict`, `--registry`
|
|
61
|
+
- Error handling and exit codes for CI/CD integration
|
|
62
|
+
- Integrated into main CLI (`src/cli/index.ts`)
|
|
63
|
+
|
|
64
|
+
### 4. Tests
|
|
65
|
+
|
|
66
|
+
✅ **Comprehensive Test Suite** (`src/__tests__/decision-ledger.test.ts`)
|
|
67
|
+
- 17 test cases covering all core functionality
|
|
68
|
+
- Contract definition and validation
|
|
69
|
+
- Facts and events creation and type guards
|
|
70
|
+
- Behavior ledger immutability and versioning
|
|
71
|
+
- All examples from behavior ledger are tested
|
|
72
|
+
- **All tests passing** (365/365 total tests pass)
|
|
73
|
+
|
|
74
|
+
### 5. Documentation
|
|
75
|
+
|
|
76
|
+
✅ **README** (`src/decision-ledger/README.md`)
|
|
77
|
+
- Quick start guide
|
|
78
|
+
- API reference
|
|
79
|
+
- CLI command documentation
|
|
80
|
+
- CI/CD integration examples
|
|
81
|
+
- Design principles
|
|
82
|
+
|
|
83
|
+
✅ **Example Application** (`examples/decision-ledger/`)
|
|
84
|
+
- Complete working example
|
|
85
|
+
- Demonstrates all core features
|
|
86
|
+
- Step-by-step walkthrough
|
|
87
|
+
- Successfully executes and produces expected output
|
|
88
|
+
|
|
89
|
+
## Test Results
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
✓ src/__tests__/decision-ledger.test.ts (17 tests) 13ms
|
|
93
|
+
|
|
94
|
+
Test Files 24 passed (24)
|
|
95
|
+
Tests 365 passed (365)
|
|
96
|
+
Duration 2.21s
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Type Safety
|
|
100
|
+
|
|
101
|
+
✅ TypeScript compilation: **PASS**
|
|
102
|
+
✅ All types properly exported from main index
|
|
103
|
+
✅ No implicit any types
|
|
104
|
+
|
|
105
|
+
## Build Status
|
|
106
|
+
|
|
107
|
+
✅ Build successful (tsup)
|
|
108
|
+
- Node ESM output
|
|
109
|
+
- Node CJS output
|
|
110
|
+
- Browser output
|
|
111
|
+
- TypeScript declarations (.d.ts)
|
|
112
|
+
|
|
113
|
+
## Integration Points
|
|
114
|
+
|
|
115
|
+
### With Existing Praxis Components
|
|
116
|
+
|
|
117
|
+
1. **Rules and Constraints** (`src/core/rules.ts`)
|
|
118
|
+
- Contracts stored in `meta` field of `RuleDescriptor` and `ConstraintDescriptor`
|
|
119
|
+
- Non-breaking change, fully backward compatible
|
|
120
|
+
|
|
121
|
+
2. **DSL Helpers** (`src/dsl/index.ts`)
|
|
122
|
+
- `defineContract()` follows same pattern as `defineRule()` and `defineConstraint()`
|
|
123
|
+
- Consistent API surface
|
|
124
|
+
|
|
125
|
+
3. **CLI** (`src/cli/index.ts`)
|
|
126
|
+
- New `validate` command follows Commander.js patterns
|
|
127
|
+
- Consistent with existing commands
|
|
128
|
+
|
|
129
|
+
4. **Main Exports** (`src/index.ts`)
|
|
130
|
+
- All Decision Ledger types and functions exported
|
|
131
|
+
- Discoverable through main package import
|
|
132
|
+
|
|
133
|
+
## Assumptions Validated
|
|
134
|
+
|
|
135
|
+
All 5 assumptions from the behavior ledger have been validated:
|
|
136
|
+
|
|
137
|
+
1. ✅ **A1: Contract Storage** - Contracts successfully stored in `meta` field
|
|
138
|
+
2. ✅ **A2: JSON Serialization** - All types JSON-serializable, tested in ledger export/import
|
|
139
|
+
3. ✅ **A3: CLI Pattern** - Validate command follows Commander.js pattern
|
|
140
|
+
4. ✅ **A4: Test Framework** - Tests use Vitest with describe/it/expect
|
|
141
|
+
5. ✅ **A5: Optional Contracts** - Contracts optional by default, strict mode opt-in
|
|
142
|
+
|
|
143
|
+
## Behavior Coverage
|
|
144
|
+
|
|
145
|
+
All examples from the behavior ledger are implemented and tested:
|
|
146
|
+
|
|
147
|
+
- ✅ Example 1: Defining a Contract for a Rule
|
|
148
|
+
- ✅ Example 2: Build-time Validation
|
|
149
|
+
- ✅ Example 3: Runtime Validation
|
|
150
|
+
- ✅ Example 4: Contract Gap Acknowledgment
|
|
151
|
+
|
|
152
|
+
All invariants are enforced:
|
|
153
|
+
|
|
154
|
+
- ✅ Contract Immutability (tested)
|
|
155
|
+
- ✅ Ledger Append-Only (tested)
|
|
156
|
+
- ✅ Assumption Traceability (implemented)
|
|
157
|
+
- ✅ Example Completeness (enforced in `defineContract()`)
|
|
158
|
+
- ✅ Validation Determinism (tested)
|
|
159
|
+
|
|
160
|
+
## Example Output
|
|
161
|
+
|
|
162
|
+
The decision-ledger example successfully demonstrates:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Contract Validation Report
|
|
166
|
+
==================================================
|
|
167
|
+
|
|
168
|
+
Total: 3
|
|
169
|
+
Complete: 2
|
|
170
|
+
Incomplete: 1
|
|
171
|
+
Missing: 1
|
|
172
|
+
|
|
173
|
+
✓ Complete Contracts:
|
|
174
|
+
✓ auth.login (v1.0.0)
|
|
175
|
+
✓ cart.addItem (v1.0.0)
|
|
176
|
+
|
|
177
|
+
✗ Incomplete Contracts:
|
|
178
|
+
⚠ legacy.process - Missing: contract
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Security Considerations
|
|
182
|
+
|
|
183
|
+
- No secrets or sensitive data in contracts
|
|
184
|
+
- All validation is deterministic and side-effect-free
|
|
185
|
+
- SARIF output compatible with GitHub Security scanning
|
|
186
|
+
- No network dependencies
|
|
187
|
+
|
|
188
|
+
## Performance Characteristics
|
|
189
|
+
|
|
190
|
+
- Validation is O(n) where n = number of rules/constraints
|
|
191
|
+
- Ledger queries are O(n) for full scans, O(1) for ID lookups
|
|
192
|
+
- JSON serialization/deserialization is efficient
|
|
193
|
+
- No memory leaks detected in tests
|
|
194
|
+
|
|
195
|
+
## Future Enhancements
|
|
196
|
+
|
|
197
|
+
While the implementation is complete, potential future enhancements could include:
|
|
198
|
+
|
|
199
|
+
1. **Schema-based contract generation** - Auto-generate contracts from schemas
|
|
200
|
+
2. **Test generation from examples** - Generate test stubs from Given/When/Then
|
|
201
|
+
3. **Assumption validation** - Check if assumptions are still valid
|
|
202
|
+
4. **Contract coverage metrics** - Detailed metrics and trends
|
|
203
|
+
5. **Integration with TLA+ model checker** - Automated property verification
|
|
204
|
+
|
|
205
|
+
## Conclusion
|
|
206
|
+
|
|
207
|
+
The Decision Ledger Integration is **production-ready** and provides:
|
|
208
|
+
|
|
209
|
+
- ✅ Contract-based documentation for rules and constraints
|
|
210
|
+
- ✅ Build-time and runtime validation
|
|
211
|
+
- ✅ Immutable behavior ledger with version tracking
|
|
212
|
+
- ✅ CLI integration with CI/CD support
|
|
213
|
+
- ✅ Comprehensive test coverage
|
|
214
|
+
- ✅ Complete documentation and examples
|
|
215
|
+
- ✅ Backward compatibility with existing Praxis code
|
|
216
|
+
|
|
217
|
+
The implementation follows the behavior-first approach with a complete behavior ledger, TLA+ specification, tests, and implementation code—all traceable to the canonical behavior specification.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Decision Ledger Integration - LATEST Behavior Snapshot
|
|
2
|
+
|
|
3
|
+
**Generated From**: BEHAVIOR_LEDGER.md Entry 1 (`decision-ledger-v1`)
|
|
4
|
+
**Generated At**: 2025-01-26
|
|
5
|
+
**Status**: Non-Authoritative (derived from ledger)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Current Behavior Summary
|
|
10
|
+
|
|
11
|
+
The Decision Ledger Integration extends Praxis with contract-based rule and constraint validation, enabling teams to document, test, and enforce behavioral contracts for their logic.
|
|
12
|
+
|
|
13
|
+
### Core Capabilities
|
|
14
|
+
|
|
15
|
+
1. **Contract Definition**
|
|
16
|
+
- Attach contracts to rules and constraints via the `meta.contract` field
|
|
17
|
+
- Define canonical behavior, examples, invariants, assumptions, and references
|
|
18
|
+
- Contracts are JSON-serializable and language-neutral
|
|
19
|
+
|
|
20
|
+
2. **Build-time Validation**
|
|
21
|
+
- `praxis validate` CLI command scans registered rules and constraints
|
|
22
|
+
- Reports contract coverage and identifies gaps
|
|
23
|
+
- Outputs structured diagnostics (JSON, console, SARIF)
|
|
24
|
+
|
|
25
|
+
3. **Runtime Validation**
|
|
26
|
+
- Optional strict mode for contract enforcement during rule registration
|
|
27
|
+
- Emits `ContractMissing` facts for rules without complete contracts
|
|
28
|
+
- Policy rules can enforce contract requirements
|
|
29
|
+
|
|
30
|
+
4. **Contract Gap Management**
|
|
31
|
+
- Acknowledge known gaps with `ACKNOWLEDGE_CONTRACT_GAP` event
|
|
32
|
+
- Track technical debt and expiration dates
|
|
33
|
+
- Audit trail of contract coverage over time
|
|
34
|
+
|
|
35
|
+
### Active Assumptions
|
|
36
|
+
|
|
37
|
+
All assumptions from Entry 1 are active:
|
|
38
|
+
- A1: Contracts stored in `meta` field
|
|
39
|
+
- A2: All contract data is JSON-serializable
|
|
40
|
+
- A3: CLI follows Commander.js pattern
|
|
41
|
+
- A4: Tests use Vitest framework
|
|
42
|
+
- A5: Contracts are optional by default
|
|
43
|
+
|
|
44
|
+
### Quick Start Example
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { defineRule, defineContract } from '@plures/praxis';
|
|
48
|
+
|
|
49
|
+
// Define a contract
|
|
50
|
+
const loginContract = defineContract({
|
|
51
|
+
ruleId: 'auth.login',
|
|
52
|
+
behavior: 'Process login events and create user session facts',
|
|
53
|
+
examples: [
|
|
54
|
+
{
|
|
55
|
+
given: 'User provides valid credentials',
|
|
56
|
+
when: 'LOGIN event is received',
|
|
57
|
+
then: 'UserSessionCreated fact is emitted'
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
invariants: ['Session must have unique ID']
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Attach contract to rule
|
|
64
|
+
const loginRule = defineRule({
|
|
65
|
+
id: 'auth.login',
|
|
66
|
+
description: 'Process login events',
|
|
67
|
+
impl: (state, events) => { /* ... */ },
|
|
68
|
+
meta: { contract: loginContract }
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Validate at build time
|
|
72
|
+
// $ praxis validate
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### API Reference
|
|
76
|
+
|
|
77
|
+
#### Contract Types
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
interface Contract {
|
|
81
|
+
ruleId: string;
|
|
82
|
+
behavior: string;
|
|
83
|
+
examples: Array<{
|
|
84
|
+
given: string;
|
|
85
|
+
when: string;
|
|
86
|
+
then: string;
|
|
87
|
+
}>;
|
|
88
|
+
invariants: string[];
|
|
89
|
+
assumptions?: Assumption[];
|
|
90
|
+
references?: Reference[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface Assumption {
|
|
94
|
+
id: string;
|
|
95
|
+
statement: string;
|
|
96
|
+
confidence: number; // 0.0 to 1.0
|
|
97
|
+
justification: string;
|
|
98
|
+
derivedFrom?: string;
|
|
99
|
+
impacts: Array<'spec' | 'tests' | 'code'>;
|
|
100
|
+
status: 'active' | 'revised' | 'invalidated';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface Reference {
|
|
104
|
+
type: string;
|
|
105
|
+
url?: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Validation API
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// CLI
|
|
114
|
+
praxis validate [options]
|
|
115
|
+
--output <format> Output format: json, console, sarif (default: console)
|
|
116
|
+
--strict Exit with error if contracts are missing
|
|
117
|
+
--config <file> Path to validation config file
|
|
118
|
+
|
|
119
|
+
// Programmatic
|
|
120
|
+
import { validateContracts } from '@plures/praxis/decision-ledger';
|
|
121
|
+
|
|
122
|
+
const report = validateContracts(registry, options);
|
|
123
|
+
// report.complete: Contract[]
|
|
124
|
+
// report.incomplete: ContractGap[]
|
|
125
|
+
// report.missing: string[] (rule IDs)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Facts and Events
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// ContractMissing fact
|
|
132
|
+
const ContractMissing = defineFact<'ContractMissing', {
|
|
133
|
+
ruleId: string;
|
|
134
|
+
missing: Array<'behavior' | 'examples' | 'invariants' | 'tests' | 'spec'>;
|
|
135
|
+
severity: 'warning' | 'error';
|
|
136
|
+
}>('ContractMissing');
|
|
137
|
+
|
|
138
|
+
// ACKNOWLEDGE_CONTRACT_GAP event
|
|
139
|
+
const AcknowledgeContractGap = defineEvent<'ACKNOWLEDGE_CONTRACT_GAP', {
|
|
140
|
+
ruleId: string;
|
|
141
|
+
missing: string[];
|
|
142
|
+
justification: string;
|
|
143
|
+
expiresAt?: string;
|
|
144
|
+
}>('ACKNOWLEDGE_CONTRACT_GAP');
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Configuration
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// praxis.config.ts
|
|
151
|
+
export default {
|
|
152
|
+
decisionLedger: {
|
|
153
|
+
strict: false, // Require contracts for all rules
|
|
154
|
+
validateOnRegister: true, // Validate at runtime
|
|
155
|
+
outputFormat: 'console', // 'json' | 'console' | 'sarif'
|
|
156
|
+
requiredFields: [ // Required contract fields
|
|
157
|
+
'behavior',
|
|
158
|
+
'examples'
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
**Note**: This is a non-authoritative snapshot derived from the behavior ledger. The source of truth is BEHAVIOR_LEDGER.md.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# CI/CD Pipeline
|
|
2
|
+
|
|
3
|
+
This document describes the automated continuous integration and deployment pipeline for the Praxis framework.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Praxis CI/CD pipeline is fully automated, ensuring that code merged into the `main` branch flows automatically through version bumping, tagging, release creation, and publishing to all package repositories in parallel.
|
|
8
|
+
|
|
9
|
+
## Pipeline Flow
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
PR Merged to main
|
|
13
|
+
↓
|
|
14
|
+
Auto Version Bump (based on semver labels)
|
|
15
|
+
↓
|
|
16
|
+
Create Git Tag (v*.*.*)
|
|
17
|
+
↓
|
|
18
|
+
Run Tests & Build
|
|
19
|
+
↓
|
|
20
|
+
Create GitHub Release
|
|
21
|
+
↓
|
|
22
|
+
Publish to Repositories (Parallel)
|
|
23
|
+
├─→ NPM
|
|
24
|
+
├─→ JSR (JavaScript Registry)
|
|
25
|
+
└─→ NuGet
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Workflow Details
|
|
29
|
+
|
|
30
|
+
### 1. Auto Version Bump (`auto-version-bump.yml`)
|
|
31
|
+
|
|
32
|
+
**Trigger**: When a PR is merged to `main`
|
|
33
|
+
|
|
34
|
+
**Process**:
|
|
35
|
+
- Determines version bump level based on PR labels:
|
|
36
|
+
- `semver:major` → Major version bump (e.g., 1.0.0 → 2.0.0)
|
|
37
|
+
- `semver:minor` → Minor version bump (e.g., 1.0.0 → 1.1.0)
|
|
38
|
+
- `semver:patch` → Patch version bump (e.g., 1.0.0 → 1.0.1) - **default**
|
|
39
|
+
- Updates `package.json` version
|
|
40
|
+
- Creates and pushes a git tag (e.g., `v1.2.3`)
|
|
41
|
+
|
|
42
|
+
**Requirements**: Add one of the semver labels to your PR to control the version bump.
|
|
43
|
+
|
|
44
|
+
### 2. Release Creation (`release.yml`)
|
|
45
|
+
|
|
46
|
+
**Trigger**: When a tag matching `v*.*.*` is pushed (automatically triggered by auto-version-bump)
|
|
47
|
+
|
|
48
|
+
**Process**:
|
|
49
|
+
- Checks out code at the tagged version
|
|
50
|
+
- Runs full test suite
|
|
51
|
+
- Builds the project
|
|
52
|
+
- Creates a GitHub Release with changelog
|
|
53
|
+
- Automatically triggers the publish workflow
|
|
54
|
+
|
|
55
|
+
### 3. Publishing (`publish.yml`)
|
|
56
|
+
|
|
57
|
+
**Trigger**: Called automatically by `release.yml` after release creation
|
|
58
|
+
|
|
59
|
+
**Process**: Three parallel publishing jobs run simultaneously:
|
|
60
|
+
|
|
61
|
+
#### NPM Publishing
|
|
62
|
+
- Builds the TypeScript/Node.js package
|
|
63
|
+
- Publishes to npm registry as `@plures/praxis`
|
|
64
|
+
- Requires `NPM_TOKEN` secret
|
|
65
|
+
|
|
66
|
+
#### JSR Publishing
|
|
67
|
+
- Publishes to JavaScript Registry (JSR) using Deno
|
|
68
|
+
- Publishes as `@plures/praxis`
|
|
69
|
+
- Uses OIDC authentication
|
|
70
|
+
- Note: Uses `--allow-dirty` flag to allow publishing from clean checkout state
|
|
71
|
+
|
|
72
|
+
#### NuGet Publishing
|
|
73
|
+
- Extracts version from the most recent git tag
|
|
74
|
+
- Updates version in `.csproj` file before building
|
|
75
|
+
- Builds the C# package
|
|
76
|
+
- Runs C# tests
|
|
77
|
+
- Publishes to NuGet.org as `Praxis`
|
|
78
|
+
- Requires `NUGET_API_KEY` secret
|
|
79
|
+
|
|
80
|
+
**Note**: When the publish workflow is called from the release workflow, it extracts version information from the git tags instead of relying on GitHub context, ensuring consistent versioning across all published packages.
|
|
81
|
+
|
|
82
|
+
## Additional Workflows
|
|
83
|
+
|
|
84
|
+
### CI (`ci.yml`)
|
|
85
|
+
|
|
86
|
+
**Trigger**: On push to `main` or pull request
|
|
87
|
+
|
|
88
|
+
**Purpose**: Validates code quality before merging
|
|
89
|
+
- Runs tests on multiple Node.js versions (18.x, 20.x)
|
|
90
|
+
- Runs C# tests on .NET 8
|
|
91
|
+
- Performs Deno compatibility checks
|
|
92
|
+
|
|
93
|
+
### C# Build Check (`publish-nuget.yml`)
|
|
94
|
+
|
|
95
|
+
**Trigger**: On push to `main` or pull request
|
|
96
|
+
|
|
97
|
+
**Purpose**: Validates C# code builds and tests pass
|
|
98
|
+
- Ensures C# codebase is always in a buildable state
|
|
99
|
+
- Runs independently of publishing workflow
|
|
100
|
+
|
|
101
|
+
## Secrets Required
|
|
102
|
+
|
|
103
|
+
The following secrets must be configured in the GitHub repository:
|
|
104
|
+
|
|
105
|
+
- `NPM_TOKEN`: NPM authentication token for publishing packages
|
|
106
|
+
- `NUGET_API_KEY`: NuGet API key for publishing packages
|
|
107
|
+
|
|
108
|
+
## Manual Triggers
|
|
109
|
+
|
|
110
|
+
The main pipeline workflows support `workflow_dispatch`, allowing manual triggering when needed:
|
|
111
|
+
|
|
112
|
+
- **Release Workflow**: Manually create a release and publish for the current state
|
|
113
|
+
- **Publish Workflow**: Re-publish to all repositories without creating a new release
|
|
114
|
+
- **C# Build Check**: Manually validate C# code builds and tests (separate from publishing)
|
|
115
|
+
|
|
116
|
+
## Best Practices
|
|
117
|
+
|
|
118
|
+
1. **Always label your PRs**: Use semver labels (`semver:major`, `semver:minor`, or `semver:patch`) to control version bumping
|
|
119
|
+
2. **Review before merging**: Once merged to `main`, the entire pipeline runs automatically
|
|
120
|
+
3. **Monitor releases**: Check the Actions tab to ensure all publishing jobs complete successfully
|
|
121
|
+
4. **Breaking changes**: Use `semver:major` for breaking changes
|
|
122
|
+
5. **New features**: Use `semver:minor` for new features
|
|
123
|
+
6. **Bug fixes**: Use `semver:patch` for bug fixes and patches
|
|
124
|
+
|
|
125
|
+
## Troubleshooting
|
|
126
|
+
|
|
127
|
+
### Publishing failures
|
|
128
|
+
|
|
129
|
+
If any publishing job fails:
|
|
130
|
+
1. Check the Actions tab for detailed error logs
|
|
131
|
+
2. Verify all required secrets are configured
|
|
132
|
+
3. The workflow can be manually re-triggered using `workflow_dispatch`
|
|
133
|
+
|
|
134
|
+
### Version conflicts
|
|
135
|
+
|
|
136
|
+
If version bumping fails:
|
|
137
|
+
1. Ensure no manual version changes conflict with automated bumping
|
|
138
|
+
2. Check that the main branch is up to date
|
|
139
|
+
|
|
140
|
+
### Parallel publishing
|
|
141
|
+
|
|
142
|
+
All three repositories (NPM, JSR, NuGet) publish in parallel. If one fails, the others will continue. Check individual job logs for failures.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plures/praxis",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "The Full Plures Application Framework - declarative schemas, logic engine, component generation, and local-first data",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"commander": "^14.0.2",
|
|
119
119
|
"js-yaml": "^4.1.1",
|
|
120
|
-
"pluresdb": "^1.
|
|
120
|
+
"@plures/pluresdb": "^1.6.10"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"svelte": "^5.46.0"
|