feature/sentinel-ptr-type #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/sentinel-ptr-type"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Deliverables:
Two bugs in the `janus cid` computeSource path (Gap 6, P1 — documented as FIXED in COMPILER_GAPS.md for this session): 1. The defer ran too early. `if (source_owned) { defer free(...); }` scopes the defer to the inner block, so the memory was freed before the computeSource / toString calls that use it — segfault on any invocation that read from a file rather than stdin. Fix: `defer if (source_owned) free(...);` keeps the guard but lets the defer run at end of the enclosing scope. 2. On computeSource failure the command returned normally, so the shell saw exit code 0 while stderr said "Error computing CID". Fix: exit with status 1 so pipelines and `set -e` see the failure. Gap 7 (missing parseSource) tracked separately in Janus/.agents/reports/2026-04-24-cid-computesource-missing-parse.md.Adds the fallback dispatch path at the end of the subcommand chain: if the first argument is not a known subcommand but IS a readable regular file, treat the invocation as `janus run <file> <rest>`. This is the path the kernel takes when executing a file with `#!/usr/bin/env janus` as shebang — it feeds us the absolute script path, not `run <path>`. Without this fallback, every shebanged .jans would hit the "Unknown command" branch. Semantics match Unix conventions: - Everything after the script path becomes script args. - No flag consumption in this form. `--verbose` / `--trace` only flow through the explicit `janus run ...` form. - Non-zero exit codes propagate (clamped to u8 range, 1 otherwise). Memory note: pairs with the Tier 1 shebang work shipped earlier today — the tokenizer already skips a leading `#!` line at file start; this closes the dispatch side of the same feature.Lands the completed stdlib OS-layering sprint as one atomic unit. All three phases ship together because the build.zig triple dispatch references source paths that only exist once the std/sys/{linux,openbsd} tree is in the repo — splitting phase-by-phase would leave intermediate commits with dangling build references. Doctrine anchor: Janus/.agents/doctrines/stdlib-os-layering.md Layout changes — bridges collapse into per-triple backends: std/vfs_adapter.zig → std/sys/linux/vfs_adapter.zig std/sys/openbsd/vfs_adapter.zig std/fs_atomic.zig → std/sys/linux/fs_atomic.zig std/fs_temp.zig → std/sys/linux/fs_temp.zig std/temp_fs.zig → std/sys/linux/temp_fs.zig std/os/fs.zig → std/sys/linux/fs.zig std/sys/openbsd/fs.zig std/core/fs_ops.zig → std/sys/linux/fs_ops.zig std/sys/openbsd/fs_ops.zig std/core/time.zig → std/sys/linux/time.zig std/sys/openbsd/time.zig std/bridge/http_bridge.zig → std/sys/linux/http.zig std/sys/openbsd/http.zig std/bridge/process_bridge.zig → std/sys/linux/process.zig std/sys/openbsd/process.zig std/bridge/socket_bridge.zig → std/sys/linux/net.zig std/sys/openbsd/net.zig std/bridge/sbi_daemon.zig → std/sys/linux/sbi_daemon.zig std/ltp/bridge/l0_bridge.zig → collapsed (subsumed by sys layer) std/net/bridge/net_bridge.zig → collapsed (subsumed by sys/*/net.zig) New facade layer (Janus-side, Advancement Loop): std/os/fs.jan — fs facade, routes to std/sys/{triple}/fs.zig std/os/process.jan — process facade + CLI args (Tier 3) std/os/time.jan — time facade, routes to std/sys/{triple}/time.zig build.zig — canonical-triple gate (doctrine §2): * gateCanonicalTriple(target) panics on wasm-wasi (reserved but not implemented), warns on unsupported triples, silent-passes on linux-musl/linux-gnu/openbsd. * dispatchSysModule(triple, name, file) selects the right std/sys/{triple}/{file} source per build, replacing hardcoded per-OS module paths. * sys_random named module — dispatched so @import("sys_random") resolves to the right backend from inside grafted Zig files. * Noise test wires sys_random as a module dep so keys.zig routes entropy through the dispatched source. compiler/qtjir — LLVM-C translate-c migration: * Zig 0.17 removed @cImport. New combined header compiler/qtjir/llvm_c.h is the single translate-c root; build.zig runs b.addTranslateC to produce the llvm_c module. * llvm_bindings.zig replaces the old @cImport block with @import("llvm_c"); other call sites are source-compatible. src/pipeline.zig — named-module dependency resolver: * Scans grafted Zig sources for @import("<name>") and wires -M<name>=<path> + --dep <name> flags so the Zig compile can resolve named modules (noise, sys_random) from inside the graft root without escaping its module boundary. Verified before commit: the work was already tested by the user across Phase 1, Phase 2, and Phase 3 sessions (1 + 2a + 2b + 2c + 2d). Out of scope for this commit, filed separately: * shebang tokenizer (compiler/libjanus/tokenizer.zig) — paired withbfeae80f, follow-up commit. * Gap 6 regression CI check (.forgejo/workflows/ci.yml) — paired withd5242256, follow-up commit.