AUTO-MAS-Runtime

module
v0.1.0-beta.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: AGPL-3.0

README

AUTO-MAS Runtime

AUTO-MAS Runtime is the Windows runtime manager for AUTO-MAS. It will provide a single auto-mas-runtime.exe that prepares the managed Go/Python environment, synchronizes the backend workspace, and supervises the backend process.

The project is under active implementation. Start from the documentation index; the architecture and task list remain the source of truth:

Contributors and AI agents must read AGENTS.md before making changes. It covers the toolchain, workflow, coding standards, and hard constraints of this repository.

Responsibilities

Runtime owns local environment setup, managed backend repository updates, dependency synchronization, diagnostics, repair, cleanup, and the backend process lifecycle. It does not proxy AUTO-MAS business HTTP or WebSocket traffic, manage Python plugins, or update its own executable.

Prerequisites

  • Windows 10 or Windows 11
  • PowerShell 7 (pwsh)
  • Go 1.26 or newer
  • MSYS2 UCRT64 GCC/G++ (for CGO and the race detector)
  • golangci-lint 2.12.2 or newer

The commands below use PowerShell 7 syntax.

Install the pinned lint tool when it is not already available:

& go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
if ($LASTEXITCODE -ne 0) { throw "golangci-lint installation failed" }

Build and run

& go build ./...
if ($LASTEXITCODE -ne 0) { throw "build failed" }
& go run ./cmd/auto-mas-runtime
if ($LASTEXITCODE -ne 0) { throw "run failed" }

Local builds without release linker flags keep the stable development placeholders:

auto-mas-runtime dev

Build a release-style Windows x64 executable with PowerShell 7:

$releaseTag = "v0.1.0-beta.1"
$releaseCommit = (& git rev-parse HEAD).Trim()
if ($LASTEXITCODE -ne 0) { throw "unable to resolve release commit" }
$releaseDate = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$releaseLdflags = "-s -w -X github.com/AUTO-MAS-Project/AUTO-MAS-Runtime/internal/version.Version=$releaseTag -X github.com/AUTO-MAS-Project/AUTO-MAS-Runtime/internal/version.Commit=$releaseCommit -X github.com/AUTO-MAS-Project/AUTO-MAS-Runtime/internal/version.BuildDate=$releaseDate"
$env:GOOS = "windows"
$env:GOARCH = "amd64"
$releaseDist = Join-Path (Get-Location) "dist"
New-Item -ItemType Directory -Path $releaseDist -Force -ErrorAction Stop | Out-Null
$releaseExecutable = Join-Path $releaseDist "auto-mas-runtime.exe"
& go build -trimpath -buildvcs=false -ldflags $releaseLdflags -o $releaseExecutable ./cmd/auto-mas-runtime
if ($LASTEXITCODE -ne 0) { throw "release-style build failed" }

The version --output ndjson result details report the injected tag, commit, and build date; the protocol hello.runtimeVersion reports the same injected tag. The project is distributed under AGPL-3.0-or-later; see LICENSE.

Error observation

Official release builds can enable Sentry error observation with the optional GitHub Actions repository secret AUTO_MAS_SENTRY_DSN. The value is injected into the executable at build time; it must be a Sentry project DSN, not a Sentry auth token. If the secret is absent, telemetry remains a no-op. The release workflow does not use PostHog or Umami credentials.

For a one-off local run, set AUTO_MAS_SENTRY_DSN in the current PowerShell 7 process. Set AUTO_MAS_TELEMETRY=disabled to disable Sentry before the SDK is initialized. Runtime reports only sanitized INTERNAL_ERROR and unexpected panic events; it does not enable tracing or log forwarding.

Test and lint

& go test ./...
if ($LASTEXITCODE -ne 0) { throw "tests failed" }
& go vet ./...
if ($LASTEXITCODE -ne 0) { throw "go vet failed" }
& golangci-lint run
if ($LASTEXITCODE -ne 0) { throw "golangci-lint failed" }

Before running the race detector, move the directory containing gcc.exe to the front of the current session's PATH. This prevents similarly named MinGW DLLs from other software directories from loading first:

$gccBin = Split-Path -Parent (Get-Command gcc -ErrorAction Stop).Source
$env:PATH = "$gccBin;$env:PATH"
& go test -race ./... -count=1
if ($LASTEXITCODE -ne 0) { throw "race tests failed" }

Check formatting without changing files:

$goFiles = Get-ChildItem -LiteralPath . -Recurse -Filter "*.go" -File
& gofmt -d $goFiles.FullName
if ($LASTEXITCODE -ne 0) { throw "gofmt check failed" }

Format the project:

$goFiles = Get-ChildItem -LiteralPath . -Recurse -Filter "*.go" -File
& gofmt -w $goFiles.FullName
if ($LASTEXITCODE -ne 0) { throw "gofmt failed" }

Repository layout

cmd/auto-mas-runtime/  Executable entry point
internal/cli/          CLI parsing and application dispatch
internal/protocol/     NDJSON protocol contracts
internal/config/       Configuration and managed directory layout
internal/gitrepo/      Managed backend repository synchronization
internal/uv/           uv, Python, and project environment management
internal/backend/      Backend lifecycle orchestration
internal/process/      Windows process and Job Object integration
internal/health/       Backend health and identity checks
internal/state/        Persistent runtime operation state
internal/lock/         Cross-process coordination
internal/mirror/       Download source selection and rotation
internal/filesystem/   Guarded filesystem operations
internal/logging/      Runtime diagnostics and operation logs
testdata/              Shared component and end-to-end fixtures

Directories

Path Synopsis
cmd
auto-mas-runtime command
Command auto-mas-runtime 管理本机 AUTO-MAS 运行时。
Command auto-mas-runtime 管理本机 AUTO-MAS 运行时。
internal
backend
Package backend 监督受管 Python 后端的生命周期。
Package backend 监督受管 Python 后端的生命周期。
cleanup
Package cleanup 提供受管可丢弃缓存与临时内容的清理服务。
Package cleanup 提供受管可丢弃缓存与临时内容的清理服务。
cli
Package cli 解析命令并把工作委派给应用服务。
Package cli 解析命令并把工作委派给应用服务。
config
Package config 统一管理 Runtime 配置与受管目录布局。
Package config 统一管理 Runtime 配置与受管目录布局。
doctor
Package doctor 提供只读运行环境诊断服务。
Package doctor 提供只读运行环境诊断服务。
filesystem
Package filesystem 提供受管根目录内经过安全校验的文件操作。
Package filesystem 提供受管根目录内经过安全校验的文件操作。
gitrepo
Package gitrepo 管理带版本的受管后端仓库。
Package gitrepo 管理带版本的受管后端仓库。
health
Package health 检查后端的就绪状态与身份。
Package health 检查后端的就绪状态与身份。
lock
Package lock 使用 Windows 命名 Mutex 协调同一物理 app root 的 Runtime 操作。
Package lock 使用 Windows 命名 Mutex 协调同一物理 app root 的 Runtime 操作。
logging
Package logging 写入 Runtime 诊断信息与操作日志。
Package logging 写入 Runtime 诊断信息与操作日志。
mirror
Package mirror 在多个目标等价的下载源之间选择并轮换。
Package mirror 在多个目标等价的下载源之间选择并轮换。
process
Package process 负责 Windows 进程与 Job Object 集成。
Package process 负责 Windows 进程与 Job Object 集成。
protocol
Package protocol 定义单次 Runtime 操作的事件、错误、生命周期、渲染和 stdin 控制契约。
Package protocol 定义单次 Runtime 操作的事件、错误、生命周期、渲染和 stdin 控制契约。
protocol/contracttest
Package contracttest 校验 Runtime 命令发射的原始协议 NDJSON。
Package contracttest 校验 Runtime 命令发射的原始协议 NDJSON。
state
Package state 持久化 Runtime 操作状态与生命周期状态。
Package state 持久化 Runtime 操作状态与生命周期状态。
telemetry
Package telemetry 隔离运行质量遥测与内部错误观测 provider。
Package telemetry 隔离运行质量遥测与内部错误观测 provider。
uv
Package uv 管理 uv、Python 与主项目环境。
Package uv 管理 uv、Python 与主项目环境。
version
Package version 提供 Runtime 版本与构建信息的注入点。
Package version 提供 Runtime 版本与构建信息的注入点。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL