Revision: 1 Last modified: 2026-12-04T19:00:00Z
payload.py defines what may leave the database, in what form, and gates the write. Three jobs
(anchor §11.4.300(D),(E)):
- the mirrored-field allowlist;
- the canonical content hash;
- the pre-write gate.
Only five DB fields are ever sent:
atm_id, type, status, title, severity
That is deliberately narrower than "the item". A tracker is potentially public, and the item's
description, body_md, forensic_anchor and current_location are not. An allowlist means a field
added to the DB next year is not mirrored by default — the failure mode is "we forgot to mirror this",
which is visible, rather than "we published something internal", which is not.
description is mirrored, but as a generated field: it is produced from a fixed template. The DB's own
description / body text is never copied across (operator decision 2026-11-25).
The hash is computed canonically, so the same logical content always yields the same digest regardless of
key ordering. engine.py writes it into the hidden footer, which is the issue's real identity — not the
issue number.
python3.- Nothing else: the module is pure (it imports
redactand the standard library).
from issue_sync import payload as pl
# which fields may ever be sent
allowed = pl.ALLOWED_FIELDS # ("atm_id", "type", "status", "title", "severity")
generated = pl.GENERATED_FIELDS # ("description",)
# build a normalised payload from a DB row, then gate it before writing
p = pl.build(row) # UNCONFIRMED: exact builder name; see the module
ok = pl.pre_write_gate(p)UNCONFIRMED: the precise builder function names beyond ALLOWED_FIELDS / GENERATED_FIELDS were not
read while writing this guide. Import the module and inspect it before depending on a name:
python3 -c "import issue_sync.payload as p; print(dir(p))".
| Name | Kind | Contract |
|---|---|---|
ALLOWED_FIELDS |
tuple | ("atm_id", "type", "status", "title", "severity") — the only DB fields ever sent. |
GENERATED_FIELDS |
tuple | ("description",) — sent, but generated from a fixed template; the DB's own body text is never mirrored. |
A library, so no exit codes. A gated write that fails is signalled to engine.py, which maps it into the
package's three-valued convention (0 ok, 1 drift/refused, 2 cannot determine).
- A DB field not on the allowlist. Not sent. Adding a field to the DB does not widen what is mirrored.
- The DB's
description/body_md. Never mirrored verbatim;descriptionin the payload is generated. - A payload containing a secret. The pre-write gate refuses (
redact.pysupplies the finding). - Key ordering differences. The canonical hash is order-independent, so an equivalent payload does not look like a change.
- An item missing an allowlisted field. Hashed as absent rather than silently defaulted, so a change from present to absent is visible.
- A new field added to
ALLOWED_FIELDS. A reviewable, deliberate change — this is the seam where widening the mirror is reviewed.
- Selects the allowlisted fields from a DB row.
- Generates the template
descriptionrather than copying DB text. - Serialises canonically and computes the content hash that becomes the issue footer.
- Runs the pre-write gate: redaction scan plus the allowlist check.
- Returns the gated payload for the adapter to send.
Imports redact.py.
Used by engine.py (every outbound payload), inbound.py (the mirror-image inbound guard),
cli.py, pipeline.py, offline_status.py (content-hash comparison) and store.py (field list).
See also docs/scripts/redact.md, docs/scripts/engine.md, docs/scripts/inbound.md and
docs/scripts/offline_status.md.
2026-12-04 — python3 -c "import ast;ast.parse(open('scripts/issue_sync/payload.py').read())" → exit 0.
python3 -c "import issue_sync.payload as p; print(p.ALLOWED_FIELDS)" prints
('atm_id', 'type', 'status', 'title', 'severity').