Skip to content

Remove encoding/gob dependency entirely #26

@friedenberg

Description

@friedenberg

Summary

encoding/gob is used throughout the codebase for serializing store configs,
object metadata, indexes, and collection types. It forces fields that should be
private to be exported (e.g. objects.metadata), requires a global registry of
types via gob.Register in init() functions, and couples unrelated packages
through shared serialization concerns. The codebase has been migrating toward
hyphence (typed blob) serialization and binary codecs, but gob remains as
legacy scaffolding.

TODO comments

  • internal/oscar/store_config/main.go:25 — "remove gob entirely and cleanly
    separate store functionality (mutation, changes, loading and unloading) from
    config functionality (reading properties)"
  • internal/oscar/store_config/persist.go:4 — "remove once V13 support dropped"
  • internal/golf/env_repo/genesis.go:162 — "remove gob"
  • internal/bravo/ids/registry.go:13 — "remove this once gob is removed
    entirely"
  • lib/charlie/quiter/keyer_stringer.go:13 — "remove when removing gob"

Affected files

Direct gob usage (encode/decode calls)

File Usage
internal/oscar/store_config/persist.go gob encode/decode for store config persistence (V13 compat)
internal/oscar/store_config/main.go gob.Register in init() for collection types
internal/golf/env_repo/genesis.go gob encode during genesis
internal/hotel/store_abbr/main.go gob encode/decode for abbreviation store
internal/hotel/log_remote_inventory_lists/v0.go gob encode/decode for remote inventory
internal/sierra/store_browser/cache.go gob encode/decode for browser cache
internal/foxtrot/zettel_id_index/v1/main.go gob encode/decode for zettel ID index
internal/foxtrot/zettel_id_index/v0/main.go gob encode/decode for zettel ID index (v0)
internal/charlie/hyphence/coder_gob.go dedicated gob coder for hyphence (bridge code)
internal/mike/store_fs/main.go gob.Register(sku.Transacted{})

gob.Register init() scaffolding (no encode/decode, just registration)

File What it registers
internal/bravo/ids/registry.go generic ID types + collection sets
internal/golf/sku/collections.go TransactedSetEmpty, MakeTransactedMutableSet
internal/golf/sku/keyers.go transactedKeyerObjectId
internal/golf/sku/main.go Transacted{}
lib/charlie/quiter/keyer_stringer.go StringerKeyer variants
lib/delta/collections_value/gob.go generic Set/MutableSet
lib/delta/collections_value/construction.go 5x gob.Register for constructed sets
lib/delta/collections_ptr/gob.go generic Set/MutableSet (ptr variant)
lib/delta/tridex/main.go &Tridex{}
lib/echo/thyme/time.go Time{}

Structural debt forced by gob

File Issue
internal/delta/objects/main.go:20-21 "all the fields need to be public for gob's stupid illusions, but should be private once moving away from the gob entirely"
internal/delta/objects/index.go:41 ImplicitTags is "public for gob, but should be private"

Test-only gob usage

File Notes
internal/bravo/ids/zettel_id_test.go gob round-trip test for ZettelId
internal/bravo/ids/gob_test.go dedicated gob serialization test
lib/delta/collections/bitset_test.go gob encode/decode test for bitset
lib/delta/trie/main.go gob encode/decode in trie (may be test-adjacent)

Approach considerations

  • Store config persistence (oscar/store_config/persist.go) gates on V13
    support — dropping gob there requires deciding the minimum supported store
    version
  • objects.metadata fields can be made private once gob is gone, which is a
    significant encapsulation win
  • The hyphence/coder_gob.go bridge can be deleted once no persisted data uses
    gob format
  • gob.Register calls in init() across ~15 files can be removed wholesale
    once no code path calls gob.NewEncoder/gob.NewDecoder
  • collections_value/gob.go and collections_ptr/gob.go are dedicated gob
    files that can be deleted entirely

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions