Skip to content

Latest commit

 

History

History
106 lines (74 loc) · 4.26 KB

payload.md

File metadata and controls

106 lines (74 loc) · 4.26 KB

payload.py

Revision: 1 Last modified: 2026-12-04T19:00:00Z

Overview

payload.py defines what may leave the database, in what form, and gates the write. Three jobs (anchor §11.4.300(D),(E)):

  1. the mirrored-field allowlist;
  2. the canonical content hash;
  3. the pre-write gate.

The allowlist is the point

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 canonical hash is the identity anchor

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.

Prerequisites

  • python3.
  • Nothing else: the module is pure (it imports redact and the standard library).

Usage examples

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))".

Exported surface

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.

Exit codes

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).

Edge cases

  • 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; description in the payload is generated.
  • A payload containing a secret. The pre-write gate refuses (redact.py supplies 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.

Internal behaviour

  1. Selects the allowlisted fields from a DB row.
  2. Generates the template description rather than copying DB text.
  3. Serialises canonically and computes the content hash that becomes the issue footer.
  4. Runs the pre-write gate: redaction scan plus the allowlist check.
  5. Returns the gated payload for the adapter to send.

Related scripts

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.

Last verified

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').