Skip to content

One implementation of src/vsa/*, not two - #3

Merged
gHashTag merged 8 commits into
mainfrom
fix/deduplicate-vsa
Aug 11, 2026
Merged

One implementation of src/vsa/*, not two#3
gHashTag merged 8 commits into
mainfrom
fix/deduplicate-vsa

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Both this repository and gHashTag/zig-golden-float carried src/vsa/core.zig, common.zig, concurrency.zig, 10k_vsa.zig, hrr.zig and fpga_bind.zig. They were edited independently and diverged — which is why repairing sixteen defects in golden-float (#97) left every one of them standing here: the fixes went into different files with the same names.

The decision was made by measurement

Comparing the two public surfaces symbol by symbol, they are identical — one constant apart. Neither copy is more capable, so there is nothing to lose by choosing, and the direction follows the dependency that already exists: this package depends on golden-float, whose copies build and pass 267 tests on 0.15.2.

Each duplicate becomes a re-export, not a deletion

All twenty-three relative imports across this repository keep working unchanged, and re-divergence becomes impossible rather than discouraged — there is one implementation behind the path now.

usingnamespace was removed in 0.15, so the names are listed individually, generated from the upstream sources. That is a real cost: a symbol added upstream does not appear here until it is added here too. It is still cheaper than a second implementation, and it fails loudly — the name is simply missing rather than quietly different.

What full-surface analysis then found, none of it caused by the deduplication

  • src/vsa.zig re-exported concurrency.LockFreePool, which has never existed in either copy. It referred to nothing and nothing complained, because lazy analysis never asked.
  • The pin predated #97, so sixteen repaired defects were still arriving through the dependency.
  • text_encoding.zig passed an allocator to bundle2 and add at nine call sites, against an API that had moved without it, and bound a const where add needs *Self.

gen_core.zig, gen_encoding.zig and the other eighteen files under src/vsa/ have no counterpart in golden-float and stay as they are.

CI is green, with refAllDeclsRecursive forcing the whole public surface through the compiler — so the green means what a consumer would take it to mean.

Both this repository and gHashTag/zig-golden-float carried src/vsa/core.zig,
common.zig, concurrency.zig, 10k_vsa.zig, hrr.zig and fpga_bind.zig. They were
edited independently and they diverged, which is why repairing sixteen defects
in golden-float (#97) left every one of them standing here: the fixes went into
different files with the same names.

The decision was made by measurement rather than preference. Comparing the two
public surfaces symbol by symbol, they are identical -- one constant apart --
so neither copy is more capable and there is nothing to lose by choosing. The
direction then follows the dependency that already exists: this package depends
on golden-float, golden-float's copies build and pass 267 tests on 0.15.2, and
these do not.

Each duplicated file becomes a one-line re-export instead of being deleted. That
keeps all twenty-three relative imports across this repository working exactly
as they did, so nothing else in the tree moves, and it makes re-divergence
impossible rather than merely discouraged: there is one implementation behind
the path now.

gen_core.zig and gen_encoding.zig stay as they are. golden-float does not export
them, so they are genuinely this package's own, and so are the other eighteen
files under src/vsa/ that have no counterpart there.
The first attempt re-exported each duplicated file with usingnamespace, which
was removed in Zig 0.15 -- the version this package targets -- so the build
answered 'expected function or variable declaration after pub'. The names are
listed individually now, generated from the upstream sources rather than typed.

That is a real cost and worth naming: a symbol added upstream does not appear
here until it is added here too. It is still cheaper than a second
implementation, and unlike a second implementation it fails loudly, because the
name is simply missing rather than quietly different.

MAX_PACKED_BYTES has no counterpart in golden-float's vsa/common.zig, so it
comes from packed_trit, where the value actually lives, rather than being
written out as a literal. Nothing here uses it, but it was in this module's
public surface and dropping it silently would break a consumer who does.
…n behind it

The build went green with the duplicated files re-exporting golden-float, but
green without this line means only that the declarations the tests happen to
walk compile. That is exactly the condition that hid five API-drift errors here
while the badge stayed green.

Now the surface goes through the compiler as a whole, and the green means what
a consumer would take it to mean.
Two things the full-surface analysis found, neither of them caused by the
deduplication.

This branch was cut from main, which pins the golden-float from before its
sixteen defects were repaired -- so atomic.fence and the rest of the 0.14 API
came back through the dependency rather than from any file here. Re-pinned.

And src/vsa.zig re-exported concurrency.LockFreePool, which has never existed
in this repository's concurrency module nor in golden-float's. Both export the
same twenty-three names and that is not one of them. The line referred to
nothing and nothing complained, because lazy analysis never asked what it
pointed at.
The local zig used to compute it does not survive between sessions here and the
download keeps timing out, so the runner that already has the right toolchain
computes it instead. Removed in the next commit.
The hash came from the runner, which has the toolchain that computes it. The
previous pin predated gHashTag/zig-golden-float#97, so sixteen repaired defects
were still arriving here through the dependency.
…take

Nine call sites passed std.heap.page_allocator to core.bundle2 and to
HybridBigInt.add. Both take their operands and nothing else -- bundle2(a, b) and
add(self, other) -- so the argument is dropped rather than replaced: there is
nothing for it to become.

This file is one of the eighteen under src/vsa/ that have no counterpart in
golden-float, so it is genuinely this package's own, and it had been calling an
API that moved without it. It compiled for nobody and nothing said so, because
nothing referenced it.
The value caches its own unpacked form, so filling that cache is a mutation and
add is declared *Self. A const binding cannot hand out the pointer it asks for.
@gHashTag
gHashTag merged commit e3c3e11 into main Aug 11, 2026
2 checks passed
@gHashTag
gHashTag deleted the fix/deduplicate-vsa branch August 11, 2026 18:29
gHashTag added a commit to gHashTag/trinity that referenced this pull request Aug 11, 2026
gHashTag/zig-hdc#3 made its duplicated src/vsa/* files re-export one repaired
implementation, and its CI is green with the whole public surface analysed. The
pin here predates that, so this build was still consuming the copies that carry
the five API-drift errors.
gHashTag added a commit to gHashTag/trinity that referenced this pull request Aug 11, 2026
* Pin the deduplicated zig-hdc

gHashTag/zig-hdc#3 made its duplicated src/vsa/* files re-export one repaired
implementation, and its CI is green with the whole public surface analysed. The
pin here predates that, so this build was still consuming the copies that carry
the five API-drift errors.

* Re-pin golden_float too: the two manifests disagreed

zig-hdc pins the repaired golden-float and this one still pinned the archive
from before those sixteen defects were fixed, so the fetch reported a hash
mismatch rather than a compile error. Both manifests name the same archive now.
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