Skip to content

Commit 80de1e3

Browse files
committed
Optimize constants
1 parent c1d088b commit 80de1e3

23 files changed

+473
-148
lines changed

dev/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ./dev
2+
3+
This directory contains ideas and thoughts about building and extending Figment and its associated tools. Nothing in this directory should be construed to be a tutorial, product or user documentation, or a promise for what is to come. It's an open and transparent repository for thoughts and ideas that may or may not materialize.
4+

TODO.md renamed to dev/TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [x] Built-in system schemas
1717
- [x] Pomodoro timer
1818
- [x] tasks
19+
- [ ] business process management (BPM)
1920
- [ ] Versioned things
2021
- [ ] default schema values
2122
- [ ] Schema inheritence

dev/workflow-system-prd.md

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
# Figment Workflow System - Product Requirements Document
2+
3+
## Executive Summary
4+
5+
This document outlines the requirements for implementing a workflow system within Figment, accessible through the `jot` console application. The workflow system will provide Windows Workflow Foundation-like capabilities while maintaining Figment's schema-driven, lightweight architecture and avoiding enterprise-specific features like XAML definitions.
6+
7+
## Current State Analysis
8+
9+
### Existing Infrastructure
10+
- **Task System**: Robust task management with filtering, status tracking, and note attachments
11+
- **Schema System**: JSON Schema-based entity definitions with validation
12+
- **Storage Abstraction**: Provider-based storage supporting local files and in-memory persistence
13+
- **Console Interface**: Rich CLI with interactive REPL mode using Spectre.Console
14+
- **Command Architecture**: Hierarchical command system with settings classes and error handling
15+
16+
### Integration Points
17+
- Task entities with status, priority, and assignee tracking
18+
- Pomodoro timer integration for time-based workflow activities
19+
- Project/Context tagging system (@context, +project)
20+
- Ultralist.io-style filtering and querying
21+
22+
## Product Vision
23+
24+
Create a flexible, code-first workflow system that enables users to define, execute, and monitor multi-step processes through the `jot` console application. Workflows should feel natural within the existing task ecosystem while providing powerful automation and orchestration capabilities.
25+
26+
## Core Requirements
27+
28+
### 1. Workflow Definition
29+
30+
#### 1.1 Schema-Based Workflow Definition
31+
- **Workflow Schema**: Define workflows as Figment schemas with standardized fields
32+
- **Activity Schema**: Define individual workflow activities/steps as schemas
33+
- **Transition Schema**: Define rules for moving between activities
34+
35+
#### 1.2 Workflow Properties
36+
```json
37+
{
38+
"id": "workflow-unique-identifier",
39+
"name": "Human-readable workflow name",
40+
"description": "Workflow description",
41+
"version": "1.0.0",
42+
"status": "draft|active|deprecated",
43+
"created": "ISO 8601 timestamp",
44+
"lastModified": "ISO 8601 timestamp",
45+
"activities": ["array of activity references"],
46+
"transitions": ["array of transition rules"],
47+
"variables": ["workflow-scoped variables"],
48+
"triggers": ["workflow initiation triggers"]
49+
}
50+
```
51+
52+
#### 1.3 Activity Types
53+
- **Task Activity**: Execute or create tasks within the existing task system
54+
- **Delay Activity**: Wait for specified time duration
55+
- **Decision Activity**: Branch based on conditions or user input
56+
- **Parallel Activity**: Execute multiple activities concurrently
57+
- **Sequential Activity**: Execute activities in sequence
58+
- **Custom Activity**: User-defined activities with configurable properties
59+
60+
### 2. Workflow Execution Engine
61+
62+
#### 2.1 Execution Model
63+
- **Instance-Based**: Each workflow execution creates a workflow instance
64+
- **State Persistence**: Save/restore workflow state across application restarts
65+
- **Concurrent Execution**: Support multiple workflow instances simultaneously
66+
- **Error Handling**: Graceful handling of activity failures with retry policies
67+
68+
#### 2.2 Workflow Instance Properties
69+
```json
70+
{
71+
"instanceId": "unique-instance-identifier",
72+
"workflowId": "reference-to-workflow-definition",
73+
"status": "pending|running|completed|failed|cancelled|suspended",
74+
"startTime": "ISO 8601 timestamp",
75+
"endTime": "ISO 8601 timestamp",
76+
"currentActivity": "reference-to-current-activity",
77+
"variables": ["instance-specific variable values"],
78+
"executionHistory": ["array of activity execution records"],
79+
"errorLog": ["array of error records"]
80+
}
81+
```
82+
83+
#### 2.3 State Management
84+
- Persist workflow instances using existing storage providers
85+
- Support workflow suspension and resumption
86+
- Maintain execution history for debugging and audit trails
87+
- Variable scoping (workflow-level, activity-level)
88+
89+
### 3. Console Interface Integration
90+
91+
#### 3.1 Command Structure
92+
```
93+
jot workflow
94+
├── list # List workflow definitions
95+
├── show <workflow-id> # Show workflow details
96+
├── create <name> # Create new workflow
97+
├── edit <workflow-id> # Edit workflow definition
98+
├── delete <workflow-id> # Delete workflow
99+
├── run <workflow-id> # Start workflow instance
100+
├── instances # List workflow instances
101+
├── instance <instance-id> # Show instance details
102+
├── pause <instance-id> # Pause workflow instance
103+
├── resume <instance-id> # Resume workflow instance
104+
├── cancel <instance-id> # Cancel workflow instance
105+
└── history <instance-id> # Show execution history
106+
```
107+
108+
#### 3.2 Interactive Features
109+
- Rich console output with progress indicators
110+
- Interactive workflow creation wizard
111+
- Real-time workflow execution monitoring
112+
- Integration with existing REPL entity selection system
113+
114+
### 4. Activity System
115+
116+
#### 4.1 Built-in Activities
117+
118+
**Task Activity**
119+
- Create new tasks or update existing tasks
120+
- Assign tasks to users
121+
- Set due dates, priorities, and status
122+
- Wait for task completion before proceeding
123+
124+
**Delay Activity**
125+
- Fixed duration delays (seconds, minutes, hours, days)
126+
- Scheduled delays (wait until specific date/time)
127+
- Business day awareness (skip weekends/holidays)
128+
129+
**Decision Activity**
130+
- Conditional branching based on variable values
131+
- User prompt for manual decisions
132+
- Task completion status checks
133+
- Custom condition evaluation
134+
135+
**Parallel Activity**
136+
- Execute multiple child activities simultaneously
137+
- Wait for all or subset completion
138+
- Merge results from parallel branches
139+
140+
**Sequential Activity**
141+
- Execute child activities in defined order
142+
- Pass data between activities
143+
- Stop on first failure or continue on errors
144+
145+
#### 4.2 Activity Configuration
146+
- JSON-based activity configuration
147+
- Variable substitution support
148+
- Input/output parameter mapping
149+
- Conditional execution rules
150+
151+
### 5. Integration Requirements
152+
153+
#### 5.1 Task System Integration
154+
- Workflow-generated tasks appear in normal task lists
155+
- Task filtering includes workflow-related tasks
156+
- Task completion can trigger workflow progression
157+
- Workflow tasks inherit project/context tags
158+
159+
#### 5.2 Pomodoro Integration
160+
- Time-based activities can integrate with Pomodoro timers
161+
- Workflow activities can be Pomodoro work sessions
162+
- Track time spent on workflow execution
163+
164+
#### 5.3 Data Integration
165+
- Workflows can read/write Thing properties
166+
- Reference other entities (people, projects, etc.)
167+
- Import/export workflow definitions
168+
- Backup/restore workflow instances
169+
170+
## Technical Requirements
171+
172+
### 6.1 Architecture Patterns
173+
- Follow existing command pattern for workflow commands
174+
- Use schema-first approach for workflow definitions
175+
- Implement provider pattern for workflow storage
176+
- Maintain ambient context pattern for global access
177+
178+
### 6.2 Storage Requirements
179+
- Workflow definitions stored as Things using workflow schema
180+
- Workflow instances stored as separate Things
181+
- Support both local file and in-memory storage
182+
- Efficient querying of workflow instances by status/date
183+
184+
### 6.3 Performance Requirements
185+
- Startup time: Workflow commands should load within 100ms
186+
- Execution overhead: Minimal impact on task system performance
187+
- Memory usage: Efficient storage of workflow state
188+
- Concurrent workflows: Support 10+ simultaneous workflow instances
189+
190+
### 6.4 Error Handling
191+
- Graceful handling of activity failures
192+
- Retry policies for transient failures
193+
- Dead letter queue for failed workflow instances
194+
- Comprehensive error logging and reporting
195+
196+
## User Experience Requirements
197+
198+
### 7.1 Learning Curve
199+
- Intuitive command structure following existing patterns
200+
- Built-in help system with examples
201+
- Progressive disclosure of advanced features
202+
- Documentation with common workflow patterns
203+
204+
### 7.2 Workflow Creation
205+
- Interactive workflow creation wizard
206+
- Template-based workflow creation
207+
- Import/export workflow definitions
208+
- Validation of workflow definitions before execution
209+
210+
### 7.3 Monitoring and Debugging
211+
- Real-time workflow execution status
212+
- Detailed execution history
213+
- Error reporting with context
214+
- Performance metrics (execution time, activity duration)
215+
216+
## Success Metrics
217+
218+
### 8.1 Adoption Metrics
219+
- Number of workflow definitions created
220+
- Number of workflow instances executed
221+
- Active workflow users
222+
- Workflow execution success rate
223+
224+
### 8.2 Performance Metrics
225+
- Average workflow execution time
226+
- System resource usage
227+
- Error rates and types
228+
- User satisfaction with workflow features
229+
230+
### 8.3 Integration Metrics
231+
- Usage of workflow-generated tasks
232+
- Integration with existing jot features
233+
- Data flow between workflows and other entities
234+
235+
## Non-Functional Requirements
236+
237+
### 9.1 Compatibility
238+
- Compatible with existing .NET 9.0 runtime
239+
- Works with all existing storage providers
240+
- Maintains backward compatibility with existing schemas
241+
- Cross-platform support (Windows, macOS, Linux)
242+
243+
### 9.2 Security
244+
- No execution of external code or scripts
245+
- Secure handling of workflow variables
246+
- Access control for workflow operations
247+
- Safe serialization/deserialization of workflow state
248+
249+
### 9.3 Maintainability
250+
- Clear separation of workflow engine from UI
251+
- Extensible activity system for future enhancements
252+
- Comprehensive unit test coverage
253+
- Documentation of architecture decisions
254+
255+
## Implementation Phases
256+
257+
### Phase 1: Core Infrastructure (Weeks 1-3)
258+
- Workflow and activity schema definitions
259+
- Basic workflow execution engine
260+
- Storage provider integration
261+
- Core workflow commands
262+
263+
### Phase 2: Built-in Activities (Weeks 4-6)
264+
- Task activity implementation
265+
- Delay and decision activities
266+
- Basic parallel/sequential activities
267+
- Activity configuration system
268+
269+
### Phase 3: Advanced Features (Weeks 7-9)
270+
- Interactive workflow creation
271+
- Workflow monitoring and debugging
272+
- Error handling and retry policies
273+
- Performance optimization
274+
275+
### Phase 4: Integration and Polish (Weeks 10-12)
276+
- Task system integration
277+
- Pomodoro integration
278+
- Comprehensive testing
279+
- Documentation and examples
280+
281+
## Future Considerations
282+
283+
### Potential Enhancements
284+
- Visual workflow designer (future GUI application)
285+
- Workflow templates and marketplace
286+
- Integration with external systems (APIs, webhooks)
287+
- Workflow scheduling and triggers
288+
- Advanced analytics and reporting
289+
- Workflow versioning and migration tools
290+
291+
### Extensibility Points
292+
- Custom activity plugin system
293+
- Workflow trigger extensions
294+
- Storage provider enhancements
295+
- Monitoring and alerting integrations
296+
297+
## Conclusion
298+
299+
This workflow system will provide powerful automation capabilities while maintaining the simplicity and elegance of the existing Figment architecture. By building on the established patterns and integrating seamlessly with the current task system, users will have a natural progression path from simple task management to sophisticated workflow automation.
300+
301+
The phased implementation approach ensures early value delivery while allowing for iterative refinement based on user feedback and usage patterns.

src/.editorconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,10 @@ dotnet_diagnostic.RCS1047.severity = warning
101101
dotnet_diagnostic.RCS1090.severity = warning
102102

103103
# The file header is missing or not located at the top of the file
104-
dotnet_diagnostic.SA1633.severity = none
104+
dotnet_diagnostic.SA1633.severity = none
105+
106+
# CA1829: Use the "Count" property instead of Enumerable.Count()
107+
dotnet_diagnostic.CA1829.severity = warning
108+
109+
# CA2016: Forward the 'cancellationToken' parameter to the 'FlushAsync' method or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token
110+
dotnet_diagnostic.CA2016.severity = warning

src/Figment.Common/Tasks/Task.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
Figment
3+
Copyright (C) 2025 Sean McElroy
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU Affero General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU Affero General Public License for more details.
14+
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
namespace Figment.Common.Tasks;
20+
21+
/// <summary>
22+
/// A task is a special type of <see cref="Thing"/> that is used to track planned work.
23+
/// </summary>
24+
public class Task(string guid, string newName) : Thing(guid, newName)
25+
{
26+
/// <summary>
27+
/// Tasks.
28+
/// </summary>
29+
public const string WellKnownSchemaGuid = "00000000-0000-0000-0000-000000000004";
30+
31+
/// <summary>
32+
/// The <see cref="ThingProperty.TruePropertyName"/> of the built-in Task entity type's "id" field.
33+
/// </summary>
34+
public const string TrueNameId = $"{WellKnownSchemaGuid}.id";
35+
36+
/// <summary>
37+
/// The <see cref="ThingProperty.TruePropertyName"/> of the built-in Task entity type's "complete" field.
38+
/// </summary>
39+
public const string TrueNameComplete = $"{WellKnownSchemaGuid}.complete";
40+
41+
/// <summary>
42+
/// The due date of this planned work.
43+
/// </summary>
44+
public const string TrueNameDue = $"{WellKnownSchemaGuid}.due";
45+
46+
/// <summary>
47+
/// The <see cref="ThingProperty.TruePropertyName"/> of the built-in Task entity type's "priority" field.
48+
/// </summary>
49+
public const string TrueNamePriority = $"{WellKnownSchemaGuid}.priority";
50+
51+
/// <summary>
52+
/// The <see cref="ThingProperty.TruePropertyName"/> of the built-in Task entity type's "archived" field.
53+
/// </summary>
54+
public const string TrueNameArchived = $"{WellKnownSchemaGuid}.archived";
55+
56+
/// <summary>
57+
/// The user-defined status of this task.
58+
/// </summary>
59+
public const string TrueNameStatus = $"{WellKnownSchemaGuid}.status";
60+
61+
/// <summary>
62+
/// The <see cref="ThingProperty.TruePropertyName"/> of the built-in Task entity type's "notes" field.
63+
/// </summary>
64+
public const string TrueNameNotes = $"{WellKnownSchemaGuid}.notes";
65+
}

0 commit comments

Comments
 (0)