Skip to content

Commit e5be16a

Browse files
authored
Fix 1830 (crossbario#1874)
* start new dev branch; add audit file * Make FlatBuffers generated-code verification actually detect drift (crossbario#1830) Two bugs let stale generated files accumulate undetected: 1. `build-fbs` invoked a system `flatc` (whatever version is on PATH) instead of the vendored, version-matched flatc. A version mismatch can silently produce different generated code. 2. The CI verification ran `build-fbs` on top of the committed tree WITHOUT cleaning first, so any orphaned file (no longer produced by the schema) survived in both the "before" and "after" states, matched its own checksum, and was never flagged. Fixes: - justfile: build-fbs now uses the bundled flatc (${VENV_PATH}/bin/flatc), built from deps/flatbuffers during install, with a clear error if it is missing. - main.yml: run `just clean-fbs` before `just build-fbs` so a clean regeneration is compared against the committed tree. - main.yml: replace the opaque checksum diff with an actionable, categorized table derived from `git status` of the regenerated tree: content differs -> regenerate & commit (e.g. newer flatc) orphan / not generated -> delete (crossbario#1828) new, not committed -> commit Validated locally with the vendored v25.12.19 flatc: a clean regenerate differs from the committed tree by exactly two files, both orphans (ChannelBinding.py, Kdf.py) - confirming no flatc content drift, only the crossbario#1828 leftovers. NOTE: this commit intentionally leaves those two orphan files in place, so CI is EXPECTED to fail on this commit - that red run proves the detection mechanism works and that the files are genuinely stale. The orphans are removed in the next commit (crossbario#1828), which turns CI green. Refs crossbario#1828. Note: This work was completed with AI assistance (Claude Code). * Delete orphaned generated FlatBuffers files Kdf.py / ChannelBinding.py (crossbario#1828) These two files in src/autobahn/wamp/gen/wamp/proto/ are stale leftovers from before the schema renamed the tables to KDF and TLSChannelBinding. They are no longer produced by `flatc`, and their case-insensitive collisions with the current KDF.py / TLSChannelBinding.py broke `git clone` and directory copies on case-insensitive filesystems (APFS/macOS, some Docker containers). Produced by `just clean-fbs && just build-fbs` with the vendored v25.12.19 flatc: a clean regeneration of the canonical tree differs from the committed tree by exactly these two deletions (every other generated file is byte-identical), so this commit is precisely "drop the orphans". With the detection fix from the previous commit (crossbario#1830) now in place, CI's clean-regenerate-and-compare turns green, proving the two files were genuine attic leftovers. Fixes crossbario#1828. Note: This work was completed with AI assistance (Claude Code).
1 parent f5fb7b6 commit e5be16a

6 files changed

Lines changed: 54 additions & 40 deletions

File tree

.audit/oberstet_fix_1830.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- [ ] I did **not** use any AI-assistance tools to help create this pull request.
2+
- [x] I **did** use AI-assistance tools to *help* create this pull request.
3+
- [x] I have read, understood and followed the projects' [AI Policy](https://github.com/crossbario/autobahn-python/blob/main/AI_POLICY.md) when creating code, documentation etc. for this pull request.
4+
5+
Submitted by: @oberstet
6+
Date: 2026-06-17
7+
Related issue(s): #1830
8+
Branch: oberstet:fix_1830

.github/workflows/main.yml

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ jobs:
466466
just create ${{ matrix.python-env }}
467467
just install-tools ${{ matrix.python-env }}
468468
469-
- name: Store original generated files checksum
470-
run: |
471-
echo "==> Computing checksums of committed FlatBuffers files..."
472-
find src/autobahn/wamp/gen/ -name "*.py" -o -name "*.bfbs" | sort | xargs sha256sum > /tmp/original-checksums.txt
473-
echo "Found $(wc -l < /tmp/original-checksums.txt) committed generated files"
469+
- name: Clean generated FlatBuffers files (so orphans become detectable)
470+
# Without this, `build-fbs` regenerates on top of the committed tree and
471+
# any orphaned/stale file (no longer produced by the schema) survives in
472+
# both the before and after states, hiding the drift (#1830).
473+
run: just clean-fbs
474474

475475
- name: Build FlatBuffers binary schema & Python wrappers
476476
run: just build-fbs
@@ -489,24 +489,37 @@ jobs:
489489
490490
- name: Verify regenerated files match committed files
491491
run: |
492-
echo "==> Computing checksums of regenerated files..."
493-
find src/autobahn/wamp/gen/ -name "*.py" -o -name "*.bfbs" | sort | xargs sha256sum > /tmp/regenerated-checksums.txt
494-
495-
echo "==> Comparing checksums..."
496-
if diff -u /tmp/original-checksums.txt /tmp/regenerated-checksums.txt; then
497-
echo "✅ SUCCESS: All regenerated FlatBuffers files match committed versions exactly!"
498-
echo "This confirms the build process is reproducible and up-to-date."
499-
else
500-
echo "❌ FAILURE: Regenerated files differ from committed versions!"
501-
echo ""
502-
echo "This indicates either:"
503-
echo "1. The committed files were generated with a different flatc version"
504-
echo "2. The committed files were manually modified"
505-
echo "3. The build process has changed since files were last committed"
506-
echo ""
507-
echo "Please run 'just clean-fbs && just build-fbs' locally and commit the results."
508-
exit 1
492+
# Compare a clean regeneration (clean-fbs + build-fbs, above) against the
493+
# committed generated tree using git's own classification, and fail with
494+
# an actionable, categorized table (#1830):
495+
# M -> content differs (e.g. newer vendored flatc) -> regenerate & commit
496+
# D -> committed but NOT produced by flatc -> orphan/attic leftover, delete (#1828)
497+
# ?? -> newly generated, not yet committed -> commit
498+
status=$(git status --porcelain -- src/autobahn/wamp/gen/)
499+
if [ -z "${status}" ]; then
500+
echo "✅ SUCCESS: committed FlatBuffers generated code matches a clean regenerate."
501+
exit 0
509502
fi
503+
echo "❌ FAILURE: committed FlatBuffers generated code drifted from a clean regenerate."
504+
echo ""
505+
printf '%-36s %-21s %s\n' "CATEGORY" "ACTION" "FILE"
506+
printf '%-36s %-21s %s\n' "------------------------------------" "---------------------" "----"
507+
while IFS= read -r line; do
508+
code="${line:0:2}"
509+
file="${line:3}"
510+
case "${code}" in
511+
" M"|"M "|"MM") category="content differs" ; action="regenerate & commit" ;;
512+
" D"|"D ") category="orphan / not generated [#1828]" ; action="delete" ;;
513+
"??") category="new, not committed" ; action="commit" ;;
514+
*) category="changed (${code})" ; action="review" ;;
515+
esac
516+
printf '%-36s %-21s %s\n' "${category}" "${action}" "${file}"
517+
done <<< "${status}"
518+
echo ""
519+
count=$(printf '%s\n' "${status}" | grep -c .)
520+
echo "FAIL: ${count} generated file(s) drifted."
521+
echo "Run 'just clean-fbs && just build-fbs' locally and commit the result."
522+
exit 1
510523
511524
# Upload FlatBuffers artifacts (split into two uploads since verified action
512525
# doesn't support multi-line paths like actions/upload-artifact@v4)

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Changelog
2525
* Commit the binary schemas (``reflection.bfbs``, ``wamp.bfbs``) to the source tree and ship them as-is; the package build no longer runs ``flatc``, which fixes cross-compilation from the PyPI sdist (e.g. Buildroot/Yocto/aarch64) (#1853)
2626
* Add ``just generate-reflection`` to regenerate the committed binary schemas with a version-matched ``flatc`` built from ``deps/flatbuffers`` (#1853)
2727
* Add ``just check-flatbuffers-sync`` and a unit test exercising ``check_zlmdb_flatbuffers_version_in_sync()`` (#1853)
28+
* Delete two orphaned generated files, ``Kdf.py`` and ``ChannelBinding.py``, left in ``src/autobahn/wamp/gen/wamp/proto/`` after the schema renamed those tables to ``KDF`` and ``TLSChannelBinding``. Their case-insensitive collisions with the current ``KDF.py`` / ``TLSChannelBinding.py`` broke ``git clone`` and directory copies on case-insensitive filesystems (APFS/macOS, some Docker setups). They are no longer produced by ``flatc``, and the verification from #1830 now keeps such orphans from recurring. Thanks to @dcki for the report (#1828)
2829

2930
**Build & CI/CD**
3031

@@ -38,6 +39,7 @@ Changelog
3839
* Build and publish the missing CPython 3.12 and 3.14 ``manylinux_*_aarch64`` (ARM64) wheels. The per-version ARM64 build matrix (added in commit 3d856f5 to deduplicate wheels) only covered cp311 and cp313, so no cp312 aarch64 wheel was ever published (and cp314 was never added) - e.g. ``pip download autobahn --platform manylinux_2_34_aarch64`` for CPython 3.12 found no matching distribution. The strict release fileset manifest shared the same gap and so could not catch it; it now requires the cp312/cp314 aarch64 wheels (fail-closed). Thanks to @norrisjeremy for the report (#1848)
3940
* Make the release fileset symmetric across all four platforms: every supported interpreter (cp311, cp312, cp313, cp314, pypy311) is now required on macOS/arm64, Linux/x86_64, Linux/aarch64, and Windows/amd64. The macOS job already built all interpreters via ``just build-all``, but the manifest only required cp313/cp314/pypy311, so the cp311/cp312 macOS wheels were built and then dropped as "extra" rather than published; they are now kept and required (#1848)
4041
* Remove orphaned/attic files left over from the pre-``justfile``/``uv`` CI/CD system: ``Makefile.orig``, ``Dockerfile.wheels``, ``mypy.ini``, ``test-docker-builds.sh``, ``versions.sh``, ``deploy.sh``, ``.prettierrc.json``, ``.coveragerc``, ``docs/DOCKER_BUILDS.md``, ``docker/README.md`` and the ``pyinstaller/`` PyInstaller hooks, plus the unused ``pyinstaller`` dev dependency. The ``.coveragerc`` ``omit = */test/*.py`` setting was preserved by migrating it to ``[tool.coverage.run]`` in ``pyproject.toml`` (so coverage still excludes in-package test modules), and the stale ``DOCKER_BUILDS.md`` entry was dropped from the Sphinx ``exclude_patterns``. ``mypy`` is unaffected: the typing recipe already passes ``--config-file pyproject-static-typing.toml`` explicitly. ``setuptools`` was added explicitly to the ``dev`` extra: it is required by ``cffi``'s ``ffi.compile()`` to build the NVX extensions in an editable install on Python >= 3.12 (stdlib ``distutils`` was removed in 3.12) and had been pulled in only transitively via the removed ``pyinstaller`` (#1831)
42+
* Fix the FlatBuffers generated-code verification so it actually detects drift. The ``build-fbs`` recipe now uses the vendored, version-matched ``flatc`` bundled in the venv (``${VENV_PATH}/bin/flatc``) instead of an arbitrary system ``flatc``, and the CI job runs ``just clean-fbs`` before ``just build-fbs`` so orphaned/stale generated files no longer survive in both the before and after states (previously they matched checksums and went undetected). On drift the job now fails with an actionable, categorized table - ``content differs`` (regenerate & commit, e.g. after a vendored-``flatc`` bump), ``orphan / not generated`` (delete), ``new, not committed`` (commit) - derived from ``git status`` of the regenerated tree (#1830)
4143

4244
25.12.2
4345
-------

justfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,15 @@ build-fbs venv="": (install-tools venv)
19411941
VENV_PATH="{{ VENV_DIR }}/${VENV_NAME}"
19421942
19431943
FBSFILES="./src/autobahn/wamp/flatbuffers/*.fbs"
1944-
FLATC="flatc"
1944+
# Use the vendored, version-matched flatc bundled in the venv (built from
1945+
# deps/flatbuffers during install), NOT a system flatc which may be a
1946+
# different version and silently produce different generated code (#1830).
1947+
FLATC="${VENV_PATH}/bin/flatc"
1948+
if [ ! -x "${FLATC}" ]; then
1949+
echo "ERROR: bundled flatc not found at ${FLATC}" >&2
1950+
echo " Run 'just install-tools ${VENV_NAME}' first (it builds the vendored flatc)." >&2
1951+
exit 1
1952+
fi
19451953
echo "==> Generating FlatBuffers binary schema and Python wrappers using $(${FLATC} --version)..."
19461954
19471955
# Generate schema binary type library (*.bfbs files)

src/autobahn/wamp/gen/wamp/proto/ChannelBinding.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/autobahn/wamp/gen/wamp/proto/Kdf.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)