Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .clang-format

This file was deleted.

25 changes: 14 additions & 11 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Checkout Project
uses: actions/checkout@v4
with:
submodules: "recursive"
uses: actions/checkout@v5

- name: Perform Commit Linting
uses: wagoid/commitlint-github-action@v6

- name: Check Clang Formatting
uses: RafikFarhad/clang-format-github-action@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26.5'

- name: Check Code Formatting
uses: wearerequired/lint-action@v2
with:
sources: "src/**/*.h,src/**/*.cpp"
style: file
gofmt: true
continue_on_error: false

- name: Build Project
uses: threeal/cmake-action@v2
- name: Build
run: make build

- name: Test Project
uses: threeal/ctest-action@v1
- name: Test
run: make test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea
cmake-build-*
**/build
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "3rd/googletest"]
path = 3rd/googletest
url = git@github.com:google/googletest.git
[submodule "spec"]
path = spec
url = git@github.com:CollaborativeStateMachines/Spec.git

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pin to a commit hash.

8 changes: 0 additions & 8 deletions 3rd/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion 3rd/googletest
Submodule googletest deleted from 52eb81
6 changes: 0 additions & 6 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ contributions.
---

## 📦 Third-Party Libraries

### GoogleTest
* **License:** BSD 3-Clause "New" or "Revised" License
* **Source:** https://github.com/google/googletest
* **Copyright:** (c) 2008, Google Inc.
* **Description:** Used for unit testing.
30 changes: 0 additions & 30 deletions CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion CMakeOptions.txt

This file was deleted.

22 changes: 4 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,11 @@ and procedural guidelines. Please ensure your contributions align with the follo

## 🛠 Engineering Standards

### C++ Style Guidelines
We adhere to a "good taste" philosophy. Beyond typical clean code practices, we enforce the following:

* **RAII & Const-Correctness:** These are non-negotiable. Manage resources through object lifetime and ensure logical
constancy across the API.
* **Trailing Return Types:** All function declarations must use trailing return type syntax:
```cpp
auto calculate_metrics(int value) -> double;
```
* **Exception Safety:** Mark all non-exception-throwing code paths as `noexcept`.
* **Early Escapes:** Avoid deeply nested branches. Prefer `if (condition) return;` to keep the primary logic at a
shallow indentation level.
* **Defensive Programming:** Write code that anticipates and handles invalid states or inputs gracefully.
* **Consistency:** Above all, match the surrounding code. New contributions should seat naturally into the existing
architecture.

### Tooling
* **Formatting:** We use **Clang Format**. Before submitting, ensure your code matches the project's `.clang-format`
specification.
* **Formatting:** We use **gofmt**. Before submitting, ensure your code is formatted:
```bash
go fmt ./...
```
* **Originality:** We value the craft of programming. While Generative AI is a valid productivity tool, we expect you to
understand and own the logic you submit.

Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: test build clean run

test:
go test ./...

build:
@mkdir -p build/casem
go build -o build/casem/casem ./cmd/casem.go

clean:
rm -rf build

run: test build
./build/casem/casem
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Casem

## Project Strucutre

```bash
Casem/
├── ATTRIBUTION.md
├── cmd
│ └── casem.go # Application Entry Point
├── CONTRIBUTING.md
├── CONTRIBUTORS
├── csm # Public CSM Package: Defines API to implement CSM via Go
├── go.mod
├── internal # Internal Application Logic
├── LICENSE
├── Makefile
├── README.md
└── spec # Language Specification
```
7 changes: 7 additions & 0 deletions cmd/casem.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello Casem")
}
33 changes: 33 additions & 0 deletions csm/context_variable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package csm

import (
"errors"
"fmt"
"strings"
)

type ContextVariable interface {
String() string
}

type typedVariable[T any] struct {
name string
value T

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably have to adapt this later.

}

func NewContextVariable[T any](name string, value T) (ContextVariable, error) {
if strings.TrimSpace(name) == "" {
return nil, errors.New("name cannot be blank")
}
return &typedVariable[T]{
name: name,
value: value,
}, nil
}

func (cv *typedVariable[T]) String() string {
if cv == nil {
return "<nil>"
}
return fmt.Sprintf("ContextVariable(name=%q, value=%+v)", cv.name, cv.value)
}
14 changes: 14 additions & 0 deletions csm/context_variable_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package csm

import "testing"

func TestNewContextVariable(t *testing.T) {
_, err := NewContextVariable("a", 1)
if err != nil {
t.Errorf("Expected no error but received: %v", err)
}
_, err = NewContextVariable("", 1)
if err == nil {
t.Errorf("Expected error but received: %v", err)
}
}
46 changes: 46 additions & 0 deletions csm/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package csm

import "fmt"

type EventChannel int

const (
Internal EventChannel = iota
External
Peripheral
)

type Event struct {
Topic string
Channel EventChannel
Data []ContextVariable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because event serialization may become messy here.

Target string
Source string
}

type ConditionalEvent struct {
Event
Provided Expression
}

func (c EventChannel) String() string {
switch c {
case Internal:
return "Internal"
case External:
return "External"
case Peripheral:
return "Peripheral"
default:
return fmt.Sprintf("UnknownChannel(%d)", c)
}
}

func (e Event) String() string {
return fmt.Sprintf("Event(topic=%q, channel=%s, target=%q, source=%q)",
e.Topic, e.Channel, e.Target, e.Source)
}

func (e ConditionalEvent) String() string {
return fmt.Sprintf("ConditionalEvent(provided=%q, event=%+v)", e.Provided, e.Event)
}
9 changes: 9 additions & 0 deletions csm/expression.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package csm

import "fmt"

type Expression string

func (e Expression) String() string {
return fmt.Sprintf("expression=%v", string(e))
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/CollaborativeStateMachines/Casem

go 1.26.5
Empty file added go.sum
Empty file.
1 change: 1 addition & 0 deletions internal/util/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package util
1 change: 1 addition & 0 deletions spec
Submodule spec added at 277125
5 changes: 0 additions & 5 deletions src/CMakeLists.txt

This file was deleted.

9 changes: 0 additions & 9 deletions src/casem/main.cpp

This file was deleted.

12 changes: 0 additions & 12 deletions test/CMakeLists.txt

This file was deleted.

7 changes: 0 additions & 7 deletions test/casem/test.cpp

This file was deleted.

Loading