Skip to content

refactor(zig): migrate codebase from 0.15.2 to 0.16.0#49

Merged
pocky merged 1 commit into
mainfrom
feature/F024-zig-0152--0160-migration
May 26, 2026
Merged

refactor(zig): migrate codebase from 0.15.2 to 0.16.0#49
pocky merged 1 commit into
mainfrom
feature/F024-zig-0152--0160-migration

Conversation

@pocky
Copy link
Copy Markdown
Contributor

@pocky pocky commented May 26, 2026

Summary

  • Migrate the entire ztick codebase from Zig 0.15.2 to 0.16.0, adopting breaking API changes across I/O namespaces, threading primitives, the build system, and the main entry point signature
  • Bump zig-o11y/opentelemetry-sdk to v0.2.0 and sam701/zig-cli to the main branch (v0.11.0), both required for 0.16 compatibility
  • Fix 9 of 11 functional test failures introduced by the migration, including graceful HTTP shutdown coordination and a memory leak in the test helper
  • Restructure CLAUDE.md to delegate queryable rules (architecture, pitfalls, tests, review) to a new ZPM knowledge base, replacing inline markdown lists

Changes

Build system & CI

  • build.zig: Switch to root_module.link_libc, root_module.linkSystemLibrary with options struct, pass b.graph.io to handle.access, drop explicit target/optimize forwarding to dependencies (0.16 propagates them automatically)
  • build.zig.zon: Bump minimum_zig_version to 0.16.0; update OTel hash to v0.2.0 and zig-cli hash to main branch (v0.11.0)
  • Makefile: Add --test-timeout 30s to integration test invocations
  • .github/workflows/ci.yaml: Update all four jobs (lint, test, sanitize, build) from Zig 0.15.2 → 0.16.0
  • .github/workflows/release.yaml: Bump ZIG_VERSION env var to 0.16.0

Application layer

  • src/application/scheduler.zig: Migrate std.time / threading primitives to 0.16 equivalents; thread io: std.Io through scheduler context
  • src/application/execution_client.zig: Update I/O and process APIs
  • src/application/job_storage.zig: Namespace and API fixes
  • src/application/query_handler.zig: I/O namespace migration

Infrastructure — I/O and concurrency

  • src/infrastructure/clock.zig: Replace std.time.Instant with std.Io.Clock.Timestamp; cache io on struct to preserve allocation-free tick semantics
  • src/infrastructure/channel.zig: Replace std.Thread.Mutex/Condition with std.Io.Mutex/Condition; fix timedWait signature
  • src/infrastructure/tcp_server.zig: Migrate std.netstd.Io.net, update stream reader/writer pattern, fix graceful shutdown signaling
  • src/infrastructure/http.zig: Migrate std.http.Server to 0.16 reader/writer interface; wire HTTP shutdown to signal handler; update Reader/Writer types
  • src/infrastructure/http/json.zig: Namespace update
  • src/infrastructure/telemetry.zig: Adopt OTel SDK v0.2.0 init signature; fix io_rng lifetime for telemetry setup
  • src/infrastructure/auth.zig: Update socket/poll APIs (remove std.posix, use std.os.linux syscalls)
  • src/infrastructure/tls_context.zig: Fix @cImport and pointer-cast idioms for 0.16

Infrastructure — persistence

  • src/infrastructure/persistence/backend.zig: Migrate I/O file APIs
  • src/infrastructure/persistence/background.zig: Thread io parameter; update threading primitives
  • src/infrastructure/persistence/logfile.zig: Namespace update

Infrastructure — protocol & runners

  • src/infrastructure/protocol/parser.zig: Namespace update
  • src/infrastructure/redis/resp.zig: Migrate std.io.fixedBufferStreamstd.Io.Reader.fixed/std.Io.Writer.fixed
  • src/infrastructure/runner.zig, runner/amqp.zig, runner/awf.zig, runner/direct.zig, runner/http.zig, runner/redis.zig, runner/shell.zig, runner/subprocess.zig: Update I/O, process spawn, and stream APIs throughout

Entry point & interfaces

  • src/main.zig: Adopt Juicy Main (pub fn main(init: std.process.Init) !void); source GPA, args, and io from init; replace @Type(.enum_literal) with @EnumLiteral; update signal handler type to fn(std.os.linux.SIG) callconv(.c) void; thread io through all subsystems
  • src/interfaces/cli.zig: Route init.minimal.args via Args.Iterator.initAllocator; remove std.process.argsAlloc/argsFree
  • src/interfaces/config.zig: Update TOML parsing I/O
  • src/interfaces/dump.zig: Migrate file I/O APIs

Tests

  • src/functional_tests.zig: Overhaul 1874-line test file — fix TestServer.start/stop to use std.Io child process APIs, add atomic shutdown signaling, fix TestServer memory leak (free config_path via allocator.free directly), fix telemetry io_rng lifetime, add defer-based cleanup

Documentation & project metadata

  • CHANGELOG.md: Add F024 migration entry under [Unreleased]
  • CLAUDE.md: Replace inline rule lists with ZPM query references; add ZPM project memory section with segment definitions and query patterns
  • CONTRIBUTING.md, README.md: Bump Zig prerequisite to 0.16.0+
  • docs/ADR/0002-zig-language-choice.md, 0003-openssl-tls-dependency.md, 0004-opentelemetry-sdk-dependency.md, 0005-amqp-runner-design.md, 0006-redis-runner-design.md: Update version references to 0.16.0
  • docs/development/building.md, docs/tutorials/getting-started.md: Update Zig version prerequisites
  • .gitignore: Add zig-pkg/, *.o, and AWF/web project artifact patterns

ZPM knowledge base

  • .zpm/kb/default/knowledge.pl, journal.wal: Base schema for task graphs, components, ADRs, and project memory
  • .zpm/kb/feedback/knowledge.pl, journal.wal: 40+ queryable architecture, pitfall, test, and review rules migrated from CLAUDE.md
  • .zpm/kb/migration_zig016/knowledge.pl, journal.wal: Migration scope, breaking changes, verified APIs, and corrections recorded during F024
  • .zpm/kb/pr_feature_f024_zig_0152_0160_migration/knowledge.pl, journal.wal: PR task completion tracking
  • .zpm/mounts.json: Mount configuration for all four segments
  • .zpm/kb/before_commit_20260427_160139.pl: Deleted obsolete snapshot file

Test plan

  • make build compiles with Zig 0.16.0 (no deprecation errors or API failures)
  • zig build test-all passes all unit tests across all layers (domain, application, infrastructure, interfaces)
  • zig build test-functional passes with no memory leaks reported by DebugAllocator
  • CI pipeline (lint → test → sanitize → build) runs green with mlugg/setup-zig@v2 installing version 0.16.0

Closes #48


Generated with awf commit workflow

- `.github/workflows/ci.yaml`: Update Zig version to 0.16.0 in lint, test, sanitize, build jobs
- `.github/workflows/release.yaml`: Update ZIG_VERSION env var to 0.16.0
- `.gitignore`: Add new ignore patterns for Zig 0.16 build artifacts
- `build.zig`: Adopt 0.16 linking API and new build system idioms
- `build.zig.zon`: Set minimum_zig_version to 0.16.0, update dependencies
- `src/main.zig`: Migrate to Juicy Main pattern with std.process.Init
- `src/interfaces/cli.zig`: Adopt std.Io namespace and new arg routing
- `src/interfaces/config.zig`: Update to std.Io.File and 0.16 fs idioms
- `src/interfaces/dump.zig`: Migrate streaming dump to 0.16 Reader/Writer
- `src/infrastructure/clock.zig`: Rewrite with futex-based wake and std.Io.Clock
- `src/infrastructure/channel.zig`: Update Channel to 0.16 concurrency primitives
- `src/infrastructure/http.zig`: Adopt std.http.Server Reader/Writer interface pattern
- `src/infrastructure/http/json.zig`: Update JSON serialization to 0.16 API
- `src/infrastructure/tcp_server.zig`: Migrate TCP server to 0.16 std.Io
- `src/infrastructure/telemetry.zig`: Fix random ID generator lifetime for std.Io
- `src/infrastructure/tls_context.zig`: Update TLS bindings to 0.16 C interop
- `src/infrastructure/auth.zig`: Migrate to 0.16 string/buffer primitives
- `src/infrastructure/persistence/backend.zig`: Update persistence backend to 0.16 API
- `src/infrastructure/persistence/background.zig`: Migrate background worker to 0.16
- `src/infrastructure/persistence/logfile.zig`: Minor 0.16 API updates
- `src/infrastructure/protocol/parser.zig`: Update parser to std.mem.splitScalar
- `src/infrastructure/redis/resp.zig`: Migrate RESP protocol to fixed Reader/Writer
- `src/infrastructure/runner.zig`: Update runner dispatch to 0.16 idioms
- `src/infrastructure/runner/amqp.zig`: Migrate AMQP runner to 0.16 std.Io
- `src/infrastructure/runner/awf.zig`: Update AWF runner to 0.16 API
- `src/infrastructure/runner/direct.zig`: Migrate direct runner to 0.16
- `src/infrastructure/runner/http.zig`: Update HTTP runner to 0.16 client API
- `src/infrastructure/runner/redis.zig`: Migrate Redis runner to 0.16 std.Io
- `src/infrastructure/runner/shell.zig`: Update shell runner to 0.16 process API
- `src/infrastructure/runner/subprocess.zig`: Migrate subprocess runner to 0.16
- `src/application/execution_client.zig`: Update execution client to 0.16 API
- `src/application/job_storage.zig`: Migrate job storage to 0.16 hash map idioms
- `src/application/query_handler.zig`: Update query handler to 0.16 patterns
- `src/application/scheduler.zig`: Migrate scheduler to 0.16 concurrency primitives
- `src/functional_tests.zig`: Fix all functional tests for 0.16 std.Io changes
- `CLAUDE.md`: Document Zig 0.16 idioms and updated conventions
- `CHANGELOG.md`: Add 0.16 migration entry
- `CONTRIBUTING.md`: Update Zig version requirement
- `Makefile`: Update build targets for 0.16
- `README.md`: Update Zig version badge and requirements
- `docs/ADR/0002-zig-language-choice.md`: Update Zig version reference
- `docs/ADR/0003-openssl-tls-dependency.md`: Update for 0.16 linking API
- `docs/ADR/0004-opentelemetry-sdk-dependency.md`: Update SDK compatibility notes
- `docs/ADR/0005-amqp-runner-design.md`: Update Zig version reference
- `docs/ADR/0006-redis-runner-design.md`: Update Zig version reference
- `docs/development/building.md`: Update build instructions for 0.16
- `docs/tutorials/getting-started.md`: Update getting started for 0.16
- `.zpm/kb/default/knowledge.pl`: Initialize ZPM default knowledge segment
- `.zpm/kb/feedback/knowledge.pl`: Initialize ZPM feedback rules segment
- `.zpm/kb/migration_zig016/knowledge.pl`: Add ZPM migration tracking segment
- `.zpm/kb/pr_feature_f024_zig_0152_0160_migration/knowledge.pl`: Add PR tracking segment
- `.zpm/mounts.json`: Configure ZPM memory segment mounts

Closes #48
@pocky pocky marked this pull request as ready for review May 26, 2026 21:30
@pocky pocky merged commit 7ec4343 into main May 26, 2026
6 checks passed
@pocky pocky deleted the feature/F024-zig-0152--0160-migration branch May 26, 2026 22:37
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.

F024: Zig 0.15.2 → 0.16.0 Migration

1 participant