Revision: 1 Last modified: 2026-12-04T19:00:00Z
cli.py is the issue_sync command-line front door (anchor §11.4.300). It mirrors workable items from
the tracker database out to the Issues of each declared upstream, and reports drift the other way.
It is a Python module inside the scripts/issue_sync/ package, normally invoked as part of that package
(for example python3 -m issue_sync.cli ...) rather than as a standalone script.
Subcommands:
| Subcommand | Purpose |
|---|---|
plan |
Dry run (the default). Show what would change. |
apply |
Write. Requires --apply. |
verify |
Three-valued check: in sync / drift / cannot determine. |
status |
Report current sync state. |
Everything is three-valued: 0 in sync or done, 1 drift or failure, 2 cannot determine — and 2
is never a pass.
Two defaults matter:
- The mechanism is OFF by default. A missing or disabled config exits
0withdisabled. Absence of a declaration is not an error; it is "not opted in". - Dry run is the default. Writing requires an explicit
--apply.
python3and PyYAML (the config loader requires it).- A
.workable-items-sync.yamldeclaring scope and legs. Absent ⇒disabled. - The workable-items DB (the source of truth, §11.4.93).
- Tokens are read by variable name (see
credentials.pyin this package) and are never printed.
# dry run against one target (the default: writes nothing)
python3 -m issue_sync.cli plan --target github/vasic-digital/constitution
# several targets
python3 -m issue_sync.cli plan \
--target github/vasic-digital/constitution \
--target gitlab/vasic-digital/constitution
# actually write
python3 -m issue_sync.cli apply --apply --target github/vasic-digital/constitution
# three-valued verification
python3 -m issue_sync.cli verify --target github/vasic-digital/constitution
# current state
python3 -m issue_sync.cli status| Code | Meaning |
|---|---|
0 |
In sync / done. Also the code for a missing or disabled config (disabled). |
1 |
Drift or failure. |
2 |
Cannot determine — never a pass. |
2 is the code to treat seriously. A target whose owning-repo visibility cannot be resolved is
undetermined, and undetermined blocks. It never defaults to public.
- No config file. Exits
0withdisabled. Default-OFF by design. - A config that fails validation. An invalid declaration is never "on" — treated as disabled/invalid rather than partially applied.
- An unknown host in
--target. The leg is reported asunknown-hostrather than guessed; seeregistry.py. - Undetermined visibility. Blocks (
2); the visibility resolver refuses to assume public. - A missing token variable. The credential is absent by name; nothing is printed and the leg cannot authenticate — it must not be reported as synced.
applywithout--apply. Stays a dry run. Dropping the flag by accident cannot write.- Multiple
--targetvalues. Repeatable; each form isHOST/OWNER/REPO.
- Parses the subcommand and the repeatable
--targetlist. - Loads and validates
.workable-items-sync.yaml; missing/disabled ⇒ exit0disabled. - Builds one leg per target: resolve the adapter via
registry.make(...)against the host map, which is data (config/forge/hosts.tsv), not a hardcoded switch. - Resolves the owning repository's visibility live from the target's
repo_info; undetermined blocks. - Delegates planning/applying to
engine, and inbound work toinbound. - Reports per-leg outcomes and exits
0/1/2.
The module imports config, credentials, redact, registry, store, engine, inbound, visibility
and the adapter base — it is the composition root of the package.
Delegates to engine.py (plan/apply/verify), inbound.py (intake), config.py (validation),
registry.py + adapters/* (per-host transport), visibility.py (visibility and routing),
store.py (DB access), redact.py (pre-write redaction).
Facade alternative with the full bidirectional pipeline: pipeline.py (subcommands plan, apply,
pull, reconcile, verify, run, init-context, stage).
See also docs/scripts/pipeline.md, docs/scripts/engine.md, docs/scripts/config.md,
docs/scripts/registry.md and docs/scripts/visibility.md.
2026-12-04 — python3 -c "import ast;ast.parse(open('scripts/issue_sync/cli.py').read())" → exit 0.
python3 -m issue_sync.cli with no subcommand exits 2 (argparse usage error).