Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c89aa23
fix: name the file a failed replacement reports
HaoZeke Nov 20, 2026
903847a
fix: record the text of a failed state lock
HaoZeke Nov 20, 2026
31ace8e
feat: add checked stdout writer to cli
HaoZeke Nov 20, 2026
cf90169
fix: compress a long log name the reference compressor allows
HaoZeke Nov 20, 2026
540a354
fix: retain state lock failure details
HaoZeke Nov 20, 2026
2166589
fix: report the failing makedirs ancestor
HaoZeke Nov 20, 2026
675f454
fix: preserve current operating-system errno
HaoZeke Nov 20, 2026
b33ecb0
fix: keep system errors when diagnostics exhaust memory
HaoZeke Nov 20, 2026
9fcd216
ci: run the workflows on develop
HaoZeke Nov 21, 2026
02ccd57
Merge pull request #79 from stackhands/fix/gzip-long-name-overflow-24…
HaoZeke Nov 21, 2026
3119105
Merge pull request #77 from stackhands/feat/cli-checked-stdout
HaoZeke Nov 21, 2026
854326d
ci: run argparse parity suite
HaoZeke Nov 21, 2026
daa2e6f
docs(changelog): backfill 0.10.0, 0.11.0 and 0.12.0 releases
HaoZeke Nov 21, 2026
3245d68
test: trace the renames and directory syncs of moveAcross
HaoZeke Nov 21, 2026
fc63e59
fix: sync nested moveAcross destination parent
HaoZeke Nov 21, 2026
9732e4f
fix: sync the moveAcross source parent beside a nested destination
HaoZeke Nov 21, 2026
4eae43b
Merge pull request #70 from stackhands/ci/argparse-parity
HaoZeke Nov 21, 2026
fac40d9
Merge pull request #83 from stackhands/chore/changelog-backfill-0.10-…
HaoZeke Nov 21, 2026
33ac564
Merge pull request #59 from stackhands/fix/moveacross-nested-target-p…
HaoZeke Nov 22, 2026
47592e5
Merge pull request #75 from stackhands/fix/oserror-text-atomic-and-lock
HaoZeke Nov 24, 2026
5d6746b
test: match OSError text for atomic writes and state locks
HaoZeke Nov 24, 2026
fa7fb4c
fix: keep the reported errno across replacement cleanup
HaoZeke Nov 24, 2026
b077a78
docs: describe the lifetime of a state-lock OSError
HaoZeke Nov 24, 2026
faa99e2
fix: describe a blocking record lock's real errno
HaoZeke Nov 24, 2026
3e17752
Merge pull request #84 from stackhands/fix/zc75-fix-forward
HaoZeke Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ jobs:
fi
zig build tempdir-probe
python3 tests/test_gettempdir_parity.py
- name: parity with python 3.14 argparse calls
run: |
python3 -c "import sys; assert sys.version_info >= (3, 14), 'argparse parity needs Python 3.14+; found ' + sys.version.split()[0]"
zig build argparse-parity-probe
python3 tests/test_argparse_parity.py
- name: no site names in the tree
run: |
! git grep -nIiE 'snellius|surf\.nl|/gpfs/|/projects/0|rg\.terra|scratch-shared' -- . ':!.github/workflows/ci.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: docs

on:
push:
branches: [main]
branches: [main, develop]
pull_request:
workflow_dispatch:
schedule:
Expand Down
76 changes: 76 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,82 @@

<!-- towncrier release notes start -->

## 0.12.0 (2026-11-19)

### Features

- `syslog`: `Identity` names the program and the structured-data identifier of an event; `formatRfc5424For`, `formatJournaldFor` and `emitFor` take one, and `send` delivers an already formatted payload, for a tool with formatting of its own. The functions without an identity keep writing `eb-keep-logs`, as 0.11.0 did, and are removed in 0.13.0.

### Miscellaneous

- Prepare `zig-common` `0.12.0` in `COMPAT.md` for callers adopting `syslog.Identity` and `syslog.send`.


## 0.11.0 (2026-11-19)

### Features

- Add `pytext.osError` and `pytext.osErrorErrno` for Python-formatted `OSError` path messages.
- Add `pytext.reprStr` and `pytext.reprStrAlloc` for Python-compatible surrogateescape string quoting.
- Add `state.lockExclusiveCancel` supporting atomic cancellation while polling `flock`.
- Add `sys.strerror` returning `errnoText(e)` or the enum tag name fallback.
- `json.writeCacheStringTo` writes cache-style JSON strings to a writer without allocation.
- `proc.resolveExecutable` resolves executable names to absolute executable regular-file paths from slash paths or PATH lookup with a null-PATH default of `/bin:/usr/bin`.
- `proc.whichShutil` adds an opt-in executable lookup mode that matches POSIX `shutil.which` behavior.
- `syslog`: the RFC 5424 and systemd-journald event emitter that eb-keep-logs and eessi-arch-guard each carried a copy of: `Target`, `parseTarget`, `parsePen`, `formatRfc5424`, `formatJournald` and `emit`.

### Fixes

- Decode UTF-8 keys, UTF-16 surrogate pairs, and surrogateescape cache bytes in `json.Value.get` so escaped non-ASCII keys match like `json.loads`.
- Fix `sys.strerror` to avoid panicking on unnamed `linux.E` values by using `std.enums.tagName` with an `"Unknown error N"` fallback.
- `fsx.appendLine` reports `not a regular file` for an existing non-regular target such as a FIFO.
- `fsx.moveAcross` reports `error.NotRegularFile` when EXDEV fallback copies a tree entry that none of the earlier copy branches handle.
- `fsx.moveAcross` reports `not a regular file` for a FIFO source that takes the EXDEV copy fallback.
- `fsx.openRegular` now reports `error.NotRegularFile` for FIFOs, sockets, and device nodes, and `sys.describe` renders that as `not a regular file` instead of `[Errno 22] Invalid argument`.
- `fsx.openRegular` now returns `error.IsDir` for directory paths, so `sys.describe` reports `[Errno 21] Is a directory` instead of `[Errno 22] Invalid argument` for that case.

### Documentation

- List every public function and error set including PR #24 shared helpers in `docs/orgmode/reference/api.org`.

### Miscellaneous

- Add `atomic.Ops` fault hooks and unit tests covering `atomicWrite` failures on `ENOSPC`, `EROFS`, and `EXDEV`, as well as `makedirs` and `fsyncDir` error paths.
- Add unit tests covering `gzipInPlace` error paths (missing file, directory, symlink, hard link, and existing `.gz` archive) in `src/logs.zig`.
- Add unit tests covering `sys.errnoText` for unknown errno values and error paths for `sys` syscall wrappers.
- Add unit tests covering error and boundary paths for `which`, `groupAlive`, `killGroup`, `stopGroup`, and `run` in `src/proc.zig`.
- Add unit tests covering error paths for public file and directory helpers in `src/fsx.zig`.
- Add unit tests verifying `cli.put` and `cli.print` ignore descriptor write errors and checking `cli.versionLine` formatting.
- Prepare `zig-common` `0.11.0` in `COMPAT.md` for callers adopting `syslog`. A release is now `cog bump` on a release branch: `cog.toml` sets the version in `build.zig.zon` and refuses a version without a `COMPAT.md` row.
- Proc resolver tests share one executable fixture helper for scratch script and plain file setup.
- Route `lockExclusiveCancel` through `state.lock_ops.flock` and add unit tests covering `lockExclusive` with timeout 0, bounded timeout, unsupported `flock`, and private state file error paths.
- The private `proc.isExecutableFile` helper holds the executable regular-file probe that `proc.which` runs for each PATH candidate.
- `json.writeWireString` writes each string through one writer and the shared escape code.
- `proc.resolveExecutable` tests cover relative slash paths for executable and non-executable files.
- `proc.which` tests cover executable resolution and null returns for non-executable candidates.
- `proc.which` uses one internal options-driven search loop for executable path matching.
- `proc` test fixtures clean up scratch directories when setup fails after partial creation.


## 0.10.0 (2026-11-18)

### Features

- Add `fsx.mkdtemp` to create a private `0700` directory with a random suffix under a given parent directory and retry on name collisions.
- Add `fsx.normPath` and `fsx.absPath` to normalize and absolutize POSIX paths without following symbolic links.
- `fsx.moveAcross` adds a durable cross-filesystem move primitive: it tries `rename` first, falls back on EXDEV to a destination-side temporary copy, publishes with an atomic rename, and removes the source only after publish. The new `fsx.MoveAcrossOptions` policy is opt-in, with `strict` for ACL-preserving copies and `portable` for ACL downgrade when destination filesystems do not represent the source ACL form.

### Documentation

- Every `pub` declaration has a doc comment, whose first sentence is the summary the API pages list.
- The documentation site is built from Org pages in `docs/orgmode/` with Sphinx, in four parts: the tutorial "Write a small tool on zig-common", how-to guides, explanation and reference. Each module's API page is generated from its doc comments, and the site publishes an `objects.inv` of every `pub` declaration for the tools' sites to link into. `pixi run -e docs docbld` builds it as CI does and fails on a warning, an unresolved name or a dead internal link; `pixi run -e docs linkcheck` checks the external links. The `docs` workflow publishes the site to GitHub Pages; `docs/requirements.txt` and `pages.yml` are gone.
- The site has how-to guides for replacing a file and keeping its access control lists, keeping private state in `/tmp`, compressing logs that `.licensed-logs` marks, matching a Python tool's output and upgrading zig-common; explanations of process groups and deadlines, system calls without a C library, and Python compatibility; and a reference of the messages, exit statuses and version line that `cli` gives the tools.

### Miscellaneous

- Prepare `zig-common` `0.10.0` in `build.zig.zon` and `COMPAT.md` for callers adopting `fsx.mkdtemp` plus `fsx.normPath` and `fsx.absPath`.


## 0.9.0 (2026-11-16)

### Features
Expand Down
1 change: 0 additions & 1 deletion changelog.d/+append-line-fifo-text.bugfix.md

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+atomic-oserror-oom.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep the original operating-system error when allocation fails while formatting its atomic-write diagnostic.
1 change: 0 additions & 1 deletion changelog.d/+atomic-write-error-tests.misc.md

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+atomic-write-oserror-text.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A failed replacement names the temporary file when the open fails, names both files when the rename fails, and names no file when the write or the flush fails.
1 change: 1 addition & 0 deletions changelog.d/+ci-argparse-parity.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The CI runs the argparse parity suite under Python 3.14 next to the JSON, filesystem and `tempfile.gettempdir` suites, guarded by a Python 3.14+ version check.
1 change: 1 addition & 0 deletions changelog.d/+cli-checked-stdout.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `cli.Stdout` and `cli.writeOut` for checked standard-output writes that report the first write error on standard error and turn a zero exit status into `1`.
1 change: 0 additions & 1 deletion changelog.d/+cli-write-errors-test.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+doc-comments.doc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+docs-pages.doc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+docs-site.doc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+fsx-error-paths-test.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+fsx-mkdtemp.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+fsx-normpath.feature.md

This file was deleted.

7 changes: 7 additions & 0 deletions changelog.d/+gzip-long-name-tmp-overflow.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`gzipInPlace` refused to compress a log whose name, well within the
reference compressor's own limit, no longer fit a filesystem's 255-byte
limit on one path component once its temporary file's pid and random
suffix were added on. That suffix alone already makes the temporary
name unique, so the original name is left off a temporary name that
would otherwise overflow, and a name that reference tool would have
compressed compresses here too.
1 change: 0 additions & 1 deletion changelog.d/+json-value-get-utf8.bugfix.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+json-write-cache-string-to.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+json-write-wire-shared-writer.misc.md

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+lock-acquire-filename.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A failed lock acquisition records the OSError text and whether Python names .lock, .lock.posix, the state directory, or no file.
1 change: 0 additions & 1 deletion changelog.d/+logs-error-tests.misc.md

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+makedirs-failed-ancestor.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Report the ancestor that actually failed when recursive state-root or atomic-write directory creation stops.
1 change: 0 additions & 1 deletion changelog.d/+move-across-fifo-source-text.bugfix.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+move-across.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+move-tree-special-entry-diagnostic.bugfix.md

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+moveacross-call-trace.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`fsx` unit tests trace the renames and directory syncs that `moveAcross` makes.
1 change: 1 addition & 0 deletions changelog.d/+moveacross-nested-target-parent.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`fsx.moveAcross` syncs the destination parent directory for nested targets.
1 change: 1 addition & 0 deletions changelog.d/+moveacross-source-parent.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`fsx.moveAcross` syncs the parent directory of the source name, also when one descriptor holds both names and the destination is nested.
1 change: 0 additions & 1 deletion changelog.d/+open-regular-dir-errno.bugfix.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+open-regular-special-files-text.bugfix.md

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+oserror-errno-lifetime.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reset stale lock errno state and preserve the parent-directory errno after an atomic replacement has been renamed.
1 change: 0 additions & 1 deletion changelog.d/+proc-error-tests.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+proc-executable-file-check.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+proc-executable-fixture-tests.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+proc-fixture-failure-cleanup.misc.md

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+proc-resolve-executable.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+proc-which-direct.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+proc-which-search-options.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+proc-which-shutil.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+pytext-os-error.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+pytext-repr.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+reference-api-pr24.doc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+release-0.10.0.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+release-0.11.0.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+release-0.12.0.misc.md

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+rootlock-preflight-osfailure.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Record the state-root path and error text when lock acquisition rejects a non-directory or broken symbolic link.
1 change: 0 additions & 1 deletion changelog.d/+state-lock-cancel.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+state-lock-exclusive-errors-test.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+sys-errnotext-unknown-test.misc.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+sys-strerror-unknown-panic.bugfix.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+sys-strerror.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+syslog-identity-and-send.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/+syslog.feature.md

This file was deleted.

17 changes: 6 additions & 11 deletions docs/orgmode/howto/replace-a-file-keeping-its-acls.org
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,19 @@ A reader sees the old file or the new one, never a part of either, and never the

The steps that follow use =atomicWrite=.

2. Call it with a [[zig:zig_common.atomic.Why]], which receives the reason for a refusal, and free that with =deinit=:
2. Call it with a [[zig:zig_common.atomic.Why]], which receives the reason for any failure, and free that with =deinit=:

#+begin_src zig
var why: common.atomic.Why = .{};
defer why.deinit(gpa);
common.atomic.atomicWrite(gpa, path, bytes, .{}, &why) catch |err| switch (err) {
error.Refused => {
common.cli.err("tool: {s}\n", .{why.msg});
return 1;
},
else => |e| {
common.cli.err("tool: {s}: {s}\n", .{ path, common.atomic.describe(e) });
return 1;
},
common.atomic.atomicWrite(gpa, path, bytes, .{}, &why) catch |err| {
const message = if (why.msg.len > 0) why.msg else common.atomic.describe(err);
common.cli.err("tool: {s}\n", .{message});
return 1;
};
#+end_src

[[zig:zig_common.atomic.describe]] words any other error as Python's =OSError= does, such as =[Errno 28] No space left on device=.
=why.msg= includes the filename or filenames of an operating-system error. If a failure happened before it could be filled, [[zig:zig_common.atomic.describe]] supplies text such as =[Errno 12] Cannot allocate memory=.

3. To give the new file the access of another file, such as a file prepared beside the live one it is to replace, name that file in [[zig:zig_common.atomic.WriteOptions]]:

Expand Down
4 changes: 4 additions & 0 deletions docs/orgmode/reference/api.org
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ Error set: [[zig:zig_common.logs.GzipError]].

| Function | Error set |
|----------------------------------------+-----------|
| [[zig:zig_common.cli.Stdout.write]] | none |
| [[zig:zig_common.cli.Stdout.print]] | none |
| [[zig:zig_common.cli.Stdout.finish]] | none |
| [[zig:zig_common.cli.put]] | none |
| [[zig:zig_common.cli.print]] | none |
| [[zig:zig_common.cli.out]] | none |
| [[zig:zig_common.cli.writeOut]] | none |
| [[zig:zig_common.cli.err]] | none |
| [[zig:zig_common.cli.die]] | none |
| [[zig:zig_common.cli.versionLine]] | none |
Expand Down
Loading
Loading