{"id":16728267,"url":"https://github.com/tmc/sc","last_synced_at":"2025-08-24T05:05:35.762Z","repository":{"id":37670382,"uuid":"506085906","full_name":"tmc/sc","owner":"tmc","description":"Statecharts","archived":false,"fork":false,"pushed_at":"2025-05-10T00:02:25.000Z","size":170,"stargazers_count":12,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-10T01:18:45.937Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-22T03:35:00.000Z","updated_at":"2025-05-10T00:02:29.000Z","dependencies_parsed_at":"2024-06-19T16:25:01.452Z","dependency_job_id":"22bbcbfc-ca63-4011-bd25-e75c6e41c758","html_url":"https://github.com/tmc/sc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tmc/sc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fsc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fsc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fsc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fsc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmc","download_url":"https://codeload.github.com/tmc/sc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fsc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271795198,"owners_count":24822668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T23:09:30.913Z","updated_at":"2025-08-24T05:05:35.696Z","avatar_url":"https://github.com/tmc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Statecharts: A Formal Model for Reactive Systems\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/tmc/sc.svg)](https://pkg.go.dev/github.com/tmc/sc)\n\n## Abstract\n\nThis repository presents an implementation of the Statecharts formalism, originally introduced by David Harel (1987). Statecharts provide a visual language for the specification and design of complex reactive systems, extending conventional state-transition diagrams with well-defined semantics for hierarchy, concurrency, and communication.\n\nThe implementation provides a language-neutral formal model that supports the rigorous development, analysis, and execution of statechart-based systems. By offering standardized type definitions and operational semantics, this library facilitates the construction of provably correct reactive systems across different programming languages.\n\n## Theoretical Foundation\n\nStatecharts extend classical finite state machines with three key concepts:\n\n1. **Hierarchy** - States can be nested within other states, creating a hierarchical structure that enables abstraction and refinement.\n2. **Orthogonality** - System components can operate concurrently through orthogonal (parallel) states, allowing the decomposition of complex behaviors.\n3. **Communication** - Events can trigger transitions and broadcast to other parts of the system, enabling coordination between components.\n\nThe formal semantics of Statecharts in this implementation follow the reconciled definitions presented in academic literature, particularly von der Beeck's comparison of statechart variants (1994) and Harel and Naamad's operational semantics (1996).\n\n## Features\n\n- Formal type definitions for statecharts, states, events, transitions, and configurations\n- Rigorous implementation of operational semantics for state transitions and event processing\n- Precise handling of state configurations and hierarchical state relationships\n- Validation rules ensuring well-formed statechart models\n- Extensible architecture supporting theoretical extensions and domain-specific adaptations\n\n## Documentation\n\nComprehensive documentation is available in the [docs/statecharts/v1/statecharts.md](./docs/statecharts/v1/statecharts.md) file, providing a formal specification of the Statecharts model, its components, and their semantics.\n\n## Formal Specification\n\nThe formal specification of the Statecharts model is defined using Protocol Buffers. The canonical definitions can be found in:\n\n- [proto/statecharts/v1/statecharts.proto](./proto/statecharts/v1/statecharts.proto) - Core type definitions\n- [proto/statecharts/v1/statechart_service.proto](./proto/statecharts/v1/statechart_service.proto) - Service interface definitions\n- [proto/validation/v1/validator.proto](./proto/validation/v1/validator.proto) - Formal validation rules\n\n## Usage\n\nTo utilize this Statecharts implementation in research or application development, clone the repository or include it as a dependency in your project. The library provides a foundation for formal verification, model checking, and execution of reactive system specifications.\n\n### Go\n\nThe primary implementation is available in Go:\n\n```go\nimport \"github.com/tmc/sc\"\n\n// Create a statechart definition\nstatechart := \u0026sc.Statechart{\n    RootState: \u0026sc.State{\n        Label: \"root\",\n        Children: []*sc.State{\n            {\n                Label:     \"off\",\n                Type:      sc.StateTypeBasic,\n                IsInitial: true,\n            },\n            {\n                Label: \"on\",\n                Type:  sc.StateTypeBasic,\n            },\n        },\n    },\n}\n```\n\n### Rust\n\nA fully-featured Rust SDK is available in the `sdks/rust` directory:\n\n```rust\nuse statecharts::factory::*;\nuse statecharts::v1::*;\n\n// Create states\nlet off_state = basic_state(\"off\", true);\nlet on_state = basic_state(\"on\", false);\n\n// Create root state with children\nlet root = normal_state(\"root\", true, vec![off_state, on_state]);\n\n// Add transition between states\nlet transition = transition(\"PowerOn\", vec![\"off\"], vec![\"on\"], \"POWER_ON\");\n\n// Create the statechart\nlet mut statechart = statechart(root);\nstatechart.transitions.push(transition);\n```\n\nThe Rust SDK includes:\n- Generated Protocol Buffer bindings for all statechart types\n- Factory functions for easier statechart creation\n- Support for hierarchical, orthogonal, and history states\n- Examples demonstrating different statechart patterns\n\nTo generate and build the Rust SDK:\n\n```bash\ncd proto\nmake build-rust\n```\n\nTo run examples:\n\n```bash\ncd sdks/rust\ncargo run --example simple_statechart\ncargo run --example orthogonal_statechart\n```\n\n## Contributing\n\nContributions to the theoretical foundation or implementation of Statecharts are welcomed. Please adhere to rigorous academic standards when proposing modifications or extensions to the model.\n\n## Citations\n\nWhen referencing this implementation in academic work, please cite:\n\n```bibtex\n@misc{tmc2023statecharts,\n  author       = {TMC},\n  title        = {Statecharts: A Formal Implementation of Harel Statecharts},\n  year         = {2023},\n  publisher    = {GitHub},\n  journal      = {GitHub Repository},\n  howpublished = {\\url{https://github.com/tmc/sc}}\n}\n```\n\n## References\n\n- Harel, D. (1987). Statecharts: A visual formalism for complex systems. *Science of Computer Programming, 8(3)*, 231-274.\n- von der Beeck, M. (1994). A comparison of statecharts variants. In *Formal Techniques in Real-Time and Fault-Tolerant Systems*, 128-148.\n- Harel, D., \u0026 Naamad, A. (1996). The STATEMATE semantics of statecharts. *ACM Transactions on Software Engineering and Methodology, 5(4)*, 293-333.\n- Harel, D., \u0026 Politi, M. (1998). *Modeling Reactive Systems with Statecharts: The STATEMATE Approach*. McGraw-Hill.\n\n## License\n\nThis implementation of the Statecharts formalism is available under the [MIT License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fsc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmc%2Fsc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fsc/lists"}