Revision: 1 Last modified: 2026-12-04T19:00:00Z
mode.py prints the effective mode of a .workable-items-sync.yaml as one word:
off | dry-run | apply | invalid
It is a small CLI (it has its own shebang and is directly runnable), and it exists for one reason: hooks must not grep YAML.
A pre-commit hook, a Docs Chain step, or any other seam that wants to know "is the mirror on, and will it
write?" needs that answer without parsing YAML itself. An ad-hoc grep '^enabled:' would disagree with the
real validator the moment the file's structure changed — and it would disagree silently, which is the
bad kind.
So mode.py asks the same validator the engine uses (config.py) and reduces the answer to one word.
The hook and the engine therefore cannot disagree about whether the mirror is enabled.
python3and PyYAML.- A
.workable-items-sync.yamlpath to inspect. A missing file isoff, not an error. - No credentials are read.
# print the effective mode for the default config path
python3 scripts/issue_sync/mode.py
# inspect a specific declaration
python3 scripts/issue_sync/mode.py path/to/.workable-items-sync.yaml
# typical hook use: only proceed when the mirror is actually going to write
mode="$(python3 scripts/issue_sync/mode.py)" || exit 2
[ "$mode" = apply ] || exit 0UNCONFIRMED: whether the config path is positional or defaulted-only was not read in full; check
python3 scripts/issue_sync/mode.py with no arguments first.
| Code | Meaning |
|---|---|
0 |
The mode is off, dry-run or apply. |
2 |
The mode is invalid. An invalid declaration is never ON. |
That mapping is the contract: off and dry-run are both legitimate states and must not fail a hook.
invalid is a real problem and exits 2 so a hook refuses rather than treating a broken declaration as
"enabled".
Exactly one word on stdout: off, dry-run, apply or invalid. A caller compares that word rather than
parsing prose.
- No config file. Prints
off, exits0— default-OFF. - A malformed declaration. Prints
invalid, exits2. Neverapply. - A declaration with a duplicate key.
invalid— the strict validator refuses it (seeconfig.py). - A hook that greps the YAML instead of calling this. The failure mode this tool exists to prevent: it can disagree with the engine about whether writes will happen.
dry-run. A legitimate state; exits0. Do not treat "not applying" as "disabled".- PyYAML missing. Cannot determine — the validator cannot run, so the mode cannot be trusted.
- Reads the config path.
- Runs the same validator the engine uses (
config.effective). - Reduces the validated state to one of the four words.
- Prints it and exits
0(or2forinvalid).
Imports config.py (the single source of truth for validation).
Used by hooks and Docs Chain steps that need the effective mode without parsing YAML.
Sibling: offline_status.py (the other hook-oriented helper — a network-free pending-change report).
See also docs/scripts/config.md, docs/scripts/offline_status.md and docs/scripts/pipeline.md.
2026-12-04 — python3 -c "import ast;ast.parse(open('scripts/issue_sync/mode.py').read())" → exit 0.
Running python3 scripts/issue_sync/mode.py with no .workable-items-sync.yaml present prints off and
exits 0.