Revision: 1 Last modified: 2026-12-04T19:00:00Z
engine.py is the outbound sync engine for the Issues mirror: plan / apply / verify, DB →
tracker, one way (anchor §11.4.300(B),(C),(D),(E)).
It is pure given its adapters — all network behaviour lives behind the adapter interface, which is what makes the engine testable without a live tracker. Dry run is the default.
The identity of a mirrored issue is:
- a title prefix of
[ID]followed by one space, plus - a hidden footer
<!-- workable-item: ID | sha256: HASH -->.
The issue number is never the identity. An issue number is allocated by the tracker, can change if an issue is transferred or recreated, and is not stable across hosts. Keying on the footer means the mirror can find its own issue even after a host-side renumbering, and it means a human editing the title is not mistaken for a new item.
A closed status is recognised by the prefix set Fixed, Implemented, Completed, Obsolete.
python3.- A per-host adapter (see
registry.py), which owns all network I/O. - The workable-items DB (source of truth).
- Tokens supplied by the adapter layer by variable name; the engine never handles or prints them.
# via the facade (recommended)
python3 -m issue_sync.pipeline plan --target github/vasic-digital/constitution
python3 -m issue_sync.pipeline apply --apply --target github/vasic-digital/constitution
# via the CLI front door
python3 -m issue_sync.cli plan --target github/vasic-digital/constitution| Name | Kind | Contract |
|---|---|---|
plan(...) |
function | Computes the changes that would be made. No writes. |
apply(...) |
function | Performs the planned changes, honouring the pre-write gate in payload.py. |
verify(...) |
function | Three-valued comparison of DB against tracker. |
FOOTER |
regex | Matches the hidden identity footer and captures (id, sha256). |
CLOSED_STATUS_PREFIXES |
tuple | ("Fixed", "Implemented", "Completed", "Obsolete") — the statuses that mean "closed upstream". |
The engine is a library; the facade maps its results onto the package's three-valued convention:
| Code | Meaning |
|---|---|
0 |
In sync / done. |
1 |
Drift, conflict, or refused. |
2 |
Cannot determine — never a pass. |
- An issue whose footer is absent. It is not ours to manage; the engine must not adopt it by title match alone.
- An issue whose footer hash differs from the computed content hash. The upstream copy changed, so the write is treated as a potential conflict rather than a blind overwrite.
- A title edited on the tracker. The title is not the identity, so this is a content change against the footer, not a new item.
- An issue number changed upstream. Footer-based identity survives it.
- A closed status. Recognised by the closed-prefix set, so reopening is a deliberate act.
- A field outside the allowlist. Never sent — see
payload.py(atm_id,type,status,title,severityonly). - A partial leg failure. Reported per leg; the engine does not claim a global success.
- Reads the items to mirror from
store(DB is truth). - For each target, builds the normalised issue payload through
payload— allowlist first, redaction gate before any write. - Computes the canonical content hash that goes into the footer.
- Resolves which existing issue is ours by footer, never by number.
- In
plan, reports the diff; inapply, performs it through the adapter. - In
verify, compares and returns three-valued.
Imports payload.py and visibility.py.
Called by cli.py and pipeline.py.
Uses adapters from registry.py / adapters/*.
See also docs/scripts/payload.md, docs/scripts/cli.md, docs/scripts/pipeline.md and
docs/scripts/store.md.
2026-12-04 — python3 -c "import ast;ast.parse(open('scripts/issue_sync/engine.py').read())" → exit 0.
The footer regex matches <!-- workable-item: ATM-1 | sha256:<64 hex> --> (verified against the pattern in
the source).