-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Overview
Add audit and audit-all CLI commands to runtime_ci_tooling that validate pubspec.yaml dependency declarations across consumer packages. This fills a critical gap — we have consumer discovery (consumers command) and template sync (update/update-all), but no automated way to detect or repair misconfigured pubspec dependencies.
Problem
Manual pubspec dependency management across 20+ repos leads to recurring issues:
- Bare constraints where git SSH deps are required — e.g.
encrypt: ^6.0.0instead of the full git block withtag_pattern - Wrong GitHub org — e.g.
pieces-app/encrypt.gitinstead ofopen-runtime/encrypt.git - Stale version constraints — e.g.
encrypt: ^5.1.10when source is at^6.0.0 - Missing
tag_pattern: v{{version}}on git deps - HTTPS URLs instead of SSH URLs (
https://github.com/...vsgit@github.com:...)
Real examples found today:
runtime_aot_tooling/pubspec.yamlhadencrypt: ^5.1.10(stale)runtime_mindfck/pubspec.yamlhadpieces-app/encrypt.git(wrong org)runtime_aot_client_examples/pubspec.yamlhad 5 bare deps missing git SSH blocks
Proposed Commands
audit — Single package pubspec validation
manage_cicd audit [--path <dir>] [--fix] [--verbose]Behavior:
- Read
pubspec.yamlin the target directory (default: cwd) - For each dependency in
dependenciesanddev_dependencies:- If it's a known git-sourced package (from a registry — see below), validate:
- Has
git:block with SSH URL (git@github.com:org/repo.git) - Has
tag_pattern: v{{version}}(or package-specific pattern) - Has
version:constraint - URL points to correct GitHub org
- Version constraint is compatible with latest known version
- Has
- If it's a pub.dev package or workspace-internal dep, skip
- If it's a known git-sourced package (from a registry — see below), validate:
- Report all issues found (structured output)
- With
--fix: rewrite the pubspec to correct format
audit-all — Recursive batch validation
manage_cicd audit-all [--path <dir>] [--fix] [--verbose] [--exclude <glob>]Behavior:
- Recursively find all
pubspec.yamlfiles under the target directory (default: cwd) - Skip
.dart_tool/,.consumers/,.claude/,build/directories - Run
auditlogic on each - Aggregate and report results
- With
--fix: batch-fix all
Package Registry
The "known git-sourced packages" registry should be derived from configs/external_workspace_packages.yaml in the monorepo (or a local equivalent). Each entry defines:
github_org+github_repo→ SSH URLtag_pattern(usuallyv{{version}}, but some packages likecustom_linthave different patterns)version→ latest known version constraint
The audit commands should accept a --registry <path> flag to point at this YAML file, with a sensible default.
Cross-referencing with .consumers/
When .consumers/ data is available (from a prior consumers run), the audit can additionally:
- Compare consumer pubspec snapshots against current source versions
- Flag consumers whose dependency constraints are incompatible with the source's current version
- Generate a compatibility matrix
Existing Infrastructure to Build On
consumerscommand already discovers all downstream repos and stores pubspec snapshots in.consumers/external_workspace_packages.yamlalready defines all git-sourced packages with org, repo, version, tag_patternhook_installer.dartalready handlesresolution: workspacestripping (pre-commit hook)- YAML parsing already used in
consumers_command.dartvialoadYaml()
Audit of Existing Commands (No Issues Found)
All existing commands were audited for incorrect pubspec modifications:
| Command | Pubspec interaction | Status |
|---|---|---|
create-release |
Bumps version: field via regex |
✅ Safe — only touches version line |
consumers |
Fetches + stores pubspec snapshots (read-only) | ✅ Safe |
update / update-all |
Updates workflows/configs, not pubspecs | ✅ Safe |
validate |
YAML syntax check (read-only) | ✅ Safe |
determine-version |
Reads version via awk (read-only) | ✅ Safe |
release |
Reads version via awk (read-only) | ✅ Safe |
| Pre-commit hook | Strips resolution: workspace via sed |
✅ Correct |
No existing commands incorrectly modify pubspec dependency structures.
Acceptance Criteria
-
auditcommand validates a single pubspec against the package registry -
audit-allcommand recursively validates all pubspecs in a directory tree - Reports bare deps, wrong orgs, stale versions, missing tag_patterns, HTTPS URLs
-
--fixflag rewrites pubspecs with correct git SSH + tag_pattern format -
--registry <path>flag to specify package registry YAML - Structured output (JSON) option for CI integration
- Skips pub.dev packages and workspace-internal deps automatically
- Cross-references
.consumers/data when available