|
| 1 | +## Repository Description |
| 2 | +- `subroutines` provides the lifecycle engine used by Platform Mesh controllers and operators. |
| 3 | +- The main exported areas are subroutine orchestration, typed reconciliation `Result` values, condition management, spread scheduling, finalizer handling, and metrics. |
| 4 | +- This is a Go library repo built around [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) and [multicluster-runtime](https://github.com/platform-mesh/multicluster-runtime). |
| 5 | +- Read the org-wide [AGENTS.md](https://github.com/platform-mesh/.github/blob/main/AGENTS.md) for general conventions. |
| 6 | + |
| 7 | +## Core Principles |
| 8 | +- Keep changes small and local. Behavior changes here can ripple into multiple downstream operators. |
| 9 | +- Prefer extending existing lifecycle patterns over introducing parallel orchestration abstractions. |
| 10 | +- Verify behavior before finishing. Start with focused package tests, then broader validation if needed. |
| 11 | +- Keep this file focused on agent execution and repository-specific constraints. |
| 12 | + |
| 13 | +## Project Structure |
| 14 | +- `subroutines`: core interfaces and typed `Result` helpers. |
| 15 | +- `lifecycle`: orchestration engine that runs subroutines and coordinates reconciliation flow. |
| 16 | +- `conditions`: condition management helpers for subroutine and aggregate readiness. |
| 17 | +- `spread`: helpers for spreading reconciliation work over time. |
| 18 | +- `metrics`: Prometheus metrics for subroutine execution. |
| 19 | + |
| 20 | +## Architecture |
| 21 | +This is a dependency repo, not a runnable service. Small semantic changes can affect many controllers. |
| 22 | + |
| 23 | +### Lifecycle model |
| 24 | +- The core abstraction is the ordered execution of subroutines that return typed `Result` values such as `OK`, `Pending`, and `Stop`. |
| 25 | +- `lifecycle` owns reconciliation flow semantics, finalizer handling, and status/condition integration. |
| 26 | +- `conditions` is the supported path for condition aggregation; avoid inventing alternative condition wiring in this repo. |
| 27 | + |
| 28 | +### Downstream impact |
| 29 | +- Several Platform Mesh operators depend on this library for reconcile ordering and readiness semantics. |
| 30 | +- A change that looks local, such as altering `Result` handling or condition updates, can change runtime behavior across multiple repositories. |
| 31 | + |
| 32 | +## Commands |
| 33 | +- `task lint` — run formatting and golangci-lint. |
| 34 | +- `task test` — run the standard local unit test flow. |
| 35 | +- `task cover` — run tests with coverage output. |
| 36 | +- `task test-coverage` — enforce coverage thresholds from `.testcoverage.yml`. |
| 37 | +- `task validate` — run the standard validation flow. |
| 38 | +- `go test ./<pkg>` — fast fallback for targeted package verification. |
| 39 | + |
| 40 | +## Code Conventions |
| 41 | +- Preserve public package APIs unless the change is intentionally coordinated with downstream consumers. |
| 42 | +- Add or update `_test.go` files alongside behavior changes. |
| 43 | +- Follow the existing package split instead of introducing new umbrella utility packages. |
| 44 | +- Keep logging, metrics, and condition semantics explicit and predictable. |
| 45 | + |
| 46 | +## Generated Artifacts |
| 47 | +- Mocks and generated outputs should be regenerated through the repo workflows, not hand-edited. |
| 48 | +- Review coverage-related changes carefully when touching core lifecycle behavior. |
| 49 | + |
| 50 | +## Do Not |
| 51 | +- Change `Result` semantics casually. |
| 52 | +- Hand-edit generated outputs if a repo workflow exists to regenerate them. |
| 53 | +- Update `.testcoverage.yml` unless the task explicitly requires it. |
| 54 | + |
| 55 | +## Hard Boundaries |
| 56 | +- Do not invent new local workflows when a `task` target already exists. |
| 57 | +- Ask before making changes that intentionally break compatibility for downstream operators. |
| 58 | + |
| 59 | +## Human-Facing Guidance |
| 60 | +- Use `README.md` for local setup and rough architecture context. |
| 61 | +- Use `CONTRIBUTING.md` for contribution process, DCO, and broader developer workflow expectations. |
0 commit comments