-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from WolderLabs/13-orchestration-stub
Lots of updates, still in POC mode.
- Loading branch information
Showing
85 changed files
with
1,513 additions
and
815 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
default: true | ||
|
||
# Allow arbitrary line length | ||
# | ||
# Reason: We apply the one-sentence-per-line rule. A sentence may get longer than 80 characters, especially if links are contained. | ||
# | ||
# Details: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013---line-length | ||
MD013: false | ||
|
||
# Allow duplicate headings | ||
# | ||
# Reasons: | ||
# | ||
# - The chosen option is considerably often used as title of the ADR (e.g., ADR-0015). Thus, that title repeats. | ||
# - We use "Examples" multiple times (e.g., ADR-0010). | ||
# - Markdown lint should support the user and not annoy them. | ||
# | ||
# Details: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md024---multiple-headings-with-the-same-content | ||
MD024: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
date: 2024-02-06 | ||
author: rebelzach using ChatGPT for feedback and revision | ||
--- | ||
# Caching and State Tracking in Action Calls | ||
|
||
## Context | ||
|
||
A primary goal of Wolder is to allow easily changing the generator code, and then quickly re-running the generator to see what influence that change has on the output. State caching of action inputs and outputs is an important optimization so that only actions affected by a data or code change need to be re-run. It's assumed that Wolder implements caching during action invocation, creating a consistent caching interface. This approach is influenced by Microsoft's durable task library. The challenge lies in selecting an invocation and caching method that offers clarity and ease of use for developers. | ||
|
||
## Decision Drivers | ||
|
||
- **Clarity** | ||
- **Ease of Use** | ||
|
||
## Options Considered | ||
|
||
1. **Middleware-Based Dispatch**: Utilizes a middleware interface by Wolder, akin to the durable task library, to intercept action calls. | ||
2. **Dynamic Proxy Library**: Employs libraries like Castle.DynamicProxy for intercepting actions marked with a specific interface or attribute. | ||
|
||
## Decision | ||
|
||
**Chosen Option**: Middleware-Based Dispatch. | ||
Choosing middleware-based dispatch aligns with the priorities of clarity and ease of use. This option maintains explicitness in how actions are intercepted and processed. Additionally, it offers flexibility and a clean separation of concerns, essential for maintainable and scalable development. There is a risk that middleware could make it more difficult for new developers to understand the workflow. These risks are hopefully outweighed by the risks presented by dynamic proxies, such as debugging challenges and confusion over expected behavior. | ||
|
||
## Evaluation | ||
|
||
### Middleware-Based Dispatch | ||
|
||
- **Pros**: | ||
- **Customizability**: Facilitates easy modifications to dispatch behaviors via middleware components. | ||
- **Separation of Concerns**: Isolates cross-cutting concerns like caching from generator logic. | ||
|
||
- **Cons**: | ||
- **Complexity**: Adds system complexity, which might be challenging for those unfamiliar with middleware patterns. | ||
|
||
### Dynamic Proxy Library | ||
|
||
- **Pros**: | ||
- **Convenience**: Allows for interception of actions with minimal code changes. | ||
- **Flexibility**: Allows for making underlying behavior changes without requiring updating or version APIs. | ||
|
||
- **Cons**: | ||
- **Debugging Difficulty**: Might obscure the debugging process, complicating error resolution. | ||
- **Cognitive Overload**: Increases the learning curve and cognitive load for developers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
# These are optional elements. Feel free to remove any of them. | ||
status: "{proposed | rejected | accepted | deprecated | … | superseded by [ADR-0005](0005-example.md)}" | ||
date: {YYYY-MM-DD when the decision was last updated} | ||
deciders: {list everyone involved in the decision} | ||
consulted: {list everyone whose opinions are sought (typically subject-matter experts); and with whom there is a two-way communication} | ||
informed: {list everyone who is kept up-to-date on progress; and with whom there is a one-way communication} | ||
--- | ||
# {short title of solved problem and solution} | ||
|
||
## Context and Problem Statement | ||
|
||
{Describe the context and problem statement, e.g., in free form using two to three sentences or in the form of an illustrative story. | ||
You may want to articulate the problem in form of a question and add links to collaboration boards or issue management systems.} | ||
|
||
<!-- This is an optional element. Feel free to remove. --> | ||
## Decision Drivers | ||
|
||
* {decision driver 1, e.g., a force, facing concern, …} | ||
* {decision driver 2, e.g., a force, facing concern, …} | ||
* … <!-- numbers of drivers can vary --> | ||
|
||
## Considered Options | ||
|
||
* {title of option 1} | ||
* {title of option 2} | ||
* {title of option 3} | ||
* … <!-- numbers of options can vary --> | ||
|
||
## Decision Outcome | ||
|
||
Chosen option: "{title of option 1}", because | ||
{justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force {force} | … | comes out best (see below)}. | ||
|
||
<!-- This is an optional element. Feel free to remove. --> | ||
### Consequences | ||
|
||
* Good, because {positive consequence, e.g., improvement of one or more desired qualities, …} | ||
* Bad, because {negative consequence, e.g., compromising one or more desired qualities, …} | ||
* … <!-- numbers of consequences can vary --> | ||
|
||
<!-- This is an optional element. Feel free to remove. --> | ||
## Pros and Cons of the Options | ||
|
||
### {title of option 1} | ||
|
||
<!-- This is an optional element. Feel free to remove. --> | ||
{example | description | pointer to more information | …} | ||
|
||
* Good, because {argument a} | ||
* Good, because {argument b} | ||
<!-- use "neutral" if the given argument weights neither for good nor bad --> | ||
* Neutral, because {argument c} | ||
* Bad, because {argument d} | ||
* … <!-- numbers of pros and cons can vary --> | ||
|
||
### {title of other option} | ||
|
||
{example | description | pointer to more information | …} | ||
|
||
* Good, because {argument a} | ||
* Good, because {argument b} | ||
* Neutral, because {argument c} | ||
* Bad, because {argument d} | ||
* … |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Decisions | ||
|
||
This directory contains decision records for Wolder. These are not meant to be overly formal. The point is to help document development choices, people forget things and new contributors might need the context. | ||
|
||
There is a [decision-template.md](decision-template.md) available, if helpful. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
|
||
# Wolder | ||
|
||
A Polyglot Structured Code Generator Built on .NET | ||
A Structured Polyglot Code Generator Built on .NET | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,69 @@ | ||
using Wolder.CommandLine; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Wolder.CommandLine; | ||
using Wolder.CommandLine.Actions; | ||
using Wolder.Core; | ||
using Wolder.Core.Pipeline; | ||
using Wolder.Core.Workspace; | ||
using Wolder.CSharp; | ||
using Wolder.CSharp.Actions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
var builder = Host.CreateApplicationBuilder(); | ||
builder.Logging.AddConsole(); | ||
|
||
var services = builder.Services; | ||
|
||
services.AddDeGA(builder.Configuration.GetSection("Wolder")) | ||
.AddCommandLineActions() | ||
.AddCSharpActions(); | ||
builder.Services.AddWolder(builder.Configuration.GetSection("Wolder")); | ||
|
||
var host = builder.Build(); | ||
|
||
var pipelineBuilder = host.Services.GetRequiredService<GeneratorPipelineBuilder>(); | ||
|
||
var pipeline = pipelineBuilder.Build("FizzBuzz.Basic.Output"); | ||
await host.Services.GetRequiredService<GeneratorWorkspaceBuilder>() | ||
.AddCommandLineActions() | ||
.AddCSharpActions() | ||
.InvokeAsync<CreateFizzBuzz>("FizzBuzz.Basic.Output"); | ||
|
||
var mainProject = new DotNetProjectReference("FizzBuzz/FizzBuzz.csproj"); | ||
class CreateFizzBuzz( | ||
CommandLineActions commandLine, | ||
CSharpActions csharp) : IVoidAction | ||
{ | ||
public async Task InvokeAsync() | ||
{ | ||
await csharp.CreateSdkGlobalAsync( | ||
new CreateSdkGlobalParameters(DotNetSdkVersion.Net8)); | ||
|
||
var mainProject = new DotNetProjectReference("FizzBuzz/FizzBuzz.csproj", "FizzBuzz"); | ||
|
||
await commandLine.ExecuteCommandLineAsync( | ||
new ExecuteCommandLineParameters( | ||
$"dotnet new console -n {mainProject.Name}")); | ||
|
||
pipeline | ||
.AddStep(ctx => new CreateSdkGlobal(DotNetSdkVersion.Net8)) | ||
.AddStep(ctx => | ||
new CreateProject(mainProject, """ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
</Project> | ||
""")) | ||
.AddStep(ctx => | ||
new CreateClass(mainProject, "Program", """ | ||
for (int i = 1; i <= 100; i++) | ||
{ | ||
if (i % 3 == 0 && i % 5 == 0) | ||
await csharp.CreateClassAsync( | ||
new CreateClassParameters( | ||
mainProject, | ||
"Program", | ||
""" | ||
for (int i = 1; i <= 100; i++) | ||
{ | ||
Console.WriteLine("FizzBuzz"); | ||
if (i % 3 == 0 && i % 5 == 0) | ||
{ | ||
Console.WriteLine("FizzBuzz"); | ||
} | ||
else if (i % 3 == 0) | ||
{ | ||
Console.WriteLine("Fizz"); | ||
} | ||
else if (i % 5 == 0) | ||
{ | ||
Console.WriteLine("Buzz"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine(i); | ||
} | ||
} | ||
else if (i % 3 == 0) | ||
{ | ||
Console.WriteLine("Fizz"); | ||
} | ||
else if (i % 5 == 0) | ||
{ | ||
Console.WriteLine("Buzz"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine(i); | ||
} | ||
} | ||
""")) | ||
.AddStep(ctx => | ||
new CompileProject(mainProject)) | ||
.AddStep(ctx => | ||
new RunCommand("dotnet run", mainProject.RelativeRoot, Interactive: true)); | ||
|
||
await pipeline.RunAsync(); | ||
""")); | ||
await csharp.CompileProjectAsync(new CompileProjectParameters(mainProject)); | ||
|
||
await commandLine.ExecuteCommandLineAsync( | ||
new ExecuteCommandLineParameters( | ||
"dotnet run", mainProject.RelativeRoot, Interactive: true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,54 @@ | ||
using Wolder.CommandLine; | ||
using Wolder.CommandLine.Actions; | ||
using Wolder.Core; | ||
using Wolder.Core.Pipeline; | ||
using Wolder.Core; | ||
using Wolder.CSharp; | ||
using Wolder.CSharp.Actions; | ||
using Wolder.CSharp.OpenAI; | ||
using Wolder.CSharp.OpenAI.Actions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Wolder.CommandLine; | ||
using Wolder.CommandLine.Actions; | ||
using Wolder.Core.Workspace; | ||
|
||
var builder = Host.CreateApplicationBuilder(); | ||
builder.Logging.AddConsole(); | ||
|
||
var services = builder.Services; | ||
|
||
services.AddDeGA(builder.Configuration.GetSection("Wolder")) | ||
.AddCommandLineActions() | ||
.AddCSharpGeneration(); | ||
services.AddWolder(builder.Configuration.GetSection("Wolder")); | ||
|
||
var host = builder.Build(); | ||
|
||
var pipelineBuilder = host.Services.GetRequiredService<GeneratorPipelineBuilder>(); | ||
|
||
var pipeline = pipelineBuilder.Build("FizzBuzz.OpenAI.Output"); | ||
|
||
var mainProject = new DotNetProjectReference("FizzBuzz/FizzBuzz.csproj"); | ||
|
||
pipeline | ||
.AddStep(ctx => new CreateSdkGlobal(DotNetSdkVersion.Net8)) | ||
.AddStep(ctx => | ||
new CreateProject(mainProject, """ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
</Project> | ||
""")) | ||
.AddStep(ctx => | ||
new GenerateClass( | ||
mainProject, | ||
"Program", | ||
"A main method that implements the common fizz buzz app.")) | ||
.AddStep(ctx => | ||
new CompileProject(mainProject)) | ||
.AddStep(ctx => | ||
new RunCommand("dotnet run", mainProject.RelativeRoot, Interactive: true)); | ||
|
||
await pipeline.RunAsync(); | ||
await host.Services.GetRequiredService<GeneratorWorkspaceBuilder>() | ||
.AddCommandLineActions() | ||
.AddCSharpGeneration() | ||
.InvokeAsync<GenerateFizzBuzz>("FizzBuzz.OpenAI.Output"); | ||
|
||
class GenerateFizzBuzz( | ||
CommandLineActions commandLine, | ||
CSharpActions csharp, | ||
CSharpGenerator csharpGenerator) : IVoidAction | ||
{ | ||
public async Task InvokeAsync() | ||
{ | ||
await csharp.CreateSdkGlobalAsync( | ||
new CreateSdkGlobalParameters(DotNetSdkVersion.Net8)); | ||
|
||
var mainProject = new DotNetProjectReference("FizzBuzz/FizzBuzz.csproj", "FizzBuzz"); | ||
|
||
await commandLine.ExecuteCommandLineAsync( | ||
new ExecuteCommandLineParameters( | ||
$"dotnet new console -n {mainProject.Name}")); | ||
|
||
await csharpGenerator.GenerateClassAsync( | ||
new GenerateClassParameters( | ||
mainProject, | ||
"", | ||
"Program", | ||
"A main method that implements the common fizz buzz app.")); | ||
|
||
await commandLine.ExecuteCommandLineAsync( | ||
new ExecuteCommandLineParameters( | ||
"dotnet run", mainProject.RelativeRoot)); | ||
} | ||
} |
Oops, something went wrong.