Category: perl

  • Bringing Non-Blocking I/O to Perl’s DBI: Looking for Community Feedback

    Disclaimer: The opinions stated here are my own, not those of my employer.

    Modern Perl Infrastructure Series: Part 1: Native gRPC, Protobuf & GenAI SDKs | Part 2: Modern ML, Columnar I/O & RAG on PDL | Part 3: Non-Blocking Core I/O for Perl DBI (this post)

    Updated (2026-12-03): Following sharp architectural reviews from Leon Timmermans (@Leont) and Robert Rothenberg (@robrwo), perl5-dbi/dbi#185 (7 stand-alone commits ending at 0c5054e, with the standalone @Leont review delta permanently preserved at tag pr185-leont-review-delta / 1f75808) now ships a zero-dependency DBI::EventLoop base class paired with 5 standalone external DBI::EventLoop::* backend distributions (PR #47), private _async_read_ready/_async_write_ready driver hooks, inverted $el->on_ready(...) completion callbacks, zero $h->err overloading, undef returns from fetch_async_row() disambiguated by DBI::is_wouldblock($sth), and a 1-bit core ABI footprint.

    Over my past two posts on bringing native gRPC, Protocol Buffers, and Cloud/GenAI SDKs and modern columnar I/O, vector search, and ML engines to Perl (now tracked across 35 distributions in the PDL Data & ML Ecosystem PR Reviewer’s Guide), a long-standing architectural gap kept resurfacing: once a Perl service is speaking multiplexed HTTP/2 RPCs and streaming Arrow batches in contiguous C memory, how should it talk to relational and cloud databases without blocking the event loop?

    This post covers our upstream RFC issue (perl5-dbi/dbi#183), the perl.dbi.dev mailing list discussion, the core implementation in perl5-dbi/dbi#185 (accompanied by a commit-by-commit PR #185 Reviewer’s Guide), and 9 companion pull requests (5 standalone DBI::EventLoop::* backends plus 8 relational and Protobuf/gRPC DBD::* drivers) bringing a unified, zero-ABI-breakage non-blocking contract to Perl’s DBI.

    (more…)
  • Bringing Modern ML, Columnar I/O, and RAG to Perl Data Language (PDLPorters)

    Disclaimer: The opinions stated here are my own, not those of my employer.

    Modern Perl Infrastructure Series: Part 1: Native gRPC, Protobuf & GenAI SDKs | Part 2: Modern ML, Columnar I/O & RAG on PDL (this post) | Part 3: Non-Blocking Core I/O for Perl DBI

    In my previous post on bringing native Protocol Buffers, gRPC, and Cloud/GenAI client libraries to Perl, I noted an important split in modern AI and data engineering: remote LLM orchestration happens over RPC, while local machine learning and columnar analytics rely on in-process C, C++, and Rust tensor libraries.

    Naturally, the next question was: what about the local side of that equation?

    What started as a pair of data-interchange prototypes (PDL::IO::Arrow and PDL::IO::Protobuf) developed alongside google-auth-library-perl (#35 and #37) quickly grew once we invited review from the PDLPorters community, in particular Ed J (mohawk2) on #pdl and Zakariyya Mughal (ZMUGHAL). That collaboration reshaped both the architecture and the packaging: 16 distributions (14 PDL::* modules at 0.011 and 2 Alien::* wrappers at 0.001) have now been migrated into dedicated repositories under PDLPorters, hardened across Linux, macOS, and Windows, and submitted as 16 pull requests built directly on Perl Data Language (PDL).

    (more…)
  • Why Perl Lost the Cloud Era, and How Native gRPC, Protobuf, and GenAI SDKs Can Bring It Back

    Disclaimer: The opinions stated here are my own, not those of my employer.

    Modern Perl Infrastructure Series: Part 1: Native gRPC, Protobuf & GenAI SDKs (this post) | Part 2: Modern ML, Columnar I/O & RAG on PDL | Part 3: Non-Blocking Core I/O for Perl DBI

    Every so often, someone asks why Perl—once the undisputed duct tape of the Internet—faded from mainstream greenfield software development. Was there a single cultural flashpoint that “canceled” Perl? Was it the fifteen-year wait for Perl 6? Or did Damian Conway’s Perl Best Practices, Perl::Critic, and CPAN’s Kwalitee metrics simply arrive too late?

    Having spent time recently building a modern Protocol Buffers and gRPC cloud client stack for Perl, I’ve come to a simple conclusion: languages don’t fade solely because of syntax debates. They decline when the friction of talking to the current generation of infrastructure outweighs the language’s natural strengths.

    Here is a look back at why Perl lost momentum during the 2000s enterprise shift—and why the GenAI and gRPC era offers an unexpected opening for a modern Perl resurgence.

    (more…)
  • The WWW::Mechanize::Chrome Saga: A Comprehensive Narrative of PR #104

    In March 2026, I spent a week hardening WWW::Mechanize::Chrome and its test suite in PR #104 to get a clean, reliable green build across Fedora 43, CentOS Stream 10, and Windows. What started as a few flaky test timeouts turned into a deeper refactor of how the library handles asynchronous Chrome DevTools Protocol (CDP) calls, Perl context propagation, memory cycles, and CI watchdogs. Here are the four architectural lessons that actually moved the needle.


    1. Non-Blocking _future Wrappers and the “Async Context Pattern”

    Mixing blocking calls inside an asynchronous event loop caused intermittent, indefinite hangs on slower Windows hosts. Rather than hardcoding arbitrary timeouts inside library methods, the clean fix was refactoring blocking methods (xpath, field, get, form selection, and their internal dependencies like _field_by_name) into thin synchronous wrappers over non-blocking ..._future counterparts:

    # Library implementation: synchronous wrapper over async _future core
    sub xpath($self, $query, %options) {
        $options{wantarray} = wantarray; # 1. Capture caller context
        return $self->xpath_future($query, %options)->get;
    }
    
    sub xpath_future($self, $query, %options) {
        my $wantarray = delete $options{wantarray}; # 2. Retrieve inside async chain
        # ... CDP send_message(...) ...
        return $doc->then(sub ($res = undef) {
            return $wantarray ? Future->done(@results) : Future->done($results[0]);
        });
    }

    Capturing wantarray at the synchronous boundary solved a subtle regression: Perl’s scalar-vs-list context is lost inside Future->then callbacks, which caused methods like xpath() to return a node count instead of a list of nodes. Passing wantarray explicitly down the chain (and giving ->then callbacks optional parameters like sub ($res = undef) for empty resolutions) preserved exact Perl semantics across the entire async refactor.


    2. Breaking Reference Cycles and Hardening Cross-Platform Browser I/O

    Moving response-body retrieval and DOM inspection onto stored Future objects surfaced several real-world hazards across Linux and Windows:

    • Weakening captured handles in stored futures: Closures attached to CDP futures (such as $response->{__body_future}) captured strong references to $self and $response, creating reference cycles. Calling Scalar::Util::weaken on both objects before entering any stored ->then block eliminated those leaks.
    • HashRef node attribute cache: WWW::Mechanize::Chrome::Node previously stored attributes as a flat list ([key, val, key, val]). Switching the cache to a HashRef gave O(1) lookups and atomic dual-updates synchronizing both the browser’s live JS property and the Perl object.
    • Async DOM & XHTML fallbacks: To survive Chromium cache eviction (Resource was not cached) and Fedora’s stricter file:// restrictions, _saveResourceTree and decoded_content() gained async fallbacks via DOM.getOuterHTML and JavaScript XMLSerializer. For Chromium’s XHTML setDocumentContent bug (40130141), XHTML documents now evaluate XPath via document.evaluate against the live DOM.
    • Windows MAX_PATH & RHEL browser discovery: filenameFromUrl now truncates filenames to 150 characters while preserving extensions (leaving headroom under Windows’ 260-character MAX_PATH limit), and browser discovery now includes headless_shell and /usr/lib64/chromium-browser/ out of the box.

    3. Why Deterministic Polling Beat MutationObserver

    When t/65-is_visible.t kept timing out, I initially tried replacing wait_until_visible‘s polling loop with an event-driven JavaScript MutationObserver awaited via callFunctionOn_future. In practice, bridging a cross-language JavaScript Promise over CDP proved opaque and brittle, with promises occasionally hanging even after the DOM changed.

    Reverting the MutationObserver experiment and inspecting the original polling code revealed the real bug: our test harness (t/lib/t/helper.pm) was racing its own Future->wait_any timeout against the library’s internal polling timer. Delegating timeout authority strictly to the library’s own timer, trimming the polling interval from 300ms to 150ms, and adding a self-cancelling ephemeral-socket watchdog in t::helper (so Windows background watchdogs exit immediately when the parent test closes its socket instead of hanging for 60 seconds) made the suite both faster and completely deterministic.


    4. Canonical make test in CI and Platform-Scoped Pragmatism

    Two final fixes brought CI to green:

    • Use make test in GitHub Actions: Running prove directly in .github/workflows/linux.yml bypassed Makefile.PL‘s custom MY::test target, which injects -It/lib for t::helper. Switching the workflow to make test aligned CI with local developer builds.
    • Documenting a Windows-only cycle cleanly: A remaining on_dialog reference-cycle failure in t/78-memleak.t reproduced exclusively on Windows (a platform-specific interaction between Perl’s GC, IO::Async on Win32, and Test::Memory::Cycle). Wrapping that single assertion in a conditional MSWin32 TODO block keeps CI green while preserving visibility for a deeper Win32 investigation.

    With those four changes in place, WWW::Mechanize::Chrome runs cleanly across Fedora 43, CentOS Stream 10, and Windows with a genuinely non-blocking _future core underneath.

  • Part 3: Building the Keystone – Dataproc Custom Images for Secure Boot & GPUs

    In Part 1, we established a secure, proxy-only network. In Part 2, we
    explored the enhanced install_gpu_driver.sh initialization
    action. Now, in Part 3, we’ll focus on using the LLC-Technologies-Collier/custom-images
    repository (branch proxy-exercise-2025-11) to build the
    actual custom Dataproc images embedded with NVIDIA drivers signed for
    Secure Boot, all within our proxied environment.

    Why Custom Images?

    To run NVIDIA GPUs on Shielded VMs with Secure Boot enabled, the
    NVIDIA kernel modules must be signed with a key trusted by the VM’s EFI
    firmware. Since standard Dataproc images don’t include these
    custom-signed modules, we need to build our own. This process also
    allows us to pre-install a full stack of GPU-accelerated software.

    The
    custom-images Toolkit
    (examples/secure-boot)

    The examples/secure-boot directory within the
    custom-images repository contains the necessary scripts and
    configurations, refined through significant development to handle proxy
    and Secure Boot challenges.

    Key Components & Development Insights:

    • env.json: The central configuration
      file (as used in Part 1) for project, network, proxy, and bucket
      details. This became the single source of truth to avoid configuration
      drift.
    • create-key-pair.sh: Manages the Secure
      Boot signing keys (PK, KEK, DB) in Google Secret Manager, essential for
      the module signing.
    • build-and-run-podman.sh: Orchestrates
      the image build process in an isolated Podman container. This was
      introduced to standardize the build environment and encapsulate
      dependencies, simplifying what the user needs to install locally.
    • pre-init.sh: Sets up the build
      environment within the container and calls
      generate_custom_image.py. It crucially passes metadata
      derived from env.json (like proxy settings and Secure Boot
      key secret names) to the temporary build VM.
    • generate_custom_image.py: The core
      Python script that automates GCE VM creation, runs the customization
      script, and creates the final GCE image.
    • gce-proxy-setup.sh: This script from
      startup_script/ is vital. It’s injected into the temporary
      build VM and runs first to configure the OS, package
      managers (apt, dnf), tools (curl, wget, GPG), Conda, and Java to use the
      proxy settings passed in the metadata. This ensures the entire build
      process is proxy-aware.
    • install_gpu_driver.sh: Used as the
      --customization-script within the build VM. As detailed in
      Part 2, this script handles the driver/CUDA/ML stack installation and
      signing, now able to function correctly due to the proxy setup by
      gce-proxy-setup.sh.

    Layered Image Strategy:

    The pre-init.sh script employs a layered approach:

    1. secure-boot Image: Base image with
      Secure Boot certificates injected.
    2. tf Image: Based on
      secure-boot, this image runs the full
      install_gpu_driver.sh within the proxy-configured build VM
      to install NVIDIA drivers, CUDA, ML libraries (TensorFlow, PyTorch,
      RAPIDS), and sign the modules. This is the primary target image for our
      use case.

    (Note: secure-proxy and proxy-tf layers
    were experiments, but the -tf image combined with runtime
    metadata emerged as the most effective solution for 2.2-debian12).

    Build Steps:

    1. Clone Repos & Configure
      env.json:
      Ensure you have the
      custom-images and cloud-dataproc repos and a
      complete env.json as described in Part 1.

    2. Run the Build:
      bash # Example: Build a 2.2-debian12 based image set # Run from the custom-images repository root bash examples/secure-boot/build-and-run-podman.sh 2.2-debian12
      This command will build the layered images, leveraging the proxy
      settings from env.json via the metadata injected into the
      build VM. Note the final image name produced (e.g.,
      dataproc-2-2-deb12-YYYYMMDD-HHMMSS-tf).

    Conclusion of Part 3

    Through an iterative process, we’ve developed a robust workflow
    within the custom-images repository to build Secure
    Boot-compatible GPU images in a proxy-only environment. The key was
    isolating the build in Podman, ensuring the build VM is fully
    proxy-aware using gce-proxy-setup.sh, and leveraging the
    enhanced install_gpu_driver.sh from Part 2.

    In Part 4, we’ll bring it all together, deploying a Dataproc cluster
    using this custom -tf image within the secure network, and
    verifying the end-to-end functionality.

  • Part 2: Taming the Beast – Deep Dive into the Proxy-Aware GPU Initialization Action

    With the proxy-only VPC from Part 1 in place, the next hurdle is installing NVIDIA GPU drivers, signing the kernel modules for Secure Boot, and building the ML stack without direct internet access. This post walks through our proxy- and Secure-Boot-aware install_gpu_driver.sh script in LLC-Technologies-Collier/initialization-actions (branch gpu-202601).

    The
    Challenge: Installing GPU Drivers Without Direct Internet

    Our goal was to create a Dataproc custom image with NVIDIA GPU
    drivers, sign the kernel modules for Secure Boot, and ensure the entire
    process works seamlessly when the build VM and the eventual cluster
    nodes have no direct internet access, relying solely on an HTTP/S proxy.
    This involved:

    1. Proxy-Aware Build: Ensuring all build steps within
      the custom image creation process (package downloads, driver downloads,
      GPG keys, etc.) correctly use the customer’s proxy.
    2. Secure Boot Signing: Integrating kernel module
      signing using keys managed in GCP Secret Manager, especially when
      drivers are built from source.
    3. Conda Environment: Reliably and speedily installing
      a complex Conda environment with PyTorch, TensorFlow, Rapids, and other
      GPU-accelerated libraries through the proxy.
    4. Dataproc Integration: Making sure the custom image
      works correctly with Dataproc’s own startup, agent processes, and
      cluster-specific configurations like YARN.

    The
    Development Journey: Key Enhancements in
    install_gpu_driver.sh

    To address these challenges, the script incorporates several key
    features:

    • Robust Proxy Handling (set_proxy
      function):

      • Challenge: Initial script versions had spotty proxy
        support. Many tools like apt, curl,
        gpg, and even gsutil failed in proxy-only
        environments.
      • Enhancements: The set_proxy function
        (also used in gce-proxy-setup.sh) was completely overhauled
        to parse various proxy metadata (http-proxy,
        https-proxy, proxy-uri,
        no-proxy). Critically, environment variables
        (HTTP_PROXY, HTTPS_PROXY,
        NO_PROXY) are now set before any network
        operations. NO_PROXY is carefully set to include
        .google.com and .googleapis.com to allow
        direct access to Google APIs via Private Google Access. System-wide
        trust stores (OS, Java, Conda) are updated with the proxy’s CA
        certificate if provided via http-proxy-pem-uri.
        gcloud, apt, dnf, and
        dirmngr are also configured to use the proxy.
    • Reliable GPG Key Fetching (import_gpg_keys
      function):

      • Challenge: Importing GPG keys for repositories
        often failed as keyservers use non-HTTP ports (e.g., 11371) blocked by
        firewalls, and gpg --recv-keys is not proxy-friendly.
      • Solution: A new import_gpg_keys
        function now fetches keys over HTTPS using curl, which
        respects the environment’s proxy settings. This replaced all direct
        gpg --recv-keys calls.
    • GCS Caching is King:
      • Challenge: Repeatedly downloading large files
        (drivers, CUDA, source code) through a proxy is slow and
        inefficient.
      • Solution: Implemented extensive GCS caching for
        NVIDIA drivers, CUDA runfiles, NVIDIA Open Kernel Module source
        tarballs, compiled kernel modules, and even packed Conda environments.
        Scripts now check a GCS bucket (dataproc-temp-bucket)
        before hitting the internet.
      • Impact: Dramatically speeds up subsequent runs and
        init action execution times on cluster nodes after the cache is
        warmed.
    • Conda Environment Stability & Speed:
      • Challenge: Large Conda environments are prone to
        solver conflicts and slow installation times.
      • Solution: Integrated Mamba for faster package
        solving. Refined package lists for better compatibility. Added logic to
        force-clean and rebuild the Conda environment cache on GCS and locally
        if inconsistencies are detected (e.g., driver installed but Conda env
        not fully set up).
    • Secure Boot & Kernel Module Signing:
      • Challenge: Custom-compiled kernel modules must be
        signed to load when Secure Boot is enabled.
      • Solution: The script integrates with GCP Secret
        Manager to fetch signing keys. The build_driver_from_github
        function now includes robust steps to compile, sign (using
        sign-file), install, and verify the signed modules.
    • Custom Image Workflow & Deferred Configuration:
      • Challenge: Cluster-specific settings (like YARN GPU
        configuration) should not be baked into the image.
      • Solution: The install_gpu_driver.sh
        script detects when it’s run during image creation
        (--metadata invocation-type=custom-images). In this mode,
        it defers cluster-specific setups to a systemd service
        (dataproc-gpu-config.service) that runs on the first boot
        of a cluster instance. This ensures that YARN and Spark configurations
        are applied in the context of the running cluster, not at image build
        time.

    Conclusion of Part 2

    The install_gpu_driver.sh initialization action is more
    than just an installer; it’s a carefully crafted tool designed to handle
    the complexities of secure, proxied environments. Its robust proxy
    support, comprehensive GCS caching, refined Conda management, Secure
    Boot signing capabilities, and awareness of the custom image build
    lifecycle make it a critical enabler.

    In Part 3, we’ll explore how the LLC-Technologies-Collier/custom-images
    repository (branch proxy-exercise-2025-11) uses this
    initialization action to build the complete, ready-to-deploy Secure Boot
    GPU custom images.

  • I’m learning about perlguts today.

    While building C/XS scalar conversion tests (upb_to_sv and sv_to_upb) for Perl’s upb-backed Protocol Buffers runtime, I hit a segfault caused by a double-free of test_pool. Turning on AddressSanitizer (ASan) in Makefile.PL and wiring standalone C test runners under t/c/ isolated the bug immediately; below is the raw git log from that debugging session.


    im-learning-about-perlguts-today.png


    ## 0.23	2025-12-20
    
    commit be15aa25dea40aea66a8534143fb81b29d2e6c08
    Author: C.J. Collier 
    Date:   Sat Dec 20 22:40:44 2025 +0000
    
        Fixes C-level test infrastructure and adds more test cases for upb_to_sv conversions.
        
        - **Makefile.PL:**
            - Allow `extra_src` in `c_test_config.json` to be an array.
            - Add ASan flags to CCFLAGS and LDDLFLAGS for better debugging.
            - Corrected echo newlines in `test_c` target.
        - **c_test_config.json:**
            - Added missing type test files to `deps` and `extra_src` for `convert/sv_to_upb` and `convert/upb_to_sv` test runners.
        - **t/c/convert/upb_to_sv.c:**
            - Fixed a double free of `test_pool`.
            - Added missing includes for type test headers.
            - Updated test plan counts.
        - **t/c/convert/sv_to_upb.c:**
            - Added missing includes for type test headers.
            - Updated test plan counts.
            - Corrected Perl interpreter initialization.
        - **t/c/convert/types/**:
            - Added missing `test_util.h` include in new type test headers.
            - Completed the set of `upb_to_sv` test cases for all scalar types by adding optional and repeated tests for `sfixed32`, `sfixed64`, `sint32`, and `sint64`, and adding repeated tests to the remaining scalar type files.
        - **Documentation:**
            - Updated `01-xs-testing.md` with more debugging tips, including ASan usage and checking for double frees and typos.
            - Updated `xs_learnings.md` with details from the recent segfault.
            - Updated `llm-plan-execution-instructions.md` to emphasize debugging steps.
    
    
    ## 0.22	2025-12-19
    
    commit 2c171d9a5027e0150eae629729c9104e7f6b9d2b
    Author: C.J. Collier 
    Date:   Fri Dec 19 23:41:02 2025 +0000
    
        feat(perl,testing): Initialize C test framework and build system
        
        This commit sets up the foundation for the C-level tests and the build system for the Perl Protobuf module:
        
        1.  **Makefile.PL Enhancements:**
            *   Integrates `Devel::PPPort` to generate `ppport.h` for better portability.
            *   Object files now retain their path structure (e.g., `xs/convert/sv_to_upb.o`) instead of being flattened, improving build clarity.
            *   The `MY::postamble` is significantly revamped to dynamically generate build rules for all C tests located in `t/c/` based on the `t/c/c_test_config.json` file.
            *   C tests are linked against `libprotobuf_common.a` and use `ExtUtils::Embed` flags.
            *   Added `JSON::MaybeXS` to `PREREQ_PM`.
            *   The `test` target now also depends on the `test_c` target.
        
        2.  **C Test Infrastructure (`t/c/`):
            *   Introduced `t/c/c_test_config.json` to configure individual C test builds, specifying dependencies and extra source files.
            *   Created `t/c/convert/test_util.c` and `.h` for shared test functions like loading descriptors.
            *   Initial `t/c/convert/upb_to_sv.c` and `t/c/convert/sv_to_upb.c` test runners.
            *   Basic `t/c/integration/030_protobuf_coro.c` for Coro safety testing on core utils using `libcoro`.
            *   Basic `t/c/integration/035_croak_test.c` for testing exception handling.
            *   Basic `t/c/integration/050_convert.c` for integration testing conversions.
        
        3.  **Test Proto:** Updated `t/data/test.proto` with more field types for conversion testing and regenerated `test_descriptor.bin`.
        
        4.  **XS Test Harness (`t/c/upb-perl-test.h`):** Added `like_n` macro for length-aware regex matching.
        
        5.  **Documentation:** Updated architecture and plan documents to reflect the C test structure.
        6.  **ERRSV Testing:** Note that the C tests (`t/c/`) will primarily check *if* a `croak` occurs (i.e., that the exception path is taken), but will not assert on the string content of `ERRSV`. Reliably testing `$@` content requires the full Perl test environment with `Test::More`, which will be done in the `.t` files when testing the Perl API.
        
        This provides a solid base for developing and testing the XS and C components of the module.
    
    
    ## 0.21	2025-12-18
    
    commit a8b6b6100b2cf29c6df1358adddb291537d979bc
    Author: C.J. Collier 
    Date:   Thu Dec 18 04:20:47 2025 +0000
    
        test(C): Add integration tests for Milestone 2 components
        
        - Created t/c/integration/030_protobuf.c to test interactions
          between obj_cache, arena, and utils.
        - Added this test to t/c/c_test_config.json.
        - Verified that all C tests for Milestones 2 and 3 pass,
          including the libcoro-based stress test.
    
    
    ## 0.20	2025-12-18
    
    commit 0fcad68680b1f700a83972a7c1c48bf3a6958695
    Author: C.J. Collier 
    Date:   Thu Dec 18 04:14:04 2025 +0000
    
        docs(plan): Add guideline review reminders to milestones
        
        - Added a "[ ] REFRESH: Review all documents in @perl/doc/guidelines/**"
          checklist item to the start of each component implementation
          milestone (C and Perl layers).
        - This excludes Integration Test milestones.
    
    
    ## 0.19	2025-12-18
    
    commit 987126c4b09fcdf06967a98fa3adb63d7de59a34
    Author: C.J. Collier 
    Date:   Thu Dec 18 04:05:53 2025 +0000
    
        docs(plan): Add C-level and Perl-level Coro tests to milestones
        
        - Added checklist items for `libcoro`-based C tests
          (e.g., `t/c/integration/050_convert_coro.c`) to all C layer
          integration milestones (050 through 220).
        - Updated `030_Integration_Protobuf.md` to standardise checklist
          items for the existing `030_protobuf_coro.c` test.
        - Removed the single `xt/author/coro-safe.t` item from
          `010_Build.md`.
        - Added checklist items for Perl-level `Coro` tests
          (e.g., `xt/coro/240_arena.t`) to each Perl layer
          integration milestone (240 through 400).
        - Created `perl/t/c/c_test_config.json` to manage C test
          configurations externally.
        - Updated `perl/doc/architecture/testing/01-xs-testing.md` to describe
          both C-level `libcoro` and Perl-level `Coro` testing strategies.
    
    
    ## 0.18	2025-12-18
    
    commit 6095a5a610401a6035a81429d0ccb9884d53687b
    Author: C.J. Collier 
    Date:   Thu Dec 18 02:34:31 2025 +0000
    
        added coro testing to c layer milestones
    
    
    ## 0.17	2025-12-18
    
    commit cc0aae78b1f7f675fc8a1e99aa876c0764ea1cce
    Author: C.J. Collier 
    Date:   Thu Dec 18 02:26:59 2025 +0000
    
        docs(plan): Refine test coverage checklist items for SMARTness
        
        - Updated the "Tests provide full coverage" checklist items in
          C layer plan files (020, 040, 060, 080, 100, 120, 140, 160, 180, 200)
          to explicitly mention testing all public functions in the
          corresponding header files.
        - Expanded placeholder checklists in 140, 160, 180, 200.
        - Updated the "Tests provide full coverage" and "Add coverage checks"
          checklist items in Perl layer plan files (230, 250, 270, 290, 310, 330,
          350, 370, 390) to be more specific about the scope of testing
          and the use of `Test::TestCoverage`.
        - Expanded Well-Known Types milestone (350) to detail each type.
    
    
    ## 0.16	2025-12-18
    
    commit e4b601f14e3817a17b0f4a38698d981dd4cb2818
    Author: C.J. Collier 
    Date:   Thu Dec 18 02:07:35 2025 +0000
    
        docs(plan): Full refactoring of C and Perl plan files
        
        - Split both ProtobufPlan-C.md and ProtobufPlan-Perl.md into
          per-milestone files under the `perl/doc/plan/` directory.
        - Introduced Integration Test milestones after each component
          milestone in both C and Perl plans.
        - Numbered milestone files sequentially (e.g., 010_Build.md,
          230_Perl_Arena.md).
        - Updated main ProtobufPlan-C.md and ProtobufPlan-Perl.md to
          act as Tables of Contents.
        - Ensured consistent naming for integration test files
          (e.g., `t/c/integration/030_protobuf.c`, `t/integration/260_descriptor_pool.t`).
        - Added architecture review steps to the end of all milestones.
        - Moved Coro safety test to C layer Milestone 1.
        - Updated Makefile.PL to support new test structure and added Coro.
        - Moved and split t/c/convert.c into t/c/convert/*.c.
        - Moved other t/c/*.c tests into t/c/protobuf/*.c.
        - Deleted old t/c/convert.c.
    
    
    ## 0.15	2025-12-17
    
    commit 649cbacf03abb5e7293e3038bb451c0406e9d0ce
    Author: C.J. Collier 
    Date:   Wed Dec 17 23:51:22 2025 +0000
    
        docs(plan): Refactor and reset ProtobufPlan.md
        
        - Split the plan into ProtobufPlan-C.md and ProtobufPlan-Perl.md.
        - Reorganized milestones to clearly separate C layer and Perl layer development.
        - Added more granular checkboxes for each component:
          - C Layer: Create test, Test coverage, Implement, Tests pass.
          - Perl Layer: Create test, Test coverage, Implement Module/XS, Tests pass, C-Layer adjustments.
        - Reset all checkboxes to `[ ]` to prepare for a full audit.
        - Updated status in architecture/api and architecture/core documents to "Not Started".
        
        feat(obj_cache): Add unregister function and enhance tests
        
        - Added `protobuf_unregister_object` to `xs/protobuf/obj_cache.c`.
        - Updated `xs/protobuf/obj_cache.h` with the new function declaration.
        - Expanded tests in `t/c/protobuf_obj_cache.c` to cover unregistering,
          overwriting keys, and unregistering non-existent keys.
        - Corrected the test plan count in `t/c/protobuf_obj_cache.c` to 17.
    
    
    ## 0.14	2025-12-17
    
    commit 40b6ad14ca32cf16958d490bb575962f88d868a1
    Author: C.J. Collier 
    Date:   Wed Dec 17 23:18:27 2025 +0000
    
        feat(arena): Complete C layer for Arena wrapper
        
        This commit finalizes the C-level implementation for the Protobuf::Arena wrapper.
        
        - Adds `PerlUpb_Arena_Destroy` for proper cleanup from Perl's DEMOLISH.
        - Enhances error checking in `PerlUpb_Arena_Get`.
        - Expands C-level tests in `t/c/protobuf_arena.c` to cover memory allocation
          on the arena and lifecycle through `PerlUpb_Arena_Destroy`.
        - Corrects embedded Perl initialization in the C test.
        
        docs(plan): Refactor ProtobufPlan.md
        
        - Restructures the development plan to clearly separate "C Layer" and
          "Perl Layer" tasks within each milestone.
        - This aligns the plan with the "C-First Implementation Strategy" and improves progress tracking.
    
    
    ## 0.13	2025-12-17
    
    commit c1e566c25f62d0ae9f195a6df43b895682652c71
    Author: C.J. Collier 
    Date:   Wed Dec 17 22:00:40 2025 +0000
    
        refactor(perl): Rename C tests and enhance Makefile.PL
        
        - Renamed test files in `t/c/` to better match the `xs` module structure:
            - `01-cache.c` -> `protobuf_obj_cache.c`
            - `02-arena.c` -> `protobuf_arena.c`
            - `03-utils.c` -> `protobuf_utils.c`
            - `04-convert.c` -> `convert.c`
            - `load_test.c` -> `upb_descriptor_load.c`
        - Updated `perl/Makefile.PL` to reflect the new test names in `MY::postamble`'s `$c_test_config`.
        - Refactored the `$c_test_config` generation in `Makefile.PL` to reduce repetition by using a default flags hash and common dependencies array.
        - Added a `fail()` macro to `perl/t/c/upb-perl-test.h` for consistency.
        - Modified `t/c/upb_descriptor_load.c` to use the `t/c/upb-perl-test.h` macros, making its output consistent with other C tests.
        - Added a skeleton for `t/c/convert.c` to test the conversion functions.
        - Updated documentation in `ProtobufPlan.md` and `architecture/testing/01-xs-testing.md` to reflect new test names.
    
    
    ## 0.12	2025-12-17
    
    commit d8cb5dd415c6c129e71cd452f78e29de398a82c9
    Author: C.J. Collier 
    Date:   Wed Dec 17 20:47:38 2025 +0000
    
        feat(perl): Refactor XS code into subdirectories
        
        This commit reorganizes the C code in the `perl/xs/` directory into subdirectories, mirroring the structure of the Python UPB extension. This enhances modularity and maintainability.
        
        - Created subdirectories for each major component: `convert`, `descriptor`, `descriptor_containers`, `descriptor_pool`, `extension_dict`, `map`, `message`, `protobuf`, `repeated`, and `unknown_fields`.
        - Created skeleton `.h` and `.c` files within each subdirectory to house the component-specific logic.
        - Updated top-level component headers (e.g., `perl/xs/descriptor.h`) to include the new sub-headers.
        - Updated top-level component source files (e.g., `perl/xs/descriptor.c`) to include their main header and added stub initialization functions (e.g., `PerlUpb_InitDescriptor`).
        - Moved code from the original `perl/xs/protobuf.c` to new files in `perl/xs/protobuf/` (arena, obj_cache, utils).
        - Moved code from the original `perl/xs/convert.c` to new files in `perl/xs/convert/` (upb_to_sv, sv_to_upb).
        - Updated `perl/Makefile.PL` to use a glob (`xs/*/*.c`) to find the new C source files in the subdirectories.
        - Added `perl/doc/architecture/core/07-xs-file-organization.md` to document the new structure.
        - Updated `perl/doc/ProtobufPlan.md` and other architecture documents to reference the new organization.
        - Corrected self-referential includes in the newly created .c files.
        
        This restructuring provides a solid foundation for further development and makes it easier to port logic from the Python implementation.
    
    
    ## 0.11	2025-12-17
    
    commit cdedcd13ded4511b0464f5d3bdd72ce6d34e73fc
    Author: C.J. Collier 
    Date:   Wed Dec 17 19:57:52 2025 +0000
    
        feat(perl): Implement C-first testing and core XS infrastructure
        
        This commit introduces a significant refactoring of the Perl XS extension, adopting a C-first development approach to ensure a robust foundation.
        
        Key changes include:
        
        -   **C-Level Testing Framework:** Established a C-level testing system in `t/c/` with a dedicated Makefile, using an embedded Perl interpreter. Initial tests cover the object cache (`01-cache.c`), arena wrapper (`02-arena.c`), and utility functions (`03-utils.c`).
        -   **Core XS Infrastructure:**
            -   Implemented a global object cache (`xs/protobuf.c`) to manage Perl wrappers for UPB objects, using weak references.
            -   Created an `upb_Arena` wrapper (`xs/protobuf.c`).
            -   Consolidated common XS helper functions into `xs/protobuf.h` and `xs/protobuf.c`.
        -   **Makefile.PL Enhancements:** Updated to support building and linking C tests, incorporating flags from `ExtUtils::Embed`, and handling both `.c` and `.cc` source files.
        -   **XS File Reorganization:** Restructured XS files to mirror the Python UPB extension's layout (e.g., `message.c`, `descriptor.c`). Removed older, monolithic `.xs` files.
        -   **Typemap Expansion:** Added extensive typemap entries in `perl/typemap` to handle conversions between Perl objects and various `const upb_*Def*` pointers.
        -   **Descriptor Tests:** Added a new test suite `t/02-descriptor.t` to validate descriptor loading and accessor methods.
        -   **Documentation:** Updated development plans and guidelines (`ProtobufPlan.md`, `xs_learnings.md`, etc.) to reflect the C-first strategy, new testing methods, and lessons learned.
        -   **Build Cleanup:** Removed `ppport.h` from `.gitignore` as it's no longer used, due to `-DPERL_NO_PPPORT` being set in `Makefile.PL`.
        
        This C-first approach allows for more isolated and reliable testing of the core logic interacting with the UPB library before higher-level Perl APIs are built upon it.
    
    
    ## 0.10	2025-12-17
    
    commit 1ef20ade24603573905cb0376670945f1ab5d829
    Author: C.J. Collier 
    Date:   Wed Dec 17 07:08:29 2025 +0000
    
        feat(perl): Implement C-level tests and core XS utils
        
        This commit introduces a C-level testing framework for the XS layer and implements key components:
        
        1.  **C-Level Tests (`t/c/`)**:
            *   Added `t/c/Makefile` to build standalone C tests.
            *   Created `t/c/upb-perl-test.h` with macros for TAP-compliant C tests (`plan`, `ok`, `is`, `is_string`, `diag`).
            *   Implemented `t/c/01-cache.c` to test the object cache.
            *   Implemented `t/c/02-arena.c` to test `Protobuf::Arena` wrappers.
            *   Implemented `t/c/03-utils.c` to test string utility functions.
            *   Corrected include paths and diagnostic messages in C tests.
        
        2.  **XS Object Cache (`xs/protobuf.c`)**:
            *   Switched to using stringified pointers (`%p`) as hash keys for stability.
            *   Fixed a critical double-free bug in `PerlUpb_ObjCache_Delete` by removing an extra `SvREFCNT_dec` on the lookup key.
        
        3.  **XS Arena Wrapper (`xs/protobuf.c`)**:
            *   Corrected `PerlUpb_Arena_New` to use `newSVrv` and `PTR2IV` for opaque object wrapping.
            *   Corrected `PerlUpb_Arena_Get` to safely unwrap the arena pointer.
        
        4.  **Makefile.PL (`perl/Makefile.PL`)**:
            *   Added `-Ixs` to `INC` to allow C tests to find `t/c/upb-perl-test.h` and `xs/protobuf.h`.
            *   Added `LIBS` to link `libprotobuf_common.a` into the main `Protobuf.so`.
            *   Added C test targets `01-cache`, `02-arena`, `03-utils` to the test config in `MY::postamble`.
        
        5.  **Protobuf.pm (`perl/lib/Protobuf.pm`)**:
            *   Added `use XSLoader;` to load the compiled XS code.
        
        6.  **New files `xs/util.h`**:
            *   Added initial type conversion function.
        
        These changes establish a foundation for testing the C-level interface with UPB and fix crucial bugs in the object cache implementation.
    
    
    ## 0.09	2025-12-17
    
    commit 07d61652b032b32790ca2d3848243f9d75ea98f4
    Author: C.J. Collier 
    Date:   Wed Dec 17 04:53:34 2025 +0000
    
        feat(perl): Build system and C cache test for Perl XS
        
        This commit introduces the foundational pieces for the Perl XS implementation, focusing on the build system and a C-level test for the object cache.
        
        -   **Makefile.PL:**
            -   Refactored C test compilation rules in `MY::postamble` to use a hash (`$c_test_config`) for better organization and test-specific flags.
            -   Integrated `ExtUtils::Embed` to provide necessary compiler and linker flags for embedding the Perl interpreter, specifically for the `t/c/01-cache.c` test.
            -   Correctly constructs the path to the versioned Perl library (`libperl.so.X.Y.Z`) using `$Config{archlib}` and `$Config{libperl}` to ensure portability.
            -   Removed `VERSION_FROM` and `ABSTRACT_FROM` to avoid dependency on `.pm` files for now.
        
        -   **C Cache Test (t/c/01-cache.c):**
            -   Added a C test to exercise the object cache functions implemented in `xs/protobuf.c`.
            -   Includes tests for adding, getting, deleting, and weak reference behavior.
        
        -   **XS Cache Implementation (xs/protobuf.c, xs/protobuf.h):**
            -   Implemented `PerlUpb_ObjCache_Init`, `PerlUpb_ObjCache_Add`, `PerlUpb_ObjCache_Get`, `PerlUpb_ObjCache_Delete`, and `PerlUpb_ObjCache_Destroy`.
            -   Uses a Perl hash (`HV*`) for the cache.
            -   Keys are string representations of the C pointers, created using `snprintf` with `"%llx"`.
            -   Values are weak references (`sv_rvweaken`) to the Perl objects (`SV*`).
            -   `PerlUpb_ObjCache_Get` now correctly returns an incremented reference to the original SV, not a copy.
            -   `PerlUpb_ObjCache_Destroy` now clears the hash before decrementing its refcount.
        
        -   **t/c/upb-perl-test.h:**
            -   Updated `is_sv` to perform direct pointer comparison (`got == expected`).
        
        -   **Minor:** Added `util.h` (currently empty), updated `typemap`.
        
        These changes establish a working C-level test environment for the XS components.
    
    
    ## 0.08	2025-12-17
    
    commit d131fd22ea3ed8158acb9b0b1fe6efd856dc380e
    Author: C.J. Collier 
    Date:   Wed Dec 17 02:57:48 2025 +0000
    
        feat(perl): Update docs and core XS files
        
        - Explicitly add TDD cycle to ProtobufPlan.md.
        - Clarify mirroring of Python implementation in upb-interfacing.md for both C and Perl layers.
        - Branch and adapt python/protobuf.h and python/protobuf.c to perl/xs/protobuf.h and perl/xs/protobuf.c, including the object cache implementation. Removed old cache.* files.
        - Create initial C test for the object cache in t/c/01-cache.c.
    
    
    ## 0.07	2025-12-17
    
    commit 56fd6862732c423736a2f9a9fb1a2816fc59e9b0
    Author: C.J. Collier 
    Date:   Wed Dec 17 01:09:18 2025 +0000
    
        feat(perl): Align Perl UPB architecture docs with Python
        
        Updates the Perl Protobuf architecture documents to more closely align with the design and implementation strategies used in the Python UPB extension.
        
        Key changes:
        
        -   **Object Caching:** Mandates a global, per-interpreter cache using weak references for all UPB-derived objects, mirroring Python's `PyUpb_ObjCache`.
        -   **Descriptor Containers:** Introduces a new document outlining the plan to use generic XS container types (Sequence, ByNameMap, ByNumberMap) with vtables to handle collections of descriptors, similar to Python's `descriptor_containers.c`.
        -   **Testing:** Adds a note to the testing strategy to port relevant test cases from the Python implementation to ensure feature parity.
    
    
    ## 0.06	2025-12-17
    
    commit 6009ce6ab64eccce5c48729128e5adf3ef98e9ae
    Author: C.J. Collier 
    Date:   Wed Dec 17 00:28:20 2025 +0000
    
        feat(perl): Implement object caching and fix build
        
        This commit introduces several key improvements to the Perl XS build system and core functionality:
        
        1.  **Object Caching:**
            *   Introduces `xs/protobuf.c` and `xs/protobuf.h` to implement a caching mechanism (`protobuf_c_to_perl_obj`) for wrapping UPB C pointers into Perl objects. This uses a hash and weak references to ensure object identity and prevent memory leaks.
            *   Updates the `typemap` to use `protobuf_c_to_perl_obj` for `upb_MessageDef *` output, ensuring descriptor objects are cached.
            *   Corrected `sv_weaken` to the correct `sv_rvweaken` function.
        
        2.  **Makefile.PL Enhancements:**
            *   Switched to using the Bazel-generated UPB descriptor sources from `bazel-bin/src/google/protobuf/_virtual_imports/descriptor_proto/google/protobuf/`.
            *   Updated `INC` paths to correctly locate the generated headers.
            *   Refactored `MY::dynamic_lib` to ensure the static library `libprotobuf_common.a` is correctly linked into each generated `.so` module, resolving undefined symbol errors.
            *   Overrode `MY::test` to use `prove -b -j$(nproc) t/*.t xt/*.t` for running tests.
            *   Cleaned up `LIBS` and `LDDLFLAGS` usage.
        
        3.  **Documentation:**
            *   Updated `ProtobufPlan.md` to reflect the current status and design decisions.
            *   Reorganized architecture documents into subdirectories.
            *   Added `object-caching.md` and `c-perl-interface.md`.
            *   Updated `llm-guidance.md` with notes on `upb/upb.h` and `sv_rvweaken`.
        
        4.  **Testing:**
            *   Fixed `xt/03-moo_immutable.t` to skip tests if no Moo modules are found.
        
        This resolves the build issues and makes the core test suite pass.
    
    
    ## 0.05	2025-12-16
    
    commit 177d2f3b2608b9d9c415994e076a77d8560423b8
    Author: C.J. Collier 
    Date:   Tue Dec 16 19:51:36 2025 +0000
    
        Refactor: Rename namespace to Protobuf, build system and doc updates
        
        This commit refactors the primary namespace from `ProtoBuf` to `Protobuf`
        to align with the style guide. This involves renaming files, directories,
        and updating package names within all Perl and XS files.
        
        **Namespace Changes:**
        
        *   Renamed `perl/lib/ProtoBuf` to `perl/lib/Protobuf`.
        *   Moved and updated `ProtoBuf.pm` to `Protobuf.pm`.
        *   Moved and updated `ProtoBuf::Descriptor` to `Protobuf::Descriptor` (.pm & .xs).
        *   Removed other `ProtoBuf::*` stubs (Arena, DescriptorPool, Message).
        *   Updated `MODULE` and `PACKAGE` in `Descriptor.xs`.
        *   Updated `NAME`, `*_FROM` in `perl/Makefile.PL`.
        *   Replaced `ProtoBuf` with `Protobuf` throughout `perl/typemap`.
        *   Updated namespaces in test files `t/01-load-protobuf-descriptor.t` and `t/02-descriptor.t`.
        *   Updated namespaces in all documentation files under `perl/doc/`.
        *   Updated paths in `perl/.gitignore`.
        
        **Build System Enhancements (Makefile.PL):**
        
        *   Included `xs/*.c` files in the common object files list.
        *   Added `-I.` to the `INC` paths.
        *   Switched from `MYEXTLIB` to `LIBS => ['-L$(CURDIR) -lprotobuf_common']` for linking.
        *   Removed custom keys passed to `WriteMakefile` for postamble.
        *   `MY::postamble` now sources variables directly from the main script scope.
        *   Added `all :: ${common_lib}` dependency in `MY::postamble`.
        *   Added `t/c/load_test.c` compilation rule in `MY::postamble`.
        *   Updated `clean` target to include `blib`.
        *   Added more modules to `TEST_REQUIRES`.
        *   Removed the explicit `PM` and `XS` keys from `WriteMakefile`, relying on `XSMULTI => 1`.
        
        **New Files:**
        
        *   `perl/lib/Protobuf.pm`
        *   `perl/lib/Protobuf/Descriptor.pm`
        *   `perl/lib/Protobuf/Descriptor.xs`
        *   `perl/t/01-load-protobuf-descriptor.t`
        *   `perl/t/02-descriptor.t`
        *   `perl/t/c/load_test.c`: Standalone C test for UPB.
        *   `perl/xs/types.c` & `perl/xs/types.h`: For Perl/C type conversions.
        *   `perl/doc/architecture/upb-interfacing.md`
        *   `perl/xt/03-moo_immutable.t`: Test for Moo immutability.
        
        **Deletions:**
        
        *   Old test files: `t/00_load.t`, `t/01_basic.t`, `t/02_serialize.t`, `t/03_message.t`, `t/04_descriptor_pool.t`, `t/05_arena.t`, `t/05_message.t`.
        *   Removed `lib/ProtoBuf.xs` as it's not needed with `XSMULTI`.
        
        **Other:**
        
        *   Updated `test_descriptor.bin` (binary change).
        *   Significant content updates to markdown documentation files in `perl/doc/architecture` and `perl/doc/internal` reflecting the new architecture and learnings.
    
    
    ## 0.04	2025-12-14
    
    commit 92de5d482c8deb9af228f4b5ce31715d3664d6ee
    Author: C.J. Collier 
    Date:   Sun Dec 14 21:28:19 2025 +0000
    
        feat(perl): Implement Message object creation and fix lifecycles
        
        This commit introduces the basic structure for `ProtoBuf::Message` object
        creation, linking it with `ProtoBuf::Descriptor` and `ProtoBuf::DescriptorPool`,
        and crucially resolves a SEGV by fixing object lifecycle management.
        
        Key Changes:
        
        1.  **`ProtoBuf::Descriptor`:** Added `_pool` attribute to hold a strong
            reference to the parent `ProtoBuf::DescriptorPool`. This is essential to
            prevent the pool and its C `upb_DefPool` from being garbage collected
            while a descriptor is still in use.
        
        2.  **`ProtoBuf::DescriptorPool`:**
            *   `find_message_by_name`: Now passes the `$self` (the pool object) to the
                `ProtoBuf::Descriptor` constructor to establish the lifecycle link.
            *   XSUB `pb_dp_find_message_by_name`: Updated to accept the pool `SV*` and
                store it in the descriptor's `_pool` attribute.
            *   XSUB `_load_serialized_descriptor_set`: Renamed to avoid clashing with the
                Perl method name. The Perl wrapper now correctly calls this internal XSUB.
            *   `DEMOLISH`: Made safer by checking for attribute existence.
        
        3.  **`ProtoBuf::Message`:**
            *   Implemented using Moo with lazy builders for `_upb_arena` and
                `_upb_message`.
            *   `_descriptor` is a required argument to `new()`.
            *   XS functions added for creating the arena (`pb_msg_create_arena`) and
                the `upb_Message` (`pb_msg_create_upb_message`).
            *   `pb_msg_create_upb_message` now extracts the `upb_MessageDef*` from the
                descriptor and uses `upb_MessageDef_MiniTable()` to get the minitable
                for `upb_Message_New()`.
            *   `DEMOLISH`: Added to free the message's arena.
        
        4.  **`Makefile.PL`:**
            *   Added `-g` to `CCFLAGS` for debugging symbols.
            *   Added Perl CORE include path to `MY::postamble`'s `base_flags`.
        
        5.  **Tests:**
            *   `t/04_descriptor_pool.t`: Updated to check the structure of the
                returned `ProtoBuf::Descriptor`.
            *   `t/05_message.t`: Now uses a descriptor obtained from a real pool to
                test `ProtoBuf::Message->new()`.
        
        6.  **Documentation:**
            *   Updated `ProtobufPlan.md` to reflect progress.
            *   Updated several files in `doc/architecture/` to match the current
                implementation details, especially regarding arena management and object
                lifecycles.
            *   Added `doc/internal/development_cycle.md` and `doc/internal/xs_learnings.md`.
        
        With these changes, the SEGV is resolved, and message objects can be successfully
        created from descriptors.
    
    
    ## 0.03	2025-12-14
    
    commit 6537ad23e93680c2385e1b571d84ed8dbe2f68e8
    Author: C.J. Collier 
    Date:   Sun Dec 14 20:23:41 2025 +0000
    
        Refactor(perl): Object-Oriented DescriptorPool with Moo
        
        This commit refactors the `ProtoBuf::DescriptorPool` to be fully object-oriented using Moo, and resolves several issues related to XS, typemaps, and test data.
        
        Key Changes:
        
        1.  **Moo Object:** `ProtoBuf::DescriptorPool.pm` now uses `Moo` to define the class. The `upb_DefPool` pointer is stored as a lazy attribute `_upb_defpool`.
        2.  **XS Lifecycle:** `DescriptorPool.xs` now has `pb_dp_create_pool` called by the Moo builder and `pb_dp_free_pool` called from `DEMOLISH` to manage the `upb_DefPool` lifecycle per object.
        3.  **Typemap:** The `perl/typemap` file has been significantly updated to handle the conversion between the `ProtoBuf::DescriptorPool` Perl object and the `upb_DefPool *` C pointer. This includes:
            *   Mapping `upb_DefPool *` to `T_PTR`.
            *   An `INPUT` section for `ProtoBuf::DescriptorPool` to extract the pointer from the object's hash, triggering the lazy builder if needed via `call_method`.
            *   An `OUTPUT` section for `upb_DefPool *` to convert the pointer back to a Perl integer, used by the builder.
        4.  **Method Renaming:** `add_file_descriptor_set_binary` is now `load_serialized_descriptor_set`.
        5.  **Test Data:**
            *   Added `perl/t/data/test.proto` with a sample message and enum.
            *   Generated `perl/t/data/test_descriptor.bin` using `protoc`.
            *   Removed `t/data/` from `.gitignore` to ensure test data is versioned.
        6.  **Test Update:** `t/04_descriptor_pool.t` is updated to use the new OO interface, load the generated descriptor set, and check for message definitions.
        7.  **Build Fixes:**
            *   Corrected `#include` paths in `DescriptorPool.xs` to be relative to the `upb/` directory (e.g., `upb/wire/decode.h`).
            *   Added `-I../upb` to `CCFLAGS` in `Makefile.PL`.
            *   Reordered `INC` paths in `Makefile.PL` to prioritize local headers.
        
        **Note:** While tests now pass in some environments, a SEGV issue persists in `make test` runs, indicating a potential memory or lifecycle issue within the XS layer that needs further investigation.
    
    
    ## 0.02	2025-12-14
    
    commit 6c9a6f1a5f774dae176beff02219f504ea3a6e07
    Author: C.J. Collier 
    Date:   Sun Dec 14 20:13:09 2025 +0000
    
        Fix(perl): Correct UPB build integration and generated file handling
        
        This commit resolves several issues to achieve a successful build of the Perl extension:
        
        1.  **Use Bazel Generated Files:** Switched from compiling UPB's stage0 descriptor.upb.c to using the Bazel-generated `descriptor.upb.c` and `descriptor.upb_minitable.c` located in `bazel-bin/src/google/protobuf/_virtual_imports/descriptor_proto/google/protobuf/`.
        2.  **Updated Include Paths:** Added the `bazel-bin` path to `INC` in `WriteMakefile` and to `base_flags` in `MY::postamble` to ensure the generated headers are found during both XS and static library compilation.
        3.  **Removed Stage0:** Removed references to `UPB_STAGE0_DIR` and no longer include headers or source files from `upb/reflection/stage0/`.
        4.  **-fPIC:** Explicitly added `-fPIC` to `CCFLAGS` in `WriteMakefile` and ensured `$(CCFLAGS)` is used in the custom compilation rules in `MY::postamble`. This guarantees all object files in the static library are compiled with position-independent code, resolving linker errors when creating the shared objects for the XS modules.
        5.  **Refined UPB Sources:** Used `File::Find` to recursively find UPB C sources, excluding `/conformance/` and `/reflection/stage0/` to avoid conflicts and unnecessary compilations.
        6.  **Arena Constructor:** Modified `ProtoBuf::Arena::pb_arena_new` XSUB to accept the class name argument passed from Perl, making it a proper constructor.
        7.  **.gitignore:** Added patterns to `perl/.gitignore` to ignore generated C files from XS (`lib/*.c`, `lib/ProtoBuf/*.c`), the copied `src_google_protobuf_descriptor.pb.cc`, and the `t/data` directory.
        8.  **Build Documentation:** Updated `perl/doc/architecture/upb-build-integration.md` to reflect the new build process, including the Bazel prerequisite, include paths, `-fPIC` usage, and `File::Find`.
        
        Build Steps:
        1.  `bazel build //src/google/protobuf:descriptor_upb_proto` (from repo root)
        2.  `cd perl`
        3.  `perl Makefile.PL`
        4.  `make`
        5.  `make test` (Currently has expected failures due to missing test data implementation).
    
    
    ## 0.01	2025-12-14
    
    commit 3e237e8a26442558c94075766e0d4456daaeb71d
    Author: C.J. Collier 
    Date:   Sun Dec 14 19:34:28 2025 +0000
    
        feat(perl): Initialize Perl extension scaffold and build system
        
        This commit introduces the `perl/` directory, laying the groundwork for the Perl Protocol Buffers extension. It includes the essential build files, linters, formatter configurations, and a vendored Devel::PPPort for XS portability.
        
        Key components added:
        
        *   **`Makefile.PL`**: The core `ExtUtils::MakeMaker` build script. It's configured to:
            *   Build a static library (`libprotobuf_common.a`) from UPB, UTF8_Range, and generated protobuf C/C++ sources.
            *   Utilize `XSMULTI => 1` to create separate shared objects for `ProtoBuf`, `ProtoBuf::Arena`, and `ProtoBuf::DescriptorPool`.
            *   Link each XS module against the common static library.
            *   Define custom compilation rules in `MY::postamble` to handle C vs. C++ flags and build the static library.
            *   Set up include paths for the project root, UPB, and other dependencies.
        
        *   **XS Stubs (`.xs` files)**:
            *   `lib/ProtoBuf.xs`: Placeholder for the main module's XS functions.
            *   `lib/ProtoBuf/Arena.xs`: XS interface for `upb_Arena` management.
            *   `lib/ProtoBuf/DescriptorPool.xs`: XS interface for `upb_DefPool` management.
        
        *   **Perl Module Stubs (`.pm` files)**:
            *   `lib/ProtoBuf.pm`: Main module, loads XS.
            *   `lib/ProtoBuf/Arena.pm`: Perl class for Arenas.
            *   `lib/ProtoBuf/DescriptorPool.pm`: Perl class for Descriptor Pools.
            *   `lib/ProtoBuf/Message.pm`: Base class for messages (TBD).
        
        *   **Configuration Files**:
            *   `.gitignore`: Ignores build artifacts, editor files, etc.
            *   `.perlcriticrc`: Configures Perl::Critic for static analysis.
            *   `.perltidyrc`: Configures perltidy for code formatting.
        
        *   **`Devel::PPPort`**: Vendored version 3.72 to generate `ppport.h` for XS compatibility across different Perl versions.
        
        *   **`typemap`**: Custom typemap for XS argument/result conversion.
        
        *   **Documentation (`doc/`)**: Initial architecture and plan documents.
        
        This provides a solid foundation for developing the UPB-based Perl extension.
    
    
    
  • Navigating the Perils of Perl Mocking: A Debugging Journey

    As a software engineer, I often find myself deep in the trenches of
    testing, ensuring the code I write is not just functional but also
    resilient. Recently, I embarked on a refactoring project that involved
    moving a script’s functionality into a new Perl module,
    App::Workflow::Controller. This module’s job was to
    orchestrate a few tasks: query a database via an external CLI tool,
    fetch more details based on the results, and write outputs. This
    naturally called for mocking external dependencies in the unit tests,
    and that’s where the real fun began.

    My go-to tool for this is usually Test::MockModule.
    The module under test, App::Workflow::Controller, used:

    • IPC::Run to call the
      external CLI tool.
    • File::ShareDir
      to locate SQL files.
    • Internal modules like App::Data::Fetcher and
      App::Utils.

    Understanding
    the Mocking Challenge: Exported Functions

    The core challenge revolves around how Perl handles imported
    functions. When a module like App::Workflow::Controller
    uses use IPC::Run qw(run);, it copies the run
    subroutine into its own namespace at compile time.

    Key Insight 1: Mock in the Calling Namespace

    As the Test::MockModule
    documentation
    clearly states, to affect the run used
    by App::Workflow::Controller, you must mock
    App::Workflow::Controller::run. Mocking
    IPC::Run::run after App::Workflow::Controller
    is loaded has no effect on the already imported symbol.

    # t/controller.t
    use Test::More;
    use Test::MockModule;
    use App::Workflow::Controller; # Load the module first
    
    # Mock run within App::Workflow::Controller's namespace
    my $runner_mock = Test::MockModule->new('App::Workflow::Controller', no_auto => 1);
    $runner_mock->mock('run', sub {
        my ($cmd_array_ref, @redirections) = @_;
        # Mocked logic to handle the command and return expected results
        # Example:
        if ($cmd_array_ref->[0] eq '/usr/bin/my_cli_tool') {
            my $out_ref = $redirections[1]; # Assuming '>'
            $$out_ref = "mocked output";
            return 1; # Simulate success
        }
        die "Unexpected command";
    });
    
    # ... tests calling methods of App::Workflow::Controller that use run ...

    Key Insight 2: Timing Matters – BEGIN Blocks

    For dependencies used during the compilation of
    App::Workflow::Controller (e.g., in attribute defaults or
    builders using File::ShareDir), the mocks must be
    active before use App::Workflow::Controller; is
    executed. This requires placing the Test::MockModule setup
    for those specific dependencies inside a BEGIN block.

    # t/controller.t
    use strict;
    use warnings;
    use Test::More;
    use Test::MockModule;
    # ... other includes ...
    
    my $mock_sql_file_path = '...'; # Path to mock SQL
    
    BEGIN {
        # Mock File::ShareDir BEFORE App::Workflow::Controller is loaded
        my $fsd_mock = Test::MockModule->new('File::ShareDir');
        $fsd_mock->redefine('dist_file', sub { return $mock_sql_file_path; });
    }
    
    use App::Workflow::Controller;
    
    # ... Mock IPC::Run as shown above ...

    The IPC::Run Enigma: $self
    Corruption

    In this specific journey, despite correctly mocking
    App::Workflow::Controller::run, I encountered bizarre
    errors where the $self object within my module’s methods
    seemed to be corrupted, sometimes appearing as the command path. This
    indicated a deep, complex interaction between
    Test::MockModule’s override mechanism and the way
    IPC::Run manipulates the call stack or environment.

    After extensive debugging, it seems that directly mocking the
    imported run sub from IPC::Run can be
    unstable, potentially due to the intricacies of how
    IPC::Run works internally.

    The
    Pragmatic Solution: Mocking an Internal Wrapper

    The most robust solution was to avoid mocking the imported
    run directly. Instead, I refactored
    App::Workflow::Controller to have a small, internal method
    that wraps the call to IPC::Run::run:

    # In App::Workflow::Controller.pm
    sub _execute_cli {
        my ($self, @cmd_list) = @_;
        my $stdout;
        run \@cmd_list, '>', \$stdout or die "Failed";
        return $stdout;
    }
    
    sub some_other_method {
        my $self = shift;
        # ...
        my $output = $self->_execute_cli('/usr/bin/my_cli_tool', 'arg1');
        # ...
    }

    Then, in the test, I mock _execute_cli:

    # t/controller.t
    use Test::More;
    use Test::MockModule;
    use App::Workflow::Controller;
    
    my $controller_mock = Test::MockModule->new('App::Workflow::Controller');
    
    subtest 'Successful run' => sub {
        $controller_mock->redefine('_execute_cli', sub {
            my ($self, @cmd) = @_;
            # Check @cmd if necessary
            return "mocked cli output";
        });
    
        my $controller = App::Workflow::Controller->new();
        is($controller->some_other_method(), "expected result", "Test with mocked CLI");
    
        $controller_mock->unmock('_execute_cli');
    };

    This approach tests the logic around the CLI call without
    interfering with IPC::Run itself.

    Lessons Learned:

    1. Mocking Exported Functions: Always mock in the
      namespace of the importing module.
    2. Compile-Time Dependencies: Use BEGIN
      blocks to mock dependencies needed when the module under test is
      loaded.
    3. IPC::Run is Special: Directly mocking
      the imported run function from IPC::Run can be
      fragile and lead to unexpected side effects like $self
      corruption.
    4. Wrap and Mock: Encapsulating external calls like
      IPC::Run::run within internal methods provides a stable
      seam for mocking, avoiding direct interference with the complex external
      library.
    5. State Management: our variables with
      local hash key assignments in subtests remain a good
      pattern for managing mock state across test cases.

    This debugging journey was a deep dive into the nuances of Perl’s
    symbol table, compile-time vs. runtime, and the limits of mocking. The
    wrapper method pattern proved to be the most effective strategy for
    handling complex dependencies like IPC::Run.

  • Upgrading Proxmox 7 to 8

    Some variant of the following[1] worked for me.

    The first line is the start of a for loop that runs on each node in my cluster a command using ssh. The argument -t is passed to attach a controlling terminal to STDIN, STDERR and STDOUT of this session, since there will not be an intervening shell to do it for us. The argument to ssh is a workflow of bash commands. They upgrade the 7.x system to the most recent packages on the repository. We then update the sources.list entries for the system to point at bookworm sources instead of bullseye. The package cache is updated and the proxmox-ve package is installed. Packages which are installed are upgraded to the versions from bookworm, and the installer concludes.

    Dear reader, you might be surprised how many times I saw the word “perl” scroll by during the manual, serial scrolling of this install. It took hours. There were a few prompts, so stand by the keyboard!

    [1]

    gpg: key 1140AF8F639E0C39: public key "Proxmox Bookworm Release Key " imported
    # have your ssh agent keychain running and a key loaded that's installed at 
    # ~root/.ssh/authorized_keys on each node 
    apt-get install -y keychain
    eval $(keychain --eval)
    ssh-add ~/.ssh/id_rsa
    # Replace the IP address prefix (100.64.79.) and  suffixes (64, 121-128)
    # with the actual IPs of your cluster nodes.  Or use hostnames :-)
    for o in 64 121 122 123 124 125 126 127 128 ; do   ssh -t root@100.64.79.$o '
      sed -i -e s/bullseye/bookworm/g /etc/apt/sources.list $(compgen -G "/etc/apt/sources.listd.d/*.list") \
      && echo "deb [signed-by=/usr/share/keyrings/proxmox-release.gpg] http://download.proxmox.com/debian/pve bookworm pve-no-subscription" \
        | dd of=/etc/apt/sources.list.d/proxmox-release.list status=none \
      && echo "deb [signed-by=/usr/share/keyrings/proxmox-release.gpg] http://download.proxmox.com/debian/ceph-quincy bookworm main no-subscription" \
        | dd of=/etc/apt/sources.list.d/ceph.list status=none \
      && proxmox_keyid="0xf4e136c67cdce41ae6de6fc81140af8f639e0c39" \
      && curl "https://keyserver.ubuntu.com/pks/lookup?op=get&search=${proxmox_keyid}" \
        | gpg --dearmor -o /usr/share/keyrings/proxmox-release.gpg  \
      && apt-get -y -qq update \
      && apt-get -y -qq install proxmox-ve \
      && apt-get -y -qq full-upgrade \
      && echo "$(hostname) upgraded"'; done
    
  • First taste of Debian 12

    As some of you may know, the Debian project released v12, bookworm to stable on the 10th of this month. I haven’t had a reason to try it yet, but I’m downloading it now. My first thought is that it’s much larger than I expected. The normal sized version used to fit on a CD-ROM disk, so around 650MB. The netinst has until now been even smaller, with the most recent versions being about 256MB if I recall correctly. The netinst, now with proprietary firmware, weighs in over 700MB:

    2023-06-18 20:29:29 (6.85 MB/s) - ‘debian-12.0.0-amd64-netinst.iso’ saved [773849088/773849088]

    It looks like 738.0MB!

    The system I’m installing is for a piece of software I’m crafting for use by Remote Online Notaries. I’m building a disk image for the notary’s side of the connection. The notary will have a yubikey-style PGP card which they will use as a digital seal similar to the one required to perform notarial acts for the state of washington. I’ll leave some ramblings on the blog as I go through the process of implementation. Here’s a link to whet your appetite!

    https://app.leg.wa.gov/wac/default.aspx?cite=308-30-020