Skip to content

Commit 320df2d

Browse files
hyperpolymathclaude
andcommitted
feat: drive NQC through Phase 1-4 — tests, spec, ABI/FFI, polish
Phase 1 — 128 unit tests across database, formatter, client, and main module. Promoted key utility functions to pub for testability. Phase 2 — EBNF grammar (spec/grammar.ebnf) covering meta-commands, protocol wire format, CLI arguments, and output formatting. Formal specification (spec/SPEC.core.scm) defining type system, protocol invariants, registry semantics, and correctness guarantees. 19 conformance tests verifying spec invariants. Phase 3 — Idris2 ABI with dependent type proofs for ports, non-empty strings, URL paths, format roundtrip, and memory layout alignment. Zig FFI (32 tests) implementing CSV escape, semicolon stripping, URL construction, query body building, and status classification. Phase 4 — Custom profile JSON loading from nqc-profiles.json. Persistent query history (~/.nqc_history) with search. In-memory LRU query cache with mutation bypass. ANSI keyword highlighting. New meta-commands: \history, \search, \clearcache. 43 additional tests. Total: 190 Gleam + 32 Zig = 222 tests, all passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0c18c24 commit 320df2d

29 files changed

+4125
-92
lines changed

nqc/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
*.ez
33
/build
44
erl_crash.dump
5+
6+
# Zig build artifacts
7+
ffi/zig/.zig-cache/
8+
ffi/zig/zig-out/

nqc/ffi/zig/build.zig

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
//
4+
// build.zig — Build configuration for the NQC Zig FFI library (Zig 0.15.2).
5+
6+
const std = @import("std");
7+
8+
pub fn build(b: *std.Build) void {
9+
const target = b.standardTargetOptions(.{});
10+
const optimize = b.standardOptimizeOption(.{});
11+
12+
// --- Library module for import ---
13+
const nqc_mod = b.addModule("nqc_ffi", .{
14+
.root_source_file = b.path("src/main.zig"),
15+
.target = target,
16+
.optimize = optimize,
17+
});
18+
19+
// --- Unit tests ---
20+
const unit_test_mod = b.createModule(.{
21+
.root_source_file = b.path("src/main.zig"),
22+
.target = target,
23+
.optimize = optimize,
24+
});
25+
const unit_tests = b.addTest(.{
26+
.root_module = unit_test_mod,
27+
});
28+
const run_unit_tests = b.addRunArtifact(unit_tests);
29+
30+
// --- Integration tests ---
31+
const integration_test_mod = b.createModule(.{
32+
.root_source_file = b.path("test/integration_test.zig"),
33+
.target = target,
34+
.optimize = optimize,
35+
});
36+
integration_test_mod.addImport("nqc_ffi", nqc_mod);
37+
const integration_tests = b.addTest(.{
38+
.root_module = integration_test_mod,
39+
});
40+
const run_integration_tests = b.addRunArtifact(integration_tests);
41+
42+
// --- Test step ---
43+
const test_step = b.step("test", "Run unit and integration tests");
44+
test_step.dependOn(&run_unit_tests.step);
45+
test_step.dependOn(&run_integration_tests.step);
46+
}

0 commit comments

Comments
 (0)