game-learning-runtime 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. game_learning_runtime-0.1.0/.github/CODEOWNERS +2 -0
  2. game_learning_runtime-0.1.0/.github/ISSUE_TEMPLATE/bug.yml +33 -0
  3. game_learning_runtime-0.1.0/.github/dependabot.yml +13 -0
  4. game_learning_runtime-0.1.0/.github/pull_request_template.md +14 -0
  5. game_learning_runtime-0.1.0/.github/workflows/ci.yml +62 -0
  6. game_learning_runtime-0.1.0/.github/workflows/release.yml +52 -0
  7. game_learning_runtime-0.1.0/.github/workflows/reusable-python-ci.yml +56 -0
  8. game_learning_runtime-0.1.0/.gitignore +15 -0
  9. game_learning_runtime-0.1.0/.python-version +1 -0
  10. game_learning_runtime-0.1.0/CHANGELOG.md +22 -0
  11. game_learning_runtime-0.1.0/CODE_OF_CONDUCT.md +10 -0
  12. game_learning_runtime-0.1.0/CONTRIBUTING.md +40 -0
  13. game_learning_runtime-0.1.0/LICENSE +22 -0
  14. game_learning_runtime-0.1.0/PKG-INFO +165 -0
  15. game_learning_runtime-0.1.0/README.md +137 -0
  16. game_learning_runtime-0.1.0/SECURITY.md +20 -0
  17. game_learning_runtime-0.1.0/docs/architecture/data-flow.md +41 -0
  18. game_learning_runtime-0.1.0/docs/architecture/overview.md +66 -0
  19. game_learning_runtime-0.1.0/docs/decisions/0001-learner-neutral-runtime.md +44 -0
  20. game_learning_runtime-0.1.0/docs/decisions/0002-versioned-tensor-contracts.md +45 -0
  21. game_learning_runtime-0.1.0/docs/decisions/README.md +8 -0
  22. game_learning_runtime-0.1.0/docs/guides/getting-started.md +48 -0
  23. game_learning_runtime-0.1.0/docs/planning/roadmap.md +23 -0
  24. game_learning_runtime-0.1.0/docs/product/overview.md +53 -0
  25. game_learning_runtime-0.1.0/docs/runbooks/local-development.md +44 -0
  26. game_learning_runtime-0.1.0/docs/runbooks/release.md +36 -0
  27. game_learning_runtime-0.1.0/pyproject.toml +97 -0
  28. game_learning_runtime-0.1.0/scripts/verify_release.py +25 -0
  29. game_learning_runtime-0.1.0/src/game_learning_runtime/__init__.py +45 -0
  30. game_learning_runtime-0.1.0/src/game_learning_runtime/collector.py +82 -0
  31. game_learning_runtime-0.1.0/src/game_learning_runtime/contracts.py +146 -0
  32. game_learning_runtime-0.1.0/src/game_learning_runtime/environment.py +118 -0
  33. game_learning_runtime-0.1.0/src/game_learning_runtime/errors.py +13 -0
  34. game_learning_runtime-0.1.0/src/game_learning_runtime/examples/__init__.py +9 -0
  35. game_learning_runtime-0.1.0/src/game_learning_runtime/examples/counter.py +94 -0
  36. game_learning_runtime-0.1.0/src/game_learning_runtime/integrations/__init__.py +1 -0
  37. game_learning_runtime-0.1.0/src/game_learning_runtime/integrations/torchrl.py +153 -0
  38. game_learning_runtime-0.1.0/src/game_learning_runtime/protocol/__init__.py +15 -0
  39. game_learning_runtime-0.1.0/src/game_learning_runtime/protocol/glr/v1/runtime.proto +93 -0
  40. game_learning_runtime-0.1.0/src/game_learning_runtime/py.typed +1 -0
  41. game_learning_runtime-0.1.0/src/game_learning_runtime/serialization.py +171 -0
  42. game_learning_runtime-0.1.0/src/game_learning_runtime/specs.py +182 -0
  43. game_learning_runtime-0.1.0/tests/test_collector.py +35 -0
  44. game_learning_runtime-0.1.0/tests/test_contracts.py +62 -0
  45. game_learning_runtime-0.1.0/tests/test_environment.py +87 -0
  46. game_learning_runtime-0.1.0/tests/test_protocol.py +23 -0
  47. game_learning_runtime-0.1.0/tests/test_serialization.py +66 -0
  48. game_learning_runtime-0.1.0/tests/test_specs.py +121 -0
  49. game_learning_runtime-0.1.0/tests_optional/test_torchrl.py +18 -0
  50. game_learning_runtime-0.1.0/uv.lock +2100 -0
@@ -0,0 +1,2 @@
1
+ * @loonghao
2
+
@@ -0,0 +1,33 @@
1
+ name: Bug report
2
+ description: Report a reproducible GLR defect
3
+ title: "bug: "
4
+ labels: [bug]
5
+ body:
6
+ - type: markdown
7
+ attributes:
8
+ value: Do not include secrets, proprietary game data, or unauthorized instrumentation details.
9
+ - type: input
10
+ id: version
11
+ attributes:
12
+ label: GLR version or commit
13
+ validations:
14
+ required: true
15
+ - type: textarea
16
+ id: reproduction
17
+ attributes:
18
+ label: Minimal authorized reproduction
19
+ validations:
20
+ required: true
21
+ - type: textarea
22
+ id: expected
23
+ attributes:
24
+ label: Expected behavior
25
+ validations:
26
+ required: true
27
+ - type: textarea
28
+ id: actual
29
+ attributes:
30
+ label: Actual behavior
31
+ validations:
32
+ required: true
33
+
@@ -0,0 +1,13 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: pip
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
7
+ open-pull-requests-limit: 5
8
+ - package-ecosystem: github-actions
9
+ directory: "/"
10
+ schedule:
11
+ interval: weekly
12
+ open-pull-requests-limit: 5
13
+
@@ -0,0 +1,14 @@
1
+ ## Summary
2
+
3
+ ## Contract impact
4
+
5
+ - [ ] No public contract or schema change
6
+ - [ ] Public contract/schema change is documented and covered by an ADR
7
+
8
+ ## Verification
9
+
10
+ - [ ] Core quality and tests pass
11
+ - [ ] Protocol schema compiles
12
+ - [ ] TorchRL check passes when the integration changes
13
+ - [ ] No secrets, proprietary game data, or unauthorized instrumentation added
14
+
@@ -0,0 +1,62 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ concurrency:
10
+ group: ci-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ core:
18
+ uses: ./.github/workflows/reusable-python-ci.yml
19
+ with:
20
+ python-versions: '["3.10", "3.11", "3.12", "3.13"]'
21
+ sync-args: "--frozen --all-groups"
22
+ lint-command: "uv run ruff check . && uv run ruff format --check . && uv run mypy"
23
+ test-command: 'uv run pytest -m "not torchrl" --cov=game_learning_runtime --cov-report=term-missing'
24
+
25
+ torchrl:
26
+ name: TorchRL 0.13 contract
27
+ runs-on: ubuntu-latest
28
+ timeout-minutes: 25
29
+ steps:
30
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31
+ - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
32
+ with:
33
+ version: "0.11.19"
34
+ python-version: "3.12"
35
+ enable-cache: true
36
+ cache-dependency-glob: uv.lock
37
+ - run: uv sync --frozen --all-groups --extra torchrl
38
+ - run: uv run --extra torchrl mypy src/game_learning_runtime/integrations/torchrl.py
39
+ - run: uv run --extra torchrl pytest tests_optional -m torchrl
40
+
41
+ package:
42
+ name: Build distribution
43
+ needs: [core, torchrl]
44
+ runs-on: ubuntu-latest
45
+ timeout-minutes: 10
46
+ steps:
47
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
48
+ - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
49
+ with:
50
+ version: "0.11.19"
51
+ python-version: "3.12"
52
+ enable-cache: true
53
+ cache-dependency-glob: uv.lock
54
+ - run: uv sync --frozen --all-groups
55
+ - run: uv build
56
+ - run: uv run twine check dist/*
57
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
58
+ with:
59
+ name: python-distributions
60
+ path: dist/
61
+ if-no-files-found: error
62
+ retention-days: 7
@@ -0,0 +1,52 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*.*.*"]
6
+
7
+ concurrency:
8
+ group: release-${{ github.ref }}
9
+ cancel-in-progress: false
10
+
11
+ permissions:
12
+ contents: write
13
+ id-token: write
14
+ attestations: write
15
+
16
+ jobs:
17
+ verify:
18
+ uses: ./.github/workflows/reusable-python-ci.yml
19
+ with:
20
+ python-versions: '["3.12"]'
21
+ sync-args: "--frozen --all-groups"
22
+ lint-command: "uv run ruff check . && uv run ruff format --check . && uv run mypy"
23
+ test-command: 'uv run pytest -m "not torchrl" --cov=game_learning_runtime --cov-report=term-missing'
24
+
25
+ release:
26
+ name: Build and publish GitHub Release
27
+ needs: verify
28
+ runs-on: ubuntu-latest
29
+ timeout-minutes: 15
30
+ steps:
31
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32
+ with:
33
+ fetch-depth: 0
34
+ - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
35
+ with:
36
+ version: "0.11.19"
37
+ python-version: "3.12"
38
+ enable-cache: true
39
+ cache-dependency-glob: uv.lock
40
+ - run: uv sync --frozen --all-groups
41
+ - name: Verify semantic version tag
42
+ run: uv run python scripts/verify_release.py "${{ github.ref_name }}"
43
+ - run: uv build
44
+ - run: uv run twine check dist/*
45
+ - name: Attest distributions
46
+ uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
47
+ with:
48
+ subject-path: "dist/*"
49
+ - name: Create immutable release
50
+ env:
51
+ GH_TOKEN: ${{ github.token }}
52
+ run: gh release create "${{ github.ref_name }}" dist/* --verify-tag --generate-notes --title "${{ github.ref_name }}"
@@ -0,0 +1,56 @@
1
+ name: Reusable uv Python CI
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ python-versions:
7
+ description: JSON array of Python versions
8
+ required: false
9
+ type: string
10
+ default: '["3.12"]'
11
+ sync-args:
12
+ description: Arguments passed to uv sync
13
+ required: false
14
+ type: string
15
+ default: "--frozen --all-groups"
16
+ lint-command:
17
+ description: Quality command executed before tests
18
+ required: false
19
+ type: string
20
+ default: "uv run ruff check . && uv run ruff format --check . && uv run mypy"
21
+ test-command:
22
+ description: Test command
23
+ required: false
24
+ type: string
25
+ default: "uv run pytest"
26
+
27
+ permissions:
28
+ contents: read
29
+
30
+ jobs:
31
+ test:
32
+ name: Python ${{ matrix.python-version }}
33
+ runs-on: ubuntu-latest
34
+ timeout-minutes: 20
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ python-version: ${{ fromJSON(inputs.python-versions) }}
39
+ steps:
40
+ - name: Check out caller repository
41
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
42
+ - name: Install uv and Python
43
+ uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
44
+ with:
45
+ version: "0.11.19"
46
+ python-version: ${{ matrix.python-version }}
47
+ enable-cache: true
48
+ cache-dependency-glob: uv.lock
49
+ - name: Verify lock file
50
+ run: uv lock --check
51
+ - name: Install dependencies
52
+ run: uv sync ${{ inputs.sync-args }}
53
+ - name: Run quality checks
54
+ run: ${{ inputs.lint-command }}
55
+ - name: Run tests
56
+ run: ${{ inputs.test-command }}
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .coverage
5
+ .mypy_cache/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .venv/
9
+ build/
10
+ dist/
11
+ htmlcov/
12
+ .idea/
13
+ .vscode/
14
+ *.log
15
+
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-08-31
10
+
11
+ ### Added
12
+
13
+ - Framework-neutral environment, tensor-tree, time-step, transition, and
14
+ unroll contracts.
15
+ - Fail-closed runtime contract validation.
16
+ - Versioned Protobuf runtime service and JSONL transition records.
17
+ - Optional TorchRL environment adapter.
18
+ - Counter environment example, documentation, reusable CI, and release CD.
19
+
20
+ [Unreleased]: https://github.com/loonghao/GameLearningRuntime/compare/v0.1.0...HEAD
21
+ [0.1.0]: https://github.com/loonghao/GameLearningRuntime/releases/tag/v0.1.0
22
+
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ We are committed to a respectful, harassment-free project for everyone.
4
+ Contributors must be constructive, respect privacy and intellectual property,
5
+ and keep security-sensitive reports private until coordinated disclosure.
6
+
7
+ Maintainers may edit, reject, or remove contributions and participation that
8
+ violate these expectations. Report conduct issues privately through the
9
+ maintainer contact listed in the repository profile.
10
+
@@ -0,0 +1,40 @@
1
+ # Contributing
2
+
3
+ Thanks for helping make game-learning infrastructure reusable.
4
+
5
+ ## Development
6
+
7
+ Prerequisites: Git and [uv](https://docs.astral.sh/uv/).
8
+
9
+ ```powershell
10
+ git clone https://github.com/loonghao/GameLearningRuntime.git
11
+ cd GameLearningRuntime
12
+ uv sync --frozen --all-groups
13
+ uv run ruff check .
14
+ uv run ruff format --check .
15
+ uv run mypy
16
+ uv run pytest -m "not torchrl" --cov=game_learning_runtime --cov-report=term-missing
17
+ uv build
18
+ uv run twine check dist/*
19
+ ```
20
+
21
+ Optional TorchRL contract:
22
+
23
+ ```powershell
24
+ uv sync --frozen --all-groups --extra torchrl
25
+ uv run --extra torchrl pytest tests_optional -m torchrl
26
+ ```
27
+
28
+ ## Change contract
29
+
30
+ - Keep game adapters independent from learning algorithms.
31
+ - Add or update an ADR when changing a public boundary or wire format.
32
+ - Treat protocol and dataset schemas as versioned compatibility contracts.
33
+ - Add adversarial tests for lifecycle, shapes, dtypes, bounds, masks, and stale
34
+ episode/step identity.
35
+ - Use Conventional Commits in English.
36
+ - Do not add game instrumentation unless it is legal, authorized, and isolated
37
+ behind an adapter.
38
+
39
+ Open a pull request only after local checks pass. A maintainer review and green
40
+ required checks are necessary before merge.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 loonghao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.5
2
+ Name: game-learning-runtime
3
+ Version: 0.1.0
4
+ Summary: A universal runtime for connecting games to learning systems and AI agents.
5
+ Project-URL: Documentation, https://github.com/loonghao/GameLearningRuntime#readme
6
+ Project-URL: Issues, https://github.com/loonghao/GameLearningRuntime/issues
7
+ Project-URL: Repository, https://github.com/loonghao/GameLearningRuntime
8
+ Author-email: loonghao <hal.long@outlook.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: environment,game-ai,imitation-learning,reinforcement-learning,torchrl
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: numpy<2.3,>=1.26
24
+ Provides-Extra: torchrl
25
+ Requires-Dist: torch>=2.8; extra == 'torchrl'
26
+ Requires-Dist: torchrl<0.14,>=0.13; extra == 'torchrl'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Game Learning Runtime
30
+
31
+ [![CI](https://github.com/loonghao/GameLearningRuntime/actions/workflows/ci.yml/badge.svg)](https://github.com/loonghao/GameLearningRuntime/actions/workflows/ci.yml)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
33
+ [![Python](https://img.shields.io/badge/Python-3.10--3.13-3776AB.svg)](pyproject.toml)
34
+
35
+ Game Learning Runtime (GLR) is a framework-neutral contract between game
36
+ runtimes and learning systems. A game adapter describes observations, actions,
37
+ action masks, rewards, events, and episode boundaries once; TorchRL, custom PPO
38
+ or IMPALA learners, behavior cloning, offline datasets, evaluators, and QA tools
39
+ can then consume the same interface.
40
+
41
+ > A universal runtime for connecting games to learning systems and AI agents.
42
+
43
+ GLR is intended for games and test environments you own or are authorized to
44
+ instrument. It does not include anti-cheat bypasses, stealth injection, or
45
+ game-specific reverse-engineering code.
46
+
47
+ ## Why this boundary
48
+
49
+ ```text
50
+ Game / simulator
51
+
52
+
53
+ Runtime adapter (C#, C++, Rust, Python, official API, ...)
54
+
55
+
56
+ GLR protocol + environment contract
57
+
58
+ ├── TorchRL
59
+ ├── custom PPO / IMPALA
60
+ ├── BC / DAgger / offline learning
61
+ ├── recorder / replay
62
+ └── evaluation / automated QA
63
+ ```
64
+
65
+ Game adapters never import PPO, IMPALA, BC, or TorchRL. Learning code never
66
+ needs to know whether the game is Unity, Unreal, Source, native, or a test
67
+ simulator. The standardized boundary is the data and lifecycle contract, not a
68
+ single implementation language or transport.
69
+
70
+ ## Implemented in v0.1
71
+
72
+ - Recursive tensor-tree specs for continuous, discrete, multi-discrete, binary,
73
+ hybrid, parameterized, and hierarchical data.
74
+ - A `GameEnvironment` port with reset, step, close, action masks, semantic
75
+ events, terminated/truncated signals, episode IDs, and monotonic step IDs.
76
+ - A fail-closed `ContractEnvironment` wrapper that validates every boundary.
77
+ - Fixed-length actor `Unroll` collection suitable for custom PPO and IMPALA.
78
+ - Versioned `glr.transition.v1` JSONL records for BC, replay, and offline data.
79
+ - A packaged `glr.v1` Protobuf service with unary and bidirectional streaming
80
+ interaction contracts.
81
+ - An optional TorchRL `EnvBase` adapter tested against TorchRL 0.13.
82
+
83
+ Game-specific runtime adapters, generated C#/C++/Rust protocol SDKs,
84
+ distributed actor transport, and learner implementations are roadmap items—not
85
+ features claimed by this initial release.
86
+
87
+ ## Install
88
+
89
+ Until PyPI trusted publishing is enabled, pin a GitHub release tag:
90
+
91
+ ```powershell
92
+ uv add "game-learning-runtime @ git+https://github.com/loonghao/GameLearningRuntime@v0.1.0"
93
+ ```
94
+
95
+ Add the TorchRL integration only where training requires it:
96
+
97
+ ```powershell
98
+ uv add "game-learning-runtime[torchrl] @ git+https://github.com/loonghao/GameLearningRuntime@v0.1.0"
99
+ ```
100
+
101
+ ## Minimal environment
102
+
103
+ ```python
104
+ import numpy as np
105
+
106
+ from game_learning_runtime import ContractEnvironment, SyncCollector
107
+ from game_learning_runtime.examples import CounterEnvironment, always_increment
108
+
109
+ environment = ContractEnvironment(CounterEnvironment(target=3))
110
+ collector = SyncCollector(environment, actor_id="local-actor")
111
+ unroll = collector.collect(always_increment, steps=16, policy_version=0)
112
+
113
+ print(len(unroll.transitions), unroll.total_reward)
114
+ ```
115
+
116
+ Run the complete example from a clone:
117
+
118
+ ```powershell
119
+ uv sync --frozen
120
+ uv run python -c "from game_learning_runtime import *; from game_learning_runtime.examples import *; print(SyncCollector(ContractEnvironment(make_environment())).collect(always_increment, steps=4).total_reward)"
121
+ ```
122
+
123
+ For TorchRL:
124
+
125
+ ```python
126
+ from game_learning_runtime.examples import CounterEnvironment
127
+ from game_learning_runtime.integrations.torchrl import TorchRLEnvironment
128
+
129
+ env = TorchRLEnvironment(CounterEnvironment())
130
+ rollout = env.rollout(max_steps=32)
131
+ ```
132
+
133
+ ## Reuse the CI workflow
134
+
135
+ Any uv-managed Python repository can call the public reusable workflow:
136
+
137
+ ```yaml
138
+ jobs:
139
+ quality:
140
+ uses: loonghao/GameLearningRuntime/.github/workflows/reusable-python-ci.yml@v0.1.0
141
+ with:
142
+ python-versions: '["3.10", "3.12"]'
143
+ sync-args: "--frozen --all-groups"
144
+ lint-command: "uv run ruff check . && uv run mypy"
145
+ test-command: "uv run pytest"
146
+ ```
147
+
148
+ Pin a release tag or commit SHA in production repositories. The workflow never
149
+ receives deployment secrets and only checks out/tests the calling repository.
150
+
151
+ ## Documentation
152
+
153
+ - [Getting started](docs/guides/getting-started.md)
154
+ - [Architecture](docs/architecture/overview.md)
155
+ - [Protocol and data flow](docs/architecture/data-flow.md)
156
+ - [Local development](docs/runbooks/local-development.md)
157
+ - [Release runbook](docs/runbooks/release.md)
158
+ - [Roadmap](docs/planning/roadmap.md)
159
+ - [Architecture decisions](docs/decisions/README.md)
160
+
161
+ ## Contributing and security
162
+
163
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development contract and
164
+ [SECURITY.md](SECURITY.md) for private vulnerability reporting. GLR is licensed
165
+ under the [MIT License](LICENSE).
@@ -0,0 +1,137 @@
1
+ # Game Learning Runtime
2
+
3
+ [![CI](https://github.com/loonghao/GameLearningRuntime/actions/workflows/ci.yml/badge.svg)](https://github.com/loonghao/GameLearningRuntime/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
+ [![Python](https://img.shields.io/badge/Python-3.10--3.13-3776AB.svg)](pyproject.toml)
6
+
7
+ Game Learning Runtime (GLR) is a framework-neutral contract between game
8
+ runtimes and learning systems. A game adapter describes observations, actions,
9
+ action masks, rewards, events, and episode boundaries once; TorchRL, custom PPO
10
+ or IMPALA learners, behavior cloning, offline datasets, evaluators, and QA tools
11
+ can then consume the same interface.
12
+
13
+ > A universal runtime for connecting games to learning systems and AI agents.
14
+
15
+ GLR is intended for games and test environments you own or are authorized to
16
+ instrument. It does not include anti-cheat bypasses, stealth injection, or
17
+ game-specific reverse-engineering code.
18
+
19
+ ## Why this boundary
20
+
21
+ ```text
22
+ Game / simulator
23
+
24
+
25
+ Runtime adapter (C#, C++, Rust, Python, official API, ...)
26
+
27
+
28
+ GLR protocol + environment contract
29
+
30
+ ├── TorchRL
31
+ ├── custom PPO / IMPALA
32
+ ├── BC / DAgger / offline learning
33
+ ├── recorder / replay
34
+ └── evaluation / automated QA
35
+ ```
36
+
37
+ Game adapters never import PPO, IMPALA, BC, or TorchRL. Learning code never
38
+ needs to know whether the game is Unity, Unreal, Source, native, or a test
39
+ simulator. The standardized boundary is the data and lifecycle contract, not a
40
+ single implementation language or transport.
41
+
42
+ ## Implemented in v0.1
43
+
44
+ - Recursive tensor-tree specs for continuous, discrete, multi-discrete, binary,
45
+ hybrid, parameterized, and hierarchical data.
46
+ - A `GameEnvironment` port with reset, step, close, action masks, semantic
47
+ events, terminated/truncated signals, episode IDs, and monotonic step IDs.
48
+ - A fail-closed `ContractEnvironment` wrapper that validates every boundary.
49
+ - Fixed-length actor `Unroll` collection suitable for custom PPO and IMPALA.
50
+ - Versioned `glr.transition.v1` JSONL records for BC, replay, and offline data.
51
+ - A packaged `glr.v1` Protobuf service with unary and bidirectional streaming
52
+ interaction contracts.
53
+ - An optional TorchRL `EnvBase` adapter tested against TorchRL 0.13.
54
+
55
+ Game-specific runtime adapters, generated C#/C++/Rust protocol SDKs,
56
+ distributed actor transport, and learner implementations are roadmap items—not
57
+ features claimed by this initial release.
58
+
59
+ ## Install
60
+
61
+ Until PyPI trusted publishing is enabled, pin a GitHub release tag:
62
+
63
+ ```powershell
64
+ uv add "game-learning-runtime @ git+https://github.com/loonghao/GameLearningRuntime@v0.1.0"
65
+ ```
66
+
67
+ Add the TorchRL integration only where training requires it:
68
+
69
+ ```powershell
70
+ uv add "game-learning-runtime[torchrl] @ git+https://github.com/loonghao/GameLearningRuntime@v0.1.0"
71
+ ```
72
+
73
+ ## Minimal environment
74
+
75
+ ```python
76
+ import numpy as np
77
+
78
+ from game_learning_runtime import ContractEnvironment, SyncCollector
79
+ from game_learning_runtime.examples import CounterEnvironment, always_increment
80
+
81
+ environment = ContractEnvironment(CounterEnvironment(target=3))
82
+ collector = SyncCollector(environment, actor_id="local-actor")
83
+ unroll = collector.collect(always_increment, steps=16, policy_version=0)
84
+
85
+ print(len(unroll.transitions), unroll.total_reward)
86
+ ```
87
+
88
+ Run the complete example from a clone:
89
+
90
+ ```powershell
91
+ uv sync --frozen
92
+ uv run python -c "from game_learning_runtime import *; from game_learning_runtime.examples import *; print(SyncCollector(ContractEnvironment(make_environment())).collect(always_increment, steps=4).total_reward)"
93
+ ```
94
+
95
+ For TorchRL:
96
+
97
+ ```python
98
+ from game_learning_runtime.examples import CounterEnvironment
99
+ from game_learning_runtime.integrations.torchrl import TorchRLEnvironment
100
+
101
+ env = TorchRLEnvironment(CounterEnvironment())
102
+ rollout = env.rollout(max_steps=32)
103
+ ```
104
+
105
+ ## Reuse the CI workflow
106
+
107
+ Any uv-managed Python repository can call the public reusable workflow:
108
+
109
+ ```yaml
110
+ jobs:
111
+ quality:
112
+ uses: loonghao/GameLearningRuntime/.github/workflows/reusable-python-ci.yml@v0.1.0
113
+ with:
114
+ python-versions: '["3.10", "3.12"]'
115
+ sync-args: "--frozen --all-groups"
116
+ lint-command: "uv run ruff check . && uv run mypy"
117
+ test-command: "uv run pytest"
118
+ ```
119
+
120
+ Pin a release tag or commit SHA in production repositories. The workflow never
121
+ receives deployment secrets and only checks out/tests the calling repository.
122
+
123
+ ## Documentation
124
+
125
+ - [Getting started](docs/guides/getting-started.md)
126
+ - [Architecture](docs/architecture/overview.md)
127
+ - [Protocol and data flow](docs/architecture/data-flow.md)
128
+ - [Local development](docs/runbooks/local-development.md)
129
+ - [Release runbook](docs/runbooks/release.md)
130
+ - [Roadmap](docs/planning/roadmap.md)
131
+ - [Architecture decisions](docs/decisions/README.md)
132
+
133
+ ## Contributing and security
134
+
135
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development contract and
136
+ [SECURITY.md](SECURITY.md) for private vulnerability reporting. GLR is licensed
137
+ under the [MIT License](LICENSE).
@@ -0,0 +1,20 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ The latest minor release receives security fixes. This project is currently
6
+ pre-1.0, so public contracts may evolve with documented migration notes.
7
+
8
+ ## Reporting a vulnerability
9
+
10
+ Use GitHub's private vulnerability reporting for this repository. Do not open a
11
+ public issue containing an exploit, token, private game artifact, process dump,
12
+ or proprietary runtime detail.
13
+
14
+ Include the affected version, impact, a minimal authorized reproduction, and
15
+ suggested remediation when available. Maintainers will acknowledge a complete
16
+ report within seven days.
17
+
18
+ GLR does not accept features intended to bypass anti-cheat, hide unauthorized
19
+ instrumentation, or access systems without permission.
20
+