aw-index-cli 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.
@@ -0,0 +1,232 @@
1
+ # aw-index-cli — envisioned architecture & plan
2
+
3
+ The **to-be** companion to [`initial-architecture.md`](initial-architecture.md)
4
+ (the verified as-is). This is the target design for the full CLI — the four
5
+ unbuilt commands, the workspace-state model they share, and the release/CI path
6
+ — plus a phased roadmap. Forward-looking; revise as decisions land. Today only
7
+ `compose` exists; `import`/`sync`/`check`/`refresh` are argparse stubs that exit 2.
8
+
9
+ ## Design north star
10
+
11
+ Stay a **thin, honest consumer** of the autoware-index registry. The CLI never
12
+ validates, builds, or resolves Autoware versions — those are the registry's
13
+ sweeps. It composes selections into a workspace and reports what the registry
14
+ already knows. Inherited values, non-negotiable: **fail loud, never
15
+ silent-empty**; **deterministic/diffable output**; **one clone per repository**;
16
+ **pure transforms with I/O at the edges**; **offline-capable where possible**;
17
+ **never invent a green** (registry locked decision 6).
18
+
19
+ ## The pivotal decision: a lockfile sidecar
20
+
21
+ Every unbuilt command must answer *"what was previously reconciled, and against
22
+ which registry state?"* — and the `.repos` file alone cannot: it omits the
23
+ registry commit, the `--tags` filter, and the resolved sha, and a `branch`
24
+ ref's `value` carries no pinned commit. Three options were weighed
25
+ (fully-stateless / lockfile sidecar / provenance embedded in the `.repos`
26
+ header); **the sidecar wins**.
27
+
28
+ **`repositories/<name>.lock.json`** sits next to `repositories/<name>.repos`
29
+ (same `<name>`, default `autoware-index`), discovered by the same
30
+ `find_repo_root` walk-up. The `.repos` stays vcstool's contract (*what to
31
+ clone*); the lock is the CLI's (*what was composed, against which registry
32
+ commit, resolved to which shas*). It is JSON (signals "generated, don't
33
+ hand-edit"), sorted, and carries no wall-clock timestamp by default — so it
34
+ diffs cleanly, mirroring `compose --no-timestamp`.
35
+
36
+ ```json
37
+ {
38
+ "lock_version": 1,
39
+ "tool_version": "0.1.0",
40
+ "rosdistro": "jazzy",
41
+ "tags": ["sensing", "perception"],
42
+ "registry": {
43
+ "source": "github",
44
+ "repo": "autowarefoundation/autoware-index",
45
+ "ref": "main",
46
+ "commit": "b42b44f0c3a19d8e7f1c2b3a4d5e6f7081929394",
47
+ "path": null
48
+ },
49
+ "repositories": {
50
+ "livox-tools": {
51
+ "url": "https://github.com/autowarefoundation/autoware_livox_tag_filter",
52
+ "ref": { "kind": "branch", "value": "main" },
53
+ "resolved_sha": "6d9ff3512ab7c4e9018273645f8a9b0c1d2e3f40",
54
+ "packages": ["autoware_livox_decoder", "autoware_livox_tag_filter"]
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ Field notes: `tags: null` = composed with no filter (all); `[]` = explicitly
61
+ empty. `registry.commit` is the resolved registry sha (filled for github when
62
+ resolvable; `null` for a local path). `resolved_sha` is `null` after `compose`
63
+ (which stays offline/pure) and **filled by `import`/`sync`** from the clone HEAD
64
+ vcstool actually produced; for `kind: sha` it equals `value`.
65
+
66
+ **Why not stateless (the tempting option):** the registry itself isn't fully
67
+ stateless — it keeps `state/<distro>/<repo_name>.json` cursors precisely because
68
+ a level-trigger needs a recorded baseline to diff against. `sync`/`check` face
69
+ the identical problem, so the same precedent applies one repo over. Stateless
70
+ would also make a tag-scoped workspace spuriously report every other repo as a
71
+ pending *remove* (no record of the tag filter), and would have no pinned sha to
72
+ diff a `branch` ref against offline.
73
+
74
+ **Cost to manage:** a second artifact that can drift from the `.repos` if
75
+ hand-edited. Mitigation: every lock-consuming command runs a **lock-vs-`.repos`
76
+ agreement check up front** and fails loud (new `LockError`) on mismatch.
77
+ `compose` builds both from the *same* `select_repositories` result, so they
78
+ agree by construction.
79
+
80
+ ## The five commands, envisioned
81
+
82
+ | Command | Role | Network | Writes |
83
+ |---|---|---|---|
84
+ | `compose` | registry selection → `.repos` (+ lock) | optional fetch | `.repos`, `.lock.json` |
85
+ | `import` | `compose` + `vcs import` + back-fill resolved shas | clone | `.repos`, `.lock.json`, `src/` |
86
+ | `sync` | reconcile imported workspace ↔ current registry | fetch + targeted clones | `.repos`, `.lock.json`, `src/` |
87
+ | `check` | honest status from the data branch (CI gate) | one branch fetch | nothing (read-only) |
88
+ | `refresh` | refresh the local registry/data cache | fetch | cache only |
89
+
90
+ All reuse the existing pure modules — `registry.load_distribution` /
91
+ `describe_source` (the single version-gated source loader — no command adds a
92
+ second fetch or a second schema gate), `compose.select_repositories` /
93
+ `to_repos_entries` / `render_repos` / `provenance_header`, and
94
+ `workspace.find_repo_root` / `output_path` (plus new siblings `lock_path` and
95
+ `src_dir`).
96
+
97
+ ### `compose` (evolves)
98
+ Externally unchanged except it now also emits `repositories/<name>.lock.json`
99
+ beside the `.repos`, built by a new **pure** `compose.build_lock(distribution,
100
+ *, tags, registry, tool_version) -> dict` that reuses `select_repositories` so
101
+ the two artifacts are consistent by construction. `resolved_sha` is `null` at
102
+ this stage; `registry.commit` is filled when the github fetch resolves a sha.
103
+ Still offline/pure; `--stdout` still writes nothing to disk.
104
+
105
+ ### `import`
106
+ The one-step materializer: resolve + select exactly like `compose`, write both
107
+ artifacts, then `vcs import < repositories/<name>.repos` into
108
+ `workspace.src_dir(repo_root)`, and finally read each clone's HEAD
109
+ (`git -C <dir> rev-parse HEAD`) to back-fill `resolved_sha` into the lock. A
110
+ **thin wrapper** — it never re-resolves refs or clones twice; it records what
111
+ vcstool checked out. Reuses compose's flags verbatim (`--rosdistro`, `--tags`,
112
+ `--registry-*`, `--repo-root`, `--name`), plus `--dry-run`. Re-running is
113
+ self-reconciling (deterministic artifacts; `vcs import` re-checks the same
114
+ versions).
115
+
116
+ ### `sync`
117
+ Load the lock (prior intent: rosdistro + the exact `--tags` + registry
118
+ coordinates + per-repo ref/sha/packages), re-read the **same** registry source,
119
+ recompose the **same** selection (`select_repositories(distribution,
120
+ tags=lock["tags"])` — this is what stops a tag-scoped workspace from reporting
121
+ every other repo as a remove), and diff per `repo_name` into **adds / removes /
122
+ ref-changes / package-set-changes**. `--dry-run` reports the plan
123
+ deterministically; `--apply` rewrites both artifacts and re-checks out only
124
+ changed/added entries (one clone or `ls-remote` each, honoring
125
+ one-clone-per-repository). Removes are **warned, never auto-deleted** (don't
126
+ destroy user work); `--force-checkout` is required to move a clone with local
127
+ changes. Re-running after a clean apply is a no-op.
128
+
129
+ ### `check` — the honest-status probe (CI gate)
130
+ Joins three real sources per registered package the consumer depends on
131
+ (optionally narrowed to `--tags` and/or packages actually present in the
132
+ workspace):
133
+ 1. **registry main** via `load_distribution` (same schema-2 gate) — `url`,
134
+ `ref`, `packages`;
135
+ 2. **data branch history** `history/<distro>/<package>.ndjson` — folding v1
136
+ (no `schema` field) and v2 lines;
137
+ 3. the **workspace** — each clone's HEAD sha (and the lock's `resolved_sha`).
138
+
139
+ Reports per package: `current_status` (latest-by-`at` record: pass | fail |
140
+ **unknown** when never swept — never coerced to green), `last_green` (the
141
+ `autoware_version` of the most recent `status:pass`, or null), and **drift**
142
+ (workspace HEAD vs lock `resolved_sha` vs registry `ref`). Locating the data
143
+ branch: default **`--data git`** — one shallow `git fetch --depth 1 <remote>
144
+ data` into an XDG cache, then `git show FETCH_HEAD:history/...`. **One network
145
+ round-trip total**, independent of package count, and one atomic snapshot so all
146
+ reads are mutually consistent. Offline layers honestly (a stale-or-missing cache
147
+ is reported as such, never as a green). Exit codes for CI: `0` all-green, `1` a
148
+ drift/fail result, `2` operational error — tunable via `--fail-on`/`--require`.
149
+
150
+ ### `refresh`
151
+ Keeps the consumer's **local cache** of the registry (the distribution YAML and
152
+ the data-branch history used by `check`) current, so `sync`/`check` can run
153
+ offline and fast. Reuses `load_distribution` verbatim to re-fetch+gate; keys the
154
+ cache off the resolved `registry.commit`; skips-if-current (no churn when
155
+ upstream hasn't moved). With no lock it errors ("run compose first") rather than
156
+ doing nothing — the deliberate "cut a command that does nothing useful" guard.
157
+ (If we later choose a no-cache variant, `refresh` folds into `sync`; the design
158
+ keeps that exit open.)
159
+
160
+ ## New surface this introduces
161
+
162
+ - **`lock.py`** (new module): `build`/`load`/`dump`/`diff_locks` + `LockError`,
163
+ the lock-vs-`.repos` agreement check. Pure where possible.
164
+ - **`workspace.py`** gains `lock_path(repo_root, name)` and `src_dir(repo_root)`
165
+ (mirroring `output_path`, so all paths stay one-sourced and discovered alike).
166
+ - **data-branch reader** (in a small `data.py` or under `check`): the cached
167
+ shallow-fetch + NDJSON fold; mirrors `site/build.py`'s `summarize` (sort by
168
+ `at`, latest wins; greens give last-green).
169
+ - **error model:** `RegistryError` (load/version) + `ComposeError` (shape) +
170
+ new `LockError` (lock load / `.repos` disagreement), all mapped uniformly to
171
+ `error: …` + non-zero exit in the command handlers.
172
+
173
+ ## Release / CI / packaging (registry roadmap B2 + H9)
174
+
175
+ - **Repo + publish:** create `autowarefoundation/aw-index-cli`, push `main`
176
+ (merge the local `feat/registry-v2` first — only a v2 CLI composes the now-v2
177
+ registry). Add governance files + the org `semantic-pull-request` / `sync-files`
178
+ reusables; protect `main` (no-delete/no-force-push + DCO / pre-commit.ci /
179
+ pytest). **PyPI via Trusted Publishing (OIDC)**, not a long-lived token —
180
+ register the pending publisher before the first release.
181
+ - **Versioning:** already single-sourced (`__init__.__version__`); tag-driven
182
+ (bare `X.Y.Z`), with a guard asserting tag == built version. Stay `0.x` while
183
+ the surface grows; reserve `1.0.0` for a stable command set + locked schema-2
184
+ coupling.
185
+ - **CI (four workflows):** `lint.yaml` (ruff + ruff-format + actionlint via
186
+ pre-commit; run `pre-commit autoupdate` once, don't `pre-commit install`),
187
+ `test.yaml` (pytest matrix py3.10–3.13, one aggregate `tests` job as the
188
+ required check), `build.yaml` (sdist+wheel + `twine check`), `publish.yaml`
189
+ (OIDC publish on tag). Mirror the registry's CI shapes.
190
+ - **e2e proof:** an `e2e.yaml` job *inside* `ghcr.io/autowarefoundation/autoware:
191
+ core-devel-jazzy-<ver>`: `pip install .` → `aw-index-cli compose` (or
192
+ `import`) → `vcs import` → `rosdep install` → `colcon build --packages-up-to
193
+ autoware_livox_tag_filter` green. Closes the registry's B2 proof from the
194
+ consumer side. (`git config --global --add safe.directory '*'` to pre-empt the
195
+ sweep's dubious-ownership Bug D.)
196
+
197
+ ## Phased roadmap
198
+
199
+ 1. **Lock foundation** — `lock.py` + `workspace.lock_path`/`src_dir` +
200
+ `compose.build_lock`; `compose` emits the lock; the agreement guard; tests.
201
+ *(No new command yet — de-risks the pivotal decision first.)*
202
+ 2. **`import`** — thin `vcs import` wrapper + resolved-sha back-fill +
203
+ `--dry-run`; the `compose → import` happy path tested offline (vcstool
204
+ mocked) and once for real.
205
+ 3. **`check`** — the data-branch reader + cached shallow fetch + the join +
206
+ CI-grade exit codes. Highest standalone value (works without a prior import).
207
+ 4. **`sync`** — the lock-vs-registry diff (adds/removes/ref-changes) + safe
208
+ apply; depends on 1–2.
209
+ 5. **`refresh`** — the registry/data cache + skip-if-current; depends on 3.
210
+ 6. **Release** — governance + four CI workflows + e2e proof; create the GitHub
211
+ repo, push, PyPI OIDC, tag `0.1.0` (compose-only is already shippable; later
212
+ commands ship as `0.x` minors).
213
+
214
+ Sequencing rule: **the lockfile lands before any command that reads it** (1
215
+ before 2/4/5); `check` (3) is independent and can ship early as the highest-value
216
+ read-only gate. Each command reuses the existing pure modules — the version gate
217
+ stays single-sourced, transforms stay pure, I/O stays at the edges (the
218
+ "Extending it" rules in the as-is doc).
219
+
220
+ ## Open questions
221
+
222
+ - **State model:** commit the lockfile alongside the `.repos`, or gitignore it?
223
+ (Reproducibility argues for committing; needs a one-line docs decision.)
224
+ - **`compose`'s partial lock:** offline `compose` writes `resolved_sha: null`;
225
+ confirm consumers/`check` treat a null sha as "not yet imported," not drift.
226
+ - **`check` data access:** default `--data git` shallow-fetch vs per-file raw
227
+ fetch — confirm git is an acceptable hard-ish dependency for `check`.
228
+ - **`refresh`'s reason to exist** hinges on the cache; if `check` proves fast
229
+ enough with a per-run fetch, consider folding `refresh` into `sync`/`check`.
230
+ - **Release specifics:** PyPI ownership (org vs individual; reserve on
231
+ test.pypi), the publish gate (required reviewer vs maintainer tag-push for
232
+ 0.x), and whether the e2e container is pinned or tracks latest.
@@ -0,0 +1,228 @@
1
+ # aw-index-cli — architecture
2
+
3
+ Internal map for contributors and agents. User-facing usage lives in
4
+ [`README.md`](../README.md); this doc covers *how the pieces fit*, the
5
+ contracts they depend on, and where to extend. Keep it reconciled when the
6
+ module boundaries or the registry coupling change.
7
+
8
+ ## What this is (and is not)
9
+
10
+ `aw-index-cli` is the **consumer** side of the [autoware-index][index]
11
+ ecosystem. It reads a distribution manifest — `distributions/<rosdistro>.yaml`,
12
+ `schema_version: "2"`, the registry's source of truth — and renders a
13
+ [vcstool][vcstool] `.repos` slice you can `vcs import` into a workspace.
14
+
15
+ It is deliberately **not**:
16
+
17
+ - a validator or builder — the registry's sweep workflows
18
+ (`autoware-index-github-actions`) clone, build, and test packages and record
19
+ history; this CLI never touches a container or runs colcon.
20
+ - an Autoware-version resolver — the registry tracks **one ref per
21
+ repository**, resolved against the freshest Autoware release at *sweep* time,
22
+ never stored. `compose` selects nothing by Autoware version; `--autoware` is
23
+ recorded in the header for provenance only.
24
+ - networked beyond one optional read — its only outbound call is fetching the
25
+ distribution YAML from `raw.githubusercontent.com` when `--registry-path` is
26
+ omitted.
27
+
28
+ The single implemented command is `compose`. `import`/`sync`/`check`/`refresh`
29
+ are registered stubs (see *Deliberately absent*).
30
+
31
+ ## Package layout
32
+
33
+ ```
34
+ src/aw_index_cli/
35
+ __init__.py # __version__ (single source of truth; hatchling reads it)
36
+ __main__.py # `python -m aw_index_cli` -> SystemExit(main())
37
+ cli.py # argparse surface + _cmd_compose orchestration
38
+ registry.py # load + schema_version-gate the distribution YAML
39
+ compose.py # select repos -> .repos entries -> rendered document
40
+ workspace.py # discover the repo root and the output path
41
+ tests/ # pytest, one module per source module (+ conftest)
42
+ pyproject.toml # hatchling, src-layout, console script aw-index-cli
43
+ ```
44
+
45
+ Build: hatchling, src-layout, `requires-python >= 3.10`, single runtime
46
+ dependency `pyyaml>=6`. Version is single-sourced from `__init__.py`
47
+ (`[tool.hatch.version]`). Console script `aw-index-cli = aw_index_cli.cli:main`.
48
+ Local-only so far — no git remote, not on PyPI.
49
+
50
+ ## Module responsibilities
51
+
52
+ ### `registry.py` — source loading + the version gate
53
+
54
+ `load_distribution(ros_distro, *, path=None, repo=DEFAULT_REPO, ref=DEFAULT_REF,
55
+ timeout=30) -> dict` is the single entry point for getting a distribution.
56
+
57
+ - **Source resolution.** With `path`: a file is read directly, a directory is
58
+ resolved to `<dir>/distributions/<ros_distro>.yaml`. Without `path`: fetched
59
+ from `RAW_URL = raw.githubusercontent.com/{repo}/{ref}/distributions/{ros_distro}.yaml`.
60
+ - **The gate.** Every failure mode — missing file, HTTP error, timeout, URL
61
+ error, non-UTF-8, YAML parse error, non-mapping document, **`schema_version`
62
+ != `"2"`** (`SUPPORTED_SCHEMA_VERSION`), `ros_distro` mismatch, `repositories`
63
+ not a mapping, or any repository spec not a mapping — raises `RegistryError`
64
+ with a specific message. The guiding rule: **never produce silently empty
65
+ output for a document we do not understand.** A v1 (or future) document is a
66
+ loud non-zero failure, not an empty `.repos`.
67
+ - `describe_source(*, path, repo, ref) -> str` returns the provenance string
68
+ (`local path <p>` or `<repo>@<ref>`) shown in the header.
69
+
70
+ This is the only module that knows where YAML comes from or what version is
71
+ acceptable. `SUPPORTED_SCHEMA_VERSION` is the one place the CLI's registry
72
+ coupling is pinned.
73
+
74
+ ### `compose.py` — the transform
75
+
76
+ The pure registry→`.repos` pipeline, three stages plus the header builder:
77
+
78
+ 1. `select_repositories(distribution, tags=None) -> list[(key, spec,
79
+ selected_packages)]`, sorted by repo key. A **package** is selected when
80
+ `tags` is empty/`None` or its own `tags` intersect the wanted set; a
81
+ **repository** is selected when ≥1 of its packages is selected; the selected
82
+ package names are sorted. A repository whose `packages` is not a mapping
83
+ raises `ComposeError`.
84
+ 2. `to_repos_entries(repositories) -> dict` maps each selected repo to a
85
+ vcstool entry `{type: "git", url, version: ref.value, packages: [...]}`.
86
+ Invariants that matter:
87
+ - the entry key is the **registry repository key**, never a URL basename —
88
+ so a monorepo's packages collapse to exactly **one clone**;
89
+ - `ref.kind` is **never read** — vcstool is kind-agnostic, so `version` is
90
+ `ref.value` verbatim (tag, branch, or sha all work);
91
+ - `packages` is a **manifest** of the selected registered package names
92
+ (vcstool ignores unknown keys), so a downstream `colcon build
93
+ --packages-up-to <names>` can scope to exactly what was asked for;
94
+ - missing `url`, missing `ref.value`, or a non-mapping `ref` each raise
95
+ `ComposeError`.
96
+ 3. `render_repos(distribution, *, tags, header_lines) -> str` re-runs selection,
97
+ builds entries, and emits `header + yaml.safe_dump({"repositories": entries},
98
+ sort_keys=False)`. `sort_keys=False` preserves the `type/url/version/packages`
99
+ field order; cross-entry order is already sorted by `select_repositories`.
100
+
101
+ `provenance_header(...)` builds the leading `# …` comment block (tool version,
102
+ source, rosdistro, tags, optional `autoware`, optional `generated_at`, and a
103
+ per-repository "selected packages" listing), ending with a do-not-edit notice.
104
+
105
+ `ComposeError` covers every *shape* failure once the document has loaded;
106
+ `RegistryError` covers *loading/version*. Both are caught together in the CLI.
107
+
108
+ ### `workspace.py` — output location
109
+
110
+ - `find_repo_root(start)` walks up from `start` (inclusive) to the first
111
+ ancestor containing a `repositories/` directory; falls back to the resolved
112
+ `start` if none is found.
113
+ - `output_path(repo_root, name="autoware-index")` →
114
+ `<repo_root>/repositories/<name>.repos`.
115
+
116
+ No registry knowledge — pure path discovery, so it stays trivially testable.
117
+
118
+ ### `cli.py` — argparse surface + orchestration
119
+
120
+ `_build_parser()` defines `--version`, the `compose` subparser (all its flags),
121
+ and the four stubs. `_cmd_compose(args)` is the only real handler and wires the
122
+ pipeline:
123
+
124
+ ```
125
+ load_distribution ─▶ describe_source ─▶ select_repositories ─▶ provenance_header
126
+ │ │
127
+ └──────────▶ render_repos ┘
128
+
129
+ --stdout ? print : write to output_path / --output
130
+ ```
131
+
132
+ The two success paths diverge: with `--stdout` the rendered YAML is printed to
133
+ **stdout** and the handler returns `0` immediately — no summary. On the
134
+ file-write path it writes to `--output` (or the discovered
135
+ `<repo_root>/repositories/<name>.repos`) and prints `Wrote N repository
136
+ entr(y|ies) covering P registered package(s) to <path>: key (pkgs), …` to
137
+ **stderr**. `RegistryError`/`ComposeError` → `error: <msg>` on stderr, exit `1`.
138
+ Stubs print "not implemented yet" and exit `2`; no subcommand prints help and
139
+ exits `2`. `main(argv=None) -> int` is the console-script entry and returns the
140
+ exit code.
141
+
142
+ ## The compose data flow, end to end
143
+
144
+ ```
145
+ distributions/<distro>.yaml (schema_version 2, repository-keyed)
146
+ │ registry.load_distribution (local path OR raw.githubusercontent.com; gate on "2")
147
+
148
+ parsed dict
149
+ │ compose.select_repositories(tags) → (key, spec, selected_packages) sorted
150
+ │ compose.to_repos_entries → key -> {type,url,version,packages}
151
+ │ compose.provenance_header → # comment lines
152
+
153
+ compose.render_repos → header + YAML
154
+ │ cli: --stdout → print, else workspace.find_repo_root + output_path → write
155
+
156
+ <repo_root>/repositories/<name>.repos → `vcs import < …`
157
+ ```
158
+
159
+ ## Registry contract this CLI is coupled to
160
+
161
+ `compose` reads, but does not own, the v2 distribution schema
162
+ (`autoware-index/schema/distribution.schema.json`). The fields it depends on:
163
+
164
+ | Path | Use |
165
+ |------|-----|
166
+ | `schema_version == "2"` | hard gate in `registry.load_distribution` |
167
+ | `ros_distro` | must equal the requested distro |
168
+ | `repositories.<key>` | entry key → `.repos` key + clone dir |
169
+ | `repositories.<key>.url` | `.repos` `url` (required) |
170
+ | `repositories.<key>.ref.value` | `.repos` `version` (required; `kind` ignored) |
171
+ | `repositories.<key>.packages.<name>.tags` | `--tags` selection |
172
+
173
+ Lockstep (one ref per repository, no per-package ref) is what lets a monorepo
174
+ collapse to a single `.repos` entry; ref skew is unrepresentable upstream, so
175
+ the CLI never has to reconcile divergent refs within a repository. If the
176
+ registry bumps `schema_version`, this CLI must move in lockstep — bump
177
+ `SUPPORTED_SCHEMA_VERSION` and the readers together; until then a newer document
178
+ fails loudly rather than mis-composing.
179
+
180
+ ## Invariants & design decisions
181
+
182
+ - **Fail loud, never empty.** Any unparseable/unsupported input is a non-zero
183
+ error with a specific message — there is no "best effort" partial `.repos`.
184
+ - **Determinism.** `--no-timestamp` drops `generated_at`; repositories and
185
+ package names are sorted; `sort_keys=False` keeps field order. Same input →
186
+ byte-identical output, so generated `.repos` files diff cleanly.
187
+ - **One clone per repository.** Keying `.repos` by the registry repo key (not a
188
+ URL basename) is what makes monorepo dedup correct and collision-free.
189
+ - **`compose` is pure + offline-capable.** `select_repositories`/
190
+ `to_repos_entries`/`render_repos`/`provenance_header` take plain dicts and do
191
+ no I/O, so they unit-test without network or filesystem.
192
+ - **Two error types, one catch.** `RegistryError` (load/version) and
193
+ `ComposeError` (shape) are distinct at the raise site but handled uniformly
194
+ in `_cmd_compose`.
195
+
196
+ ## Deliberately absent
197
+
198
+ - `import` / `sync` / `check` / `refresh` are parser stubs that exit `2`. They
199
+ exist so `--help` lists the planned surface; they hold no logic and bake in no
200
+ assumptions. (`check` is intended to read the `data` branch history for drift;
201
+ `import` would wrap `vcs import`.)
202
+ - No build/validate/version-resolution — those are the registry's job (see
203
+ *What this is and is not*).
204
+
205
+ ## Testing
206
+
207
+ `pytest` (config in `pyproject.toml`: `pythonpath = ["src"]`, `testpaths =
208
+ ["tests"]`). One test module per source module — `test_registry.py`,
209
+ `test_compose.py`, `test_cli.py`, `test_workspace.py` — plus `conftest.py`.
210
+ Coverage includes the schema_version gate (v1/missing/garbage rejection),
211
+ monorepo collapse and tag-filtered subsetting, the malformed-shape error
212
+ paths, and `--no-timestamp` determinism.
213
+
214
+ ## Extending it (adding a real command)
215
+
216
+ 1. Add a subparser in `_build_parser()` and a `_cmd_<name>` handler;
217
+ `set_defaults(func=…)`. Remove the name from `STUB_COMMANDS`.
218
+ 2. Reuse `registry.load_distribution` for any registry read — do not re-fetch or
219
+ re-gate elsewhere; the version gate must stay single-sourced.
220
+ 3. Keep transforms pure where possible (mirror `compose.py`) and push I/O to the
221
+ handler so the logic stays unit-testable.
222
+ 4. Raise `RegistryError`/`ComposeError` (or a new sibling) for expected
223
+ failures; let `_cmd_*` map them to `error: …` + a non-zero exit.
224
+ 5. Add a `tests/test_<name>.py`; assert the failure messages, not just exit
225
+ codes.
226
+
227
+ [index]: https://github.com/autowarefoundation/autoware-index
228
+ [vcstool]: https://github.com/dirk-thomas/vcstool
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ dist/
5
+ build/
6
+ log/
7
+ *.egg-info/
8
+ .venv/
9
+ .idea/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.