|
1 | 1 | # Unilang Crate/Framework Implementation Roadmap |
2 | 2 |
|
3 | 3 | ### Current Status (as of 2025-07-31) |
4 | | -The project has successfully completed its foundational phases (1 and 2), establishing a mature core engine. Phase 3, a critical architectural refactoring, is now substantially complete, having successfully migrated the entire framework to the modern `unilang_parser` and aligned the core data models with the formal specification. The project is now well-positioned to begin work on advanced features and modalities in Phase 4. |
| 4 | +The project has successfully completed its foundational phases (1-3), culminating in a critical architectural refactoring that unified the parsing pipeline and data models. The framework is now stable and robust. The next phase will focus on implementing the mandatory performance requirement for a zero-overhead static command registry, which is the cornerstone for building large-scale, high-performance utilities. |
5 | 5 |
|
6 | 6 | **Legend:** |
7 | 7 | * ⚫ : Not Started |
8 | 8 | * ⏳ : In Progress |
9 | 9 | * ✅ : Done |
10 | | -* ❌ : Blocked / Needs Revisit |
11 | 10 | * 🏁 : Phase Complete / Major Milestone |
12 | 11 |
|
13 | 12 | --- |
14 | 13 |
|
15 | 14 | ### Phase 1: Core `unilang` Language Engine & CLI Foundations 🏁 |
16 | 15 | * **Goal:** Establish the `unilang` parsing pipeline, core data structures, command registration, basic type handling, execution flow, initial help capabilities, and error reporting to enable a functional CLI. |
17 | 16 | * **Outcome:** A working, foundational `unilang` crate capable of handling basic CLI commands from parsing to execution. |
18 | | - |
19 | | -* [✅] **1. Foundational Setup:** |
20 | | - * [✅] **1.1. Establish Testing Strategy & Framework:** (Unit & Integration test setup for the crate). |
21 | | -* [✅] **2. CLI Input Processing - Phase 1: Lexical and Syntactic Analysis (Spec 1.1.1):** |
22 | | - * [✅] **2.1. Implement Lexer:** For `unilang` CLI syntax. |
23 | | - * [✅] **2.2. Implement Parser:** To build "Generic Instructions". |
24 | | - * [✅] **2.3. Global Argument Identification & Extraction Logic:** (Framework for integrators to define and extract their global arguments). |
25 | | -* [✅] **3. Core Data Structures & Command Registry (Spec 0.2, 2, 2.4):** |
26 | | - * [✅] **3.1. Define Core Data Structures:** `CommandDefinition`, `ArgumentDefinition`, `Namespace`, `OutputData`, `ErrorData`. |
27 | | - * [✅] **3.2. Implement Unified Command Registry:** |
28 | | - * [✅] Core registry data structure. |
29 | | - * [✅] Provide Compile-Time Registration Mechanisms (e.g., builder API). |
30 | | - * [✅] Basic Namespace Handling Logic. |
31 | | -* [✅] **4. CLI Input Processing - Phase 2: Semantic Analysis & Command Binding (Spec 1.1.2):** |
32 | | - * [✅] **4.1. Command Resolution Logic.** |
33 | | - * [✅] **4.2. Argument Binding Logic.** |
34 | | - * [✅] **4.3. Basic Argument Type System (`kind` - Spec 2.2.2):** |
35 | | - * [✅] Implement parsing/validation for `String`, `Integer`, `Float`, `Boolean`. |
36 | | - * [✅] Support core attributes: `optional`, `default`. |
37 | | - * [✅] **4.4. `VerifiedCommand` Object Generation.** |
38 | | - * [✅] **4.5. Implement Standard `UNILANG_*` Error Code Usage.** |
39 | | -* [✅] **5. Interpreter / Execution Engine - Core (Spec 5):** |
40 | | - * [✅] **5.1. Define `ExecutionContext` Structure (basic version).** |
41 | | - * [✅] **5.2. Implement Routine Invocation mechanism.** |
42 | | - * [✅] **5.3. Basic Handling of Routine Results (`OutputData`, `ErrorData`).** |
43 | | - * [✅] **5.4. Command Separator (`;;`) Processing.** |
44 | | -* [✅] **6. Basic Help Generation & Output (Spec 3.2.6, 4.2.1):** |
45 | | - * [✅] **6.1. Logic to generate structured help data from `CommandDefinition`s.** |
46 | | - * [✅] **6.2. Framework support for `.system.help.globals ?`.** |
47 | | - * [✅] **6.3. Provide default text formatters for basic CLI display.** |
| 17 | +* **Status:** All milestones are complete. |
48 | 18 |
|
49 | 19 | ### Phase 2: Enhanced Type System, Runtime Commands & CLI Maturity 🏁 |
50 | 20 | * **Goal:** Expand the `unilang` crate's type system, provide APIs for runtime command management, and mature CLI support. |
51 | 21 | * **Outcome:** A feature-rich framework capable of handling complex data types, dynamic command loading, and advanced CLI interactions. |
| 22 | +* **Status:** All milestones are complete. |
52 | 23 |
|
53 | | -* [✅] **1. Advanced Built-in Argument Types (`kind` - Spec 2.2.2):** |
54 | | - * [✅] **1.1. Implement parsing/validation for:** `Path`, `File`, `Directory`, `Enum`, `URL`, `DateTime`, `Pattern`. |
55 | | - * [✅] **1.2. Implement `List<Type>`.** |
56 | | - * [✅] **1.3. Implement `Map<KeyType,ValueType>`.** |
57 | | - * [✅] **1.4. Implement `JsonString` / `Object` types.** |
58 | | - * [✅] **1.5. Implement `multiple: true` attribute logic.** |
59 | | - * [✅] **1.6. Implement `validation_rules` attribute processing.** |
60 | | -* [✅] **2. Runtime Command Registration & Management (Spec 4.5.B):** |
61 | | - * [✅] **2.1. Expose Crate API:** For `command_add_runtime`. |
62 | | - * [✅] **2.2. Provide Parsers (e.g., for YAML/JSON) for `CommandDefinition`s.** |
63 | | - * [✅] **2.3. Framework Support for `routine_link` Resolution (placeholder).** |
64 | | -* [✅] **3. CLI Modality Enhancements (Integrator Focused):** |
65 | | - * [✅] **3.1. Framework support for `output_format` global argument.** |
66 | | - * [✅] **3.2. Framework hooks for Interactive Argument Prompting (`interactive: true`).** |
67 | | - * [✅] **3.3. Framework support for `on_error::continue` global argument.** |
68 | | -* [✅] **4. `ExecutionContext` Enhancements (Spec 4.7):** |
69 | | - * [✅] **4.1. Standardize fields and access methods.** |
70 | | - |
71 | | -### Phase 3: Architectural Unification & Enhancement ⏳ |
| 24 | +### Phase 3: Architectural Unification & Enhancement 🏁 |
72 | 25 | * **Goal:** Correct the project's architecture by removing legacy components, integrating `unilang_parser` as the single source of truth, and fully aligning data models with the specification. |
73 | | -* **Outcome:** A stable, maintainable, and consistent codebase with comprehensive test coverage, ready for future feature development. |
74 | | - |
75 | | -* [✅] **M3.1: design_architectural_unification_task:** A detailed `task_plan.md` was created and executed. |
76 | | -* [✅] **M3.2: implement_parser_integration:** |
77 | | - * [✅] **3.2.1:** Refactored `unilang::semantic::SemanticAnalyzer` to consume `unilang_parser::GenericInstruction`. |
78 | | - * [✅] **3.2.2:** Refactored the `unilang_cli` binary to use the `unilang_parser`. |
79 | | - * [✅] **3.2.3:** Migrated all integration tests to the new unified parsing pipeline. |
80 | | -* [✅] **M3.3: refactor_data_models_and_help:** |
81 | | - * [✅] **3.3.1:** Added all specified fields (`status`, `tags`, `version`, `aliases`, etc.) to `CommandDefinition` and `ArgumentDefinition`. |
82 | | - * [✅] **3.3.2:** Updated the `HelpGenerator` to display all new metadata fields. |
83 | | - * [✅] **3.3.3:** Implemented command alias resolution in the CLI binary. |
84 | | -* [✅] **M3.4: update_documentation_and_examples:** |
85 | | - * [✅] **3.4.1:** Created a comprehensive example (`full_cli_example.rs`) demonstrating modern framework usage. |
86 | | - * [✅] **3.4.2:** Updated `spec.md` to formally document the multi-phase processing pipeline and the complete data models. |
87 | | -* [⚫] **M3.5: finalize_unification:** |
88 | | - * **Deliverable:** A fully unified codebase with no legacy components. |
89 | | - * **Tasks:** |
90 | | - * [⚫] **3.5.1:** Remove any remaining legacy parsing modules and files (e.g., `src/ca/`). |
91 | | - * [⚫] **3.5.2:** Conduct a final code audit to ensure all components adhere to the new architecture. |
| 26 | +* **Outcome:** A stable, maintainable codebase with a unified architecture, ready for the implementation of core functional requirements. |
| 27 | +* **Status:** All milestones are complete. |
92 | 28 |
|
93 | | -### Phase 4: Advanced Features & Modalities |
94 | | -* **Goal:** Build on the stable architecture to implement advanced framework features that enable powerful, multi-modal utilities. |
95 | | -* **Outcome:** A versatile framework that supports global configuration, Web APIs, and a superior developer experience through procedural macros. |
| 29 | +### Phase 4: Zero-Overhead Static Command Registry ⏳ |
| 30 | +* **Goal:** To implement the mandatory performance NFR for a zero-overhead static command system, enabling utilities with thousands of commands to start instantly. |
| 31 | +* **Outcome:** A framework with a hybrid command registry where all compile-time commands are stored in a Perfect Hash Function (PHF), eliminating runtime registration costs and ensuring sub-millisecond command resolution. |
96 | 32 |
|
97 | | -* [⚫] **M4.1: design_global_argument_framework:** |
98 | | - * **Deliverable:** A design document for handling global arguments. |
99 | | - * **Description:** Plan how global arguments are defined, parsed, and integrated into the `ExecutionContext`. |
100 | | -* [⚫] **M4.2: implement_global_argument_parsing:** |
| 33 | +* [⚫] **M4.1: design_hybrid_registry_architecture:** |
| 34 | + * **Spec Reference:** FR-PERF-1, NFR-Performance |
| 35 | + * **Deliverable:** A detailed task plan for implementing a zero-overhead static command registry. |
| 36 | + * **Description:** Design a build-time mechanism (using `build.rs` and the `phf` crate) to generate a Perfect Hash Function (PHF) map for all compile-time command definitions. This plan will outline the steps to refactor the `CommandRegistry` into a hybrid model (static PHF for compile-time commands + dynamic HashMap for runtime commands). |
| 37 | +* [⚫] **M4.2: implement_build_time_phf_generation:** |
101 | 38 | * **Prerequisites:** M4.1 |
102 | | - * **Deliverable:** The ability to parse and validate global arguments from the command line and environment variables. |
103 | | -* [⚫] **M4.3: integrate_globals_into_execution_context:** |
| 39 | + * **Deliverable:** A `build.rs` script that generates a `.rs` file containing the static PHF maps for commands and routines. |
| 40 | + * **Description:** Implement the build script that scans the source code (or a manifest) for static command definitions and uses the `phf_codegen` crate to construct the perfect hash maps. |
| 41 | +* [⚫] **M4.3: refactor_command_registry_to_hybrid_model:** |
104 | 42 | * **Prerequisites:** M4.2 |
105 | | - * **Deliverable:** Global argument values are accessible to all command routines via the `ExecutionContext`. |
106 | | -* [⚫] **M4.4: design_web_api_modality:** |
| 43 | + * **Deliverable:** An updated `CommandRegistry` that uses the generated PHF for static commands. |
| 44 | + * **Tasks:** |
| 45 | + * [⚫] **4.3.1:** Modify the `CommandRegistry` struct to hold both the static PHF (included via `include!`) and the dynamic `HashMap`. |
| 46 | + * [⚫] **4.3.2:** Refactor all lookup methods (`get_command`, `get_routine`) to query the static PHF first before falling back to the dynamic `HashMap`. |
| 47 | +* [⚫] **M4.4: implement_performance_stress_test:** |
| 48 | + * **Prerequisites:** M4.3 |
| 49 | + * **Spec Reference:** FR-PERF-1 |
| 50 | + * **Deliverable:** A new integration test that proves the performance non-functional requirement is met. |
| 51 | + * **Tasks:** |
| 52 | + * [⚫] **4.4.1:** Create a test that programmatically generates source code for over 1,000 static command definitions. |
| 53 | + * [⚫] **4.4.2:** Use this generated code in a test binary to trigger the `build.rs` PHF generation. |
| 54 | + * [⚫] **4.4.3:** Measure and assert that the resulting binary's startup time is negligible and not proportional to the number of commands. |
| 55 | + * [⚫] **4.4.4:** Measure and assert that the p99 latency for command resolution is under 1ms. |
| 56 | + |
| 57 | +### Phase 5: Core API Enhancements & Modality Support |
| 58 | +* **Goal:** To implement the remaining mandatory functional requirements from Spec v2.2.0, ensuring the framework fully supports REPL and interactive CLI modalities. |
| 59 | +* **Outcome:** A functionally complete API that provides all necessary hooks for building sophisticated, user-friendly command-line applications. |
| 60 | + |
| 61 | +* [⚫] **M5.1: refactor_pipeline_for_reusability_and_add_repl_example:** |
| 62 | + * **Spec Reference:** FR-REPL-1 |
| 63 | + * **Deliverable:** A new example file (`repl_example.rs`) demonstrating the reusability of framework components in a loop. |
| 64 | + * **Description:** Audit the core pipeline components (`Parser`, `SemanticAnalyzer`, `Interpreter`) to ensure they are stateless and can be reused. Create an example that simulates a REPL by repeatedly taking input and invoking the full pipeline using the same long-lived `Pipeline` instance. |
| 65 | +* [⚫] **M5.2: implement_interactive_argument_signaling:** |
| 66 | + * **Spec Reference:** FR-INTERACTIVE-1 |
| 67 | + * **Deliverable:** The `SemanticAnalyzer` correctly returns a specific error for interactive prompts. |
| 68 | + * **Tasks:** |
| 69 | + * [⚫] **5.2.1:** In `semantic.rs`, modify the `bind_arguments` logic to check for missing mandatory arguments that have `interactive: true`. |
| 70 | + * [⚫] **5.2.2:** When this condition is met, return an `Error::Execution` with the specific `ErrorData` code `UNILANG_ARGUMENT_INTERACTIVE_REQUIRED`. |
| 71 | +* [⚫] **M5.3: create_interactive_prompting_test:** |
| 72 | + * **Prerequisites:** M5.2 |
| 73 | + * **Deliverable:** A new unit test for the `SemanticAnalyzer` and an example in the CLI binary. |
| 74 | + * **Tasks:** |
| 75 | + * [⚫] **5.3.1:** Write a test that defines a command with a mandatory interactive argument, analyzes an instruction that omits it, and asserts that the returned error has the code `UNILANG_ARGUMENT_INTERACTIVE_REQUIRED`. |
| 76 | + * [⚫] **5.3.2:** Update `unilang_cli.rs` to demonstrate how to catch this specific error and print a user-friendly prompt. |
| 77 | + |
| 78 | +### Phase 6: Advanced Features & Web Modality |
| 79 | +* **Goal:** Build on the stable and performant architecture to implement advanced framework features, including a Web API modality and a superior developer experience through procedural macros. |
| 80 | +* **Outcome:** A versatile, multi-modal framework that significantly reduces boilerplate for developers. |
| 81 | + |
| 82 | +* [⚫] **M6.1: design_web_api_modality:** |
107 | 83 | * **Deliverable:** A plan for mapping `unilang` commands to HTTP endpoints. |
108 | | - * **Description:** Define the strategy for URL structure, HTTP method mapping (`http_method_hint`), and data serialization. |
109 | | -* [⚫] **M4.5: implement_openapi_generator:** |
110 | | - * **Prerequisites:** M4.4 |
| 84 | +* [⚫] **M6.2: implement_openapi_generator:** |
| 85 | + * **Prerequisites:** M6.1 |
111 | 86 | * **Deliverable:** A function that generates an OpenAPI v3+ specification from the `CommandRegistry`. |
112 | | -* [⚫] **M4.6: implement_http_to_command_mapper:** |
113 | | - * **Prerequisites:** M4.4 |
| 87 | +* [⚫] **M6.3: implement_http_to_command_mapper:** |
| 88 | + * **Prerequisites:** M6.1 |
114 | 89 | * **Deliverable:** A utility/adapter that converts an incoming HTTP request into a `unilang` command invocation. |
115 | | -* [⚫] **M4.7: create_web_api_example:** |
116 | | - * **Prerequisites:** M4.6 |
117 | | - * **Deliverable:** An example application (e.g., using `axum` or `actix-web`) that serves a `unilang` registry as a REST API. |
118 | | -* [⚫] **M4.8: design_procedural_macros:** |
| 90 | +* [⚫] **M6.4: create_web_api_example:** |
| 91 | + * **Prerequisites:** M6.3 |
| 92 | + * **Deliverable:** An example application that serves a `unilang` registry as a REST API. |
| 93 | +* [⚫] **M6.5: design_procedural_macros:** |
119 | 94 | * **Deliverable:** An API design for the `#[command]` procedural macro in the `unilang_meta` crate. |
120 | | -* [⚫] **M4.9: implement_command_macro:** |
121 | | - * **Prerequisites:** M4.8 |
| 95 | +* [⚫] **M6.6: implement_command_macro:** |
| 96 | + * **Prerequisites:** M6.5 |
122 | 97 | * **Deliverable:** A working `#[command]` macro that generates `CommandDefinition` structs from Rust functions. |
123 | | -* [⚫] **M4.10: update_documentation_for_macros:** |
124 | | - * **Prerequisites:** M4.9 |
125 | | - * **Deliverable:** Documentation and examples for using the new procedural macros. |
126 | 98 |
|
127 | | -### Phase 5: Release Candidate Preparation |
128 | | -* **Goal:** Focus on stability, performance, developer experience, and documentation to prepare for a v1.0 release. |
| 99 | +### Phase 7: Release Candidate Preparation |
| 100 | +* **Goal:** Focus on stability, developer experience, and documentation to prepare for a v1.0 release. |
129 | 101 | * **Outcome:** A polished, production-ready v1.0.0-rc.1 release of the `unilang` framework. |
130 | 102 |
|
131 | | -* [⚫] **M5.1: establish_benchmarks:** |
132 | | - * **Deliverable:** A suite of benchmarks for key performance indicators (parsing, semantic analysis, command dispatch). |
133 | | -* [⚫] **M5.2: optimize_hot_paths:** |
134 | | - * **Prerequisites:** M5.1 |
135 | | - * **Deliverable:** Code optimizations applied to performance-critical sections of the framework. |
136 | | -* [⚫] **M5.3: write_core_concepts_guide:** |
| 103 | +* [⚫] **M7.1: write_core_concepts_guide:** |
137 | 104 | * **Deliverable:** A comprehensive guide in the documentation explaining the core architecture and philosophy of `unilang`. |
138 | | -* [⚫] **M5.4: write_modality_tutorials:** |
139 | | - * **Prerequisites:** M4.7 |
140 | | - * **Deliverable:** Tutorials for building a CLI and a Web API with `unilang`. |
141 | | -* [⚫] **M5.5: conduct_api_review_and_stabilization:** |
| 105 | +* [⚫] **M7.2: write_modality_tutorials:** |
| 106 | + * **Prerequisites:** M6.4 |
| 107 | + * **Deliverable:** Tutorials for building a CLI, REPL, and a Web API with `unilang`. |
| 108 | +* [⚫] **M7.3: conduct_api_review_and_stabilization:** |
142 | 109 | * **Deliverable:** A final review of the public API, with any necessary breaking changes made before the 1.0 release. |
143 | | -* [⚫] **M5.6: publish_v1_release_candidate:** |
144 | | - * **Prerequisites:** M5.5 |
| 110 | +* [⚫] **M7.4: publish_v1_release_candidate:** |
| 111 | + * **Prerequisites:** M7.3 |
145 | 112 | * **Deliverable:** `unilang` v1.0.0-rc.1 published to crates.io. |
146 | 113 |
|
147 | | -### Phase 6: Post-v1.0 Ecosystem & Advanced Features |
| 114 | +### Phase 8: Post-v1.0 Ecosystem & Advanced Features |
148 | 115 | * **Goal:** Expand the `unilang` ecosystem with new modalities, improved tooling, and advanced integration capabilities. |
149 | 116 | * **Outcome:** A mature and extensible framework that solidifies its position as a universal command-line tool. |
150 | 117 |
|
151 | | -* [⚫] **M6.1: implement_tui_modality_framework:** |
| 118 | +* [⚫] **M8.1: implement_tui_modality_framework:** |
152 | 119 | * **Deliverable:** Utilities and an example for building interactive Textual User Interfaces. |
153 | | -* [⚫] **M6.2: implement_dynamic_routine_loading:** |
154 | | - * **Deliverable:** A robust implementation for `routine_link` that can load routines from dynamic libraries (.so, .dll, .dylib). |
155 | | -* [⚫] **M6.3: implement_advanced_shell_completions:** |
156 | | - * **Deliverable:** Dynamic shell completion logic that provides context-aware suggestions for argument values (e.g., file paths, enum choices). |
157 | | -* [⚫] **M6.4: design_plugin_system:** |
158 | | - * **Deliverable:** A formal specification for a plugin system, allowing third-party crates to provide `unilang` commands to a host application. |
| 120 | +* [⚫] **M8.2: implement_dynamic_routine_loading:** |
| 121 | + * **Deliverable:** A robust implementation for `routine_link` that can load routines from dynamic libraries. |
| 122 | +* [⚫] **M8.3: design_plugin_system:** |
| 123 | + * **Deliverable:** A formal specification for a plugin system, allowing third-party crates to provide `unilang` commands to a host application. |
0 commit comments