Skip to content

feat(iso8583): freeze-prep — lock down Bitmap, rename PutTag→SetTag#9

Open
canaan5 wants to merge 2 commits into
mainfrom
feat/iso8583-freeze-prep
Open

feat(iso8583): freeze-prep — lock down Bitmap, rename PutTag→SetTag#9
canaan5 wants to merge 2 commits into
mainfrom
feat/iso8583-freeze-prep

Conversation

@canaan5

@canaan5 canaan5 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

API freeze-prep ahead of v1. Closes two of the four iso8583 seams from the API-surface audit. Breaking (pre-1.0); full suite passes under go test -race.

1. Lock down the Bitmap mutators

The design guarantees the wire bitmap is always derived from the present-field set — yet Bitmap.Set, Clear, and SetWord were exported, contradicting that invariant and freezing engine internals into the v1 surface.

  • Unexported Set/Clear/SetWord (engine-internal).
  • Added two immutable constructors:
    • iso8583.BitmapFromWords([3]uint64) — wire/word-level, for BitmapCodec implementations (replaces the codec's use of SetWord).
    • iso8583.BitmapFor(des ...int) — by present DE number, for codec authors and tests.
  • Read surface unchanged: IsSet, Word, Count, Width, Range, String.

2. Rename Message.PutTagSetTag

Consistency with the Set/SetS/SetP family. Updated the two callers (message.go, fieldcodec/tlv).

Verification

  • gofmt -l clean, go vet ./... clean.
  • go test -race ./...all packages pass.
  • Caller updates were compiler-driven (unexport → fix every flagged site), so nothing was missed: engine (message.go, codec.go), fieldcodec/bitmap.go, and internal/external tests.

Still open from the audit (not in this PR — they're design calls)

  • The Tag API is still a parallel surface (GetTag/SetTag/TagSeq/LookupTag) rather than flowing through the unified FieldPath grammar, and SetTag still takes a Value while Set takes any. Bigger decision — flagged for follow-up.
  • FieldDef exposes public struct fields; WidthCodec and the Describe family want a confirm-or-change pass.
  • ARCHITECTURE.md §2.4 still shows Bitmap.Set as exported (design doc vs. impl drift) — minor doc follow-up.

Note: both this PR and #8 touch CHANGELOG.md's ## [Unreleased] section, so whichever merges second needs a trivial conflict resolution.

API freeze-prep ahead of v1: enforce the always-derived bitmap invariant
through the type system, and align tag-write naming with the field API.

- Unexport the engine-internal Bitmap mutators Set/Clear/SetWord so application
  code cannot mutate a bitmap directly (the wire bitmap is always derived from
  the present-field set at marshal time). The read surface is unchanged.
- Add immutable constructors iso8583.BitmapFromWords([3]uint64) (wire/word-level,
  used by BitmapCodec implementations) and iso8583.BitmapFor(des ...int) (by
  present DE, for codec authors and tests).
- Update the internal engine, the fieldcodec bitmap codec, and tests to the new
  constructors.
- Rename Message.PutTag -> SetTag for consistency with Set/SetS/SetP; update the
  two callers (message.go, fieldcodec/tlv).

Breaking (pre-1.0). gofmt/go vet clean; full suite passes under go test -race.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant