Skip to content

Flip pandoc tool genesis from opt-in to opt-out (prerequisites: fixture-helper system) #208

@friedenberg

Description

@friedenberg

Goal

Make the pandoc tool tree (!pandoc-defaults, !pandoc-lua_filter, the three tool blobs, and the [formatters.text] + blob references on !md) default-on at dodder init. Replace the opt-in -include-default-pandoc-tools flag with an opt-out -exclude-default-pandoc-tools flag.

Why not done yet

Attempted in this session but backed out due to test-suite cascade cost. The four source edits are trivial; the bats fallout is the blocker.

Cascade scope (when the flip lands)

After the flip, dodder init (no flags) produces 4 lines instead of 2 (adds !pandoc-defaults and !pandoc-lua_filter), and the !md box line gains three blob references with deterministic blob digests and per-init ed25519_sig values. Every test that pins the old shape needs to change. From a full bats run against the flipped source:

  • 5 shared setup() blocks in checkin.bats, status.bats, checkout.bats, organize.bats, clean.bats — assert exact dodder checkout :z,t,e output; failing setup cascades through ~67 tests.
  • ~25 occurrences of [!md @$(get_type_blob_sha) !toml-type-v2] inside assert_output(_unsorted) - <<-EOM heredocs across init.bats, show.bats, deinit.bats, checkin.bats, reindex.bats, push.bats, import.bats.
  • ~10 multi-type-query assertions that need 2 new lines for pandoc types (show :t, show +t,konfig, dodder last).
  • ~6 hardcoded blob/sync counts that drift with the bigger fixture (e.g. blob_store_sync.bats:25 asserts Total: 16; new count is 13–16 depending on what fixture changes settle to).
  • 3 migration tests (migration_validate_schwanzen, migration_validate_history, migration_reindex) — not investigated; may be deeper than mechanical updates.

Mass .*] regex substitution doesn't work — these are inside exact-mode assert_output blocks where adjacent lines are literal, so mixing regex requires converting whole blocks to --regexp mode + escaping [/].

Recommended prerequisite: fixture-helper system

A durable fix that benefits future flag flips, new tool types, and any fixture data change. Keeps assert_output exact-mode (stronger assertions than --regexp).

.fixtures.env additions

FIXTURE_PANDOC_DEFAULTS_TYPE_SHA      # !pandoc-defaults type blob digest
FIXTURE_PANDOC_LUA_FILTER_TYPE_SHA    # !pandoc-lua_filter type blob digest
FIXTURE_PANDOC_DEFAULTS_SIG           # signature on !pandoc-defaults
FIXTURE_PANDOC_LUA_FILTER_SIG         # signature on !pandoc-lua_filter
FIXTURE_DODDER_COMMON_LUA_SHA         # tool blob: filters/dodder-common.lua
FIXTURE_DODDER_EDIT_LUA_SHA           # tool blob: filters/dodder-edit.lua
FIXTURE_DODDER_EDIT_YAML_SHA          # tool blob: defaults/dodder-edit.yaml

Extraction added to go/bats.nix + zz-tests_bats/previous_versions/generate_fixture.bash. Use the same anchored-sed pattern as #d696091c7 (one extraction per object).

common.bash helpers (3 layers)

Single-value getters:

get_pandoc_defaults_type_sha()       # → "blake2b256-..."
get_pandoc_lua_filter_type_sha()
get_pandoc_defaults_sig()            # → "ed25519_sig-..."
get_pandoc_lua_filter_sig()
get_dodder_common_lua_sha()
get_dodder_edit_lua_sha()
get_dodder_edit_yaml_sha()

Single-object box-line strings:

get_konfig_box()                     # → "[konfig @... !toml-config-v2]"
get_pandoc_defaults_type_box()
get_pandoc_lua_filter_type_box()
get_md_type_box()                    # → "[!md @... !toml-type-v2 \"defaults/...<@... !pandoc-defaults@...\" ...]"

get_md_type_box fully pins all 3 blob refs + their type sigs using fixture values — no regex anywhere.

Composite multi-line outputs:

get_genesis_types_output()           # show :t
get_genesis_objects_output()         # show +t,konfig
get_genesis_checkout_output()        # checkout :t (with "checked out " prefix)

Test rewrite shape

Before:

assert_output_unsorted - <<-EOM
    [!md @$(get_type_blob_sha) !toml-type-v2]
    [konfig @$(get_konfig_sha) !toml-config-v2]
EOM

After:

assert_output_unsorted - <<EOM
$(get_genesis_objects_output)
EOM

Or for single-line replacement: swap the one literal for $(get_md_type_box).

Open design question

User raised at end of session: should we reconsider the .fixtures.env + getter pattern altogether before extending it? Possibly a different assertion model (e.g. golden-file diffs, or shaping bats assertions around a different abstraction) would serve better. Not explored. Worth a separate scoping pass before building out the helper layers above.

Sequencing

  1. Decide on fixture/assertion abstraction (open question above). If staying with the current .fixtures.env model: continue with step 2. If reshaping: design that first.
  2. Build helper system as pure refactor — no source change. Migrate existing tests to use the helpers (this part is reversible and value-positive on its own).
  3. Land the flip — at this point a near-mechanical change: 4 source files + update one composite helper to include pandoc trailer + delete the opt-in flag.

Latent bug already fixed

The fixture-extraction sed regex (s/.*@.../) in bats.nix and generate_fixture.bash was already broken for the post-flip shape and would have masked the cascade beneath a wrong FIXTURE_TYPE_BLOB_SHA. Fixed in d696091c7 (anchored to \[!md @ literal). Independent of this issue — the fix works whether or not !md has blob refs.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions