Skip to content

Commit a5794d2

Browse files
hyperpolymathclaude
andcommitted
fix: SPDX header positioning, remove 4 remaining silent catches
- Move SPDX headers to line 1 in 11 files (was buried in comment blocks) - Remove duplicate SPDX block in reextract.zig - Fix 4 remaining catch {} blocks: prefetch ring submit, dragonfly socket timeouts, stages write — all now log errors - All @ptrCast/@aligncast already have // SAFETY: comments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 45d261f commit a5794d2

12 files changed

Lines changed: 40 additions & 43 deletions

ffi/zig/src/cache.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl Cache — LMDB-Backed Result Cache
24
//
35
// Stores parsed document results keyed by file path. On cache hit
@@ -17,9 +19,6 @@
1719
//
1820
// Each Chapel locale should have its own LMDB environment to avoid
1921
// cross-locale write locking. Reads are fully concurrent.
20-
//
21-
// SPDX-License-Identifier: PMPL-1.0-or-later
22-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
2322

2423
const std = @import("std");
2524

ffi/zig/src/capnp.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl — Minimal Cap'n Proto Single-Segment Message Builder
24
//
35
// Produces valid Cap'n Proto binary messages readable by any standard decoder.
46
// Single-segment only (sufficient for per-document stage results).
57
// No external dependencies — pure Zig implementation of the wire format.
68
//
79
// Wire format reference: https://capnproto.org/encoding.html
8-
//
9-
// SPDX-License-Identifier: PMPL-1.0-or-later
10-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
1110

1211
const std = @import("std");
1312

ffi/zig/src/conduit.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl — Preprocessing Conduit
24
//
35
// Lightweight pre-processing pipeline that runs before the main Chapel parse.
@@ -11,9 +13,6 @@
1113
// Chapel calls ddac_conduit_process() on a batch of paths. The conduit
1214
// returns an array of ConduitResult structs that the main loop uses to
1315
// skip invalid files and pre-populate cache keys.
14-
//
15-
// SPDX-License-Identifier: PMPL-1.0-or-later
16-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
1716

1817
const std = @import("std");
1918

ffi/zig/src/docudactyl_ffi.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl FFI — Unified Multi-Format Parser Dispatcher
24
//
35
// Thin Zig wrapper around C libraries for HPC document processing.
@@ -11,9 +13,6 @@
1113
// - libxml2 (EPUB/XHTML parsing)
1214
// - libgdal (geospatial: shapefiles, GeoTIFF)
1315
// - libvips (image dimensions/metadata)
14-
//
15-
// SPDX-License-Identifier: PMPL-1.0-or-later
16-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
1716

1817
const std = @import("std");
1918
const stages = @import("stages.zig");

ffi/zig/src/dragonfly.zig

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl — Dragonfly / Redis RESP Client (L2 Cache)
24
//
35
// Minimal RESP2 client for Dragonfly (Redis-compatible) cross-locale cache.
@@ -10,9 +12,6 @@
1012
// - 25x throughput on same hardware
1113
// - Multi-threaded (no single-thread bottleneck)
1214
// - Compatible with RESP2 protocol
13-
//
14-
// SPDX-License-Identifier: PMPL-1.0-or-later
15-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
1615

1716
const std = @import("std");
1817

@@ -41,9 +40,15 @@ pub const DragonflyClient = struct {
4140
const addr = std.net.Address.parseIp4(host, port) catch return null;
4241
const stream = std.net.tcpConnectToAddress(addr) catch return null;
4342

44-
// Set a reasonable timeout (5 seconds)
45-
stream.handle.setReadTimeout(5_000_000_000) catch {};
46-
stream.handle.setWriteTimeout(5_000_000_000) catch {};
43+
// Set a reasonable timeout (5 seconds). Failure to set timeouts is
44+
// non-fatal — operations will block indefinitely on network stalls,
45+
// but the connection itself is still usable.
46+
stream.handle.setReadTimeout(5_000_000_000) catch |err| {
47+
std.log.debug("Dragonfly: failed to set read timeout: {s}", .{@errorName(err)});
48+
};
49+
stream.handle.setWriteTimeout(5_000_000_000) catch |err| {
50+
std.log.debug("Dragonfly: failed to set write timeout: {s}", .{@errorName(err)});
51+
};
4752

4853
return .{
4954
.stream = stream,

ffi/zig/src/gpu_ocr.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl — GPU-Accelerated OCR Coprocessor
24
//
35
// Batched OCR using GPU acceleration when available:
@@ -16,9 +18,6 @@
1618
// and collects results via ddac_gpu_ocr_collect(). The coprocessor maintains
1719
// an internal queue and flushes batches to the GPU when full or on explicit
1820
// flush.
19-
//
20-
// SPDX-License-Identifier: PMPL-1.0-or-later
21-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
2221

2322
const std = @import("std");
2423

ffi/zig/src/hw_crypto.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl — Hardware Crypto Acceleration
24
//
35
// Detects and leverages hardware SHA-256 instructions for maximum throughput
@@ -14,9 +16,6 @@
1416
// - Multi-buffer SHA-256 for batch operations (4 files at once with AVX2)
1517
// - Runtime capability reporting for Chapel banner
1618
// - Batch digest computation for the conduit pipeline
17-
//
18-
// SPDX-License-Identifier: PMPL-1.0-or-later
19-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
2019

2120
const std = @import("std");
2221

ffi/zig/src/lith_adapter.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
// Docudactyl → Lithoglyph Ingest Adapter
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
// Docudactyl — Lithoglyph Ingest Adapter
24
//
35
// Reads a Cap'n Proto StageResults message buffer and converts it to a JSON
46
// evidence record compatible with Lithoglyph's bofig_evidence schema.
57
//
68
// The adapter extracts fields from the Cap'n Proto binary layout defined in
79
// capnp.zig, maps them to Lithoglyph schema fields, and computes auto-PROMPT
810
// epistemological scores from extraction metadata.
9-
//
10-
// SPDX-License-Identifier: PMPL-1.0-or-later
11-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
1211

1312
const std = @import("std");
1413
const capnp = @import("capnp.zig");

ffi/zig/src/ml_inference.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl — ML Inference Engine (ONNX Runtime)
24
//
35
// Unified ML inference backend for all ML-dependent processing stages:
@@ -19,9 +21,6 @@
1921
// use (lazy loading) and caches the ONNX session for subsequent calls.
2022
//
2123
// Model paths are configured via ddac_ml_set_model_dir().
22-
//
23-
// SPDX-License-Identifier: PMPL-1.0-or-later
24-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
2524

2625
const std = @import("std");
2726

ffi/zig/src/prefetch.zig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
13
// Docudactyl — I/O Prefetcher (Linux io_uring + fadvise)
24
//
35
// Addresses Wall 2 (I/O bandwidth) by prefetching upcoming documents
@@ -10,9 +12,6 @@
1012
// The prefetcher manages a sliding window of N upcoming files.
1113
// Chapel tasks call ddac_prefetch_hint() before processing each document
1214
// to keep the pipeline full.
13-
//
14-
// SPDX-License-Identifier: PMPL-1.0-or-later
15-
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
1615

1716
const std = @import("std");
1817
const builtin = @import("builtin");
@@ -182,8 +181,11 @@ fn prefetchWithUring(state: *PrefetchState, fd: std.posix.fd_t) void {
182181
sqe.prep_fadvise(fd, 0, @intCast(READAHEAD_SIZE), 3); // POSIX_FADV_WILLNEED
183182
sqe.user_data = @intCast(fd);
184183

185-
// Submit without waiting
186-
_ = ring_state.ring.submit() catch {};
184+
// Submit without waiting — failure is non-fatal; the file will still
185+
// be read synchronously when the parser reaches it.
186+
_ = ring_state.ring.submit() catch |err| {
187+
std.log.debug("io_uring prefetch submit failed: {s}", .{@errorName(err)});
188+
};
187189
}
188190
}
189191

0 commit comments

Comments
 (0)