Skip to content

Commit cc38b06

Browse files
hyperpolymathclaude
andcommitted
feat(pkg): promote verisim-modular-experiment to shippable Julia package
- Project.toml: add name="Verisim", uuid, version="0.1.0", authors, [extras]/[targets] for Test, [compat] julia="1.10" - src/Verisim.jl: package entry point (module Verisim); __init__ loads all impl modules into Main in dependency order, preserving existing Main.X cross-references without modifying any impl file; thin delegator functions expose the full VCL + VerisimCore public API - test/runtests.jl: Pkg.test() entry point; package-API smoke test (using Verisim, prove ProofIntegrity, parse_vcl round-trip) plus all existing impl-level test suites - justfile: test, test-file, demo, repl, check recipes The flat-include scaffold (Main.X references) is preserved intentionally for the research prototype phase. Phase 6 will migrate each module to src/ with proper relative imports. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7bfd6d6 commit cc38b06

4 files changed

Lines changed: 218 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
name = "Verisim"
2+
uuid = "d7869902-4796-4fb1-b062-064d07af1eff"
3+
version = "0.1.0"
4+
authors = ["Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>"]
5+
16
[deps]
27
AcceleratorGate = "59f742c7-270d-4a76-95d4-a853ae16cc71"
38
KnotTheory = "215268c9-7579-426e-8b7c-a3dc27acd339"
49
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
510
Sodium = "4f5b5e99-b0ad-42cd-b47a-334e172ec8bd"
11+
12+
[extras]
613
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
14+
15+
[targets]
16+
test = ["Test"]
17+
18+
[compat]
19+
julia = "1.10"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# justfile — Verisim research prototype build/test recipes
3+
4+
# Run the full test suite via Pkg.test()
5+
test:
6+
julia --project=. -e 'using Pkg; Pkg.test()'
7+
8+
# Run a single test file standalone (flat-include scaffold)
9+
test-file FILE:
10+
julia --project=. test/{{FILE}}
11+
12+
# Run the KRLAdapter dogfood demo
13+
demo:
14+
julia --project=. examples/krladapter_integration.jl
15+
16+
# Drop into an interactive session with the package pre-loaded
17+
repl:
18+
julia --project=. -e 'using Verisim; import KnotTheory'
19+
20+
# Check package integrity
21+
check:
22+
julia --project=. -e 'using Pkg; Pkg.instantiate(); Pkg.resolve(); Pkg.status()'
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+
Verisim
5+
6+
Julia package wrapper for the VeriSim identity-core research prototype.
7+
8+
Exports the full VCL proof API (prove, parse_vcl), the VerisimCore store
9+
(enrich!, get_core, Store, Manager), and the tropical geometry types
10+
(Tropical, TropicalMatrix, TangleGraph).
11+
12+
# Design note — flat-include scaffold preserved
13+
The implementation lives in `impl/` as a set of independent modules that
14+
cross-reference each other via `Main.X` (the "flat-include scaffold" pattern).
15+
On package load, `__init__` injects each module into `Main` in dependency
16+
order, preserving all `Main.X` references without modifying any impl file.
17+
18+
This is intentional for the research prototype phase. A future
19+
`Verisim v0.2` refactor will move each impl module into `src/` with proper
20+
relative imports (`using ..Sibling`), removing the `Main` injection.
21+
See `PLAN.adoc §Phase-6-Package-Refactor`.
22+
23+
# Usage
24+
```julia
25+
using Verisim
26+
27+
store = Verisim.Store()
28+
manager = Verisim.Manager()
29+
id = Verisim.OctadId(fill(0x01, 16))
30+
blob = Verisim.SemanticBlob(["http://example.org/Doc"], b"hello")
31+
32+
Verisim.enrich!(store, id, :semantic, blob, "alice")
33+
34+
v = Verisim.prove(Verisim.ProofIntegrity(id), store, manager)
35+
println(v) # VerdictPass(...)
36+
```
37+
"""
38+
module Verisim
39+
40+
# -----------------------------------------------------------------------
41+
# Impl load order — must match the manual include order in test files and
42+
# examples. Each file defines its own module which __init__ injects into
43+
# Main so that all existing Main.X cross-references continue to work.
44+
# -----------------------------------------------------------------------
45+
46+
const _IMPL = joinpath(@__DIR__, "..", "impl")
47+
48+
const _IMPL_FILES = [
49+
joinpath(_IMPL, "Crypto.jl"),
50+
joinpath(_IMPL, "drift", "Metrics.jl"),
51+
joinpath(_IMPL, "VerisimCore.jl"),
52+
joinpath(_IMPL, "peers", "VectorPeer.jl"),
53+
joinpath(_IMPL, "FederationManager.jl"),
54+
joinpath(_IMPL, "tropical", "TropicalMatrix.jl"),
55+
joinpath(_IMPL, "tropical", "TangleGraph.jl"),
56+
joinpath(_IMPL, "tropical", "TropicalDeterminant.jl"),
57+
joinpath(_IMPL, "vcl", "Query.jl"),
58+
joinpath(_IMPL, "vcl", "Prover.jl"),
59+
joinpath(_IMPL, "vcl", "Parser.jl"),
60+
]
61+
62+
"""
63+
__init__()
64+
65+
Load all impl modules into `Main` in dependency order. Called automatically
66+
by Julia when `using Verisim` is evaluated.
67+
"""
68+
function __init__()
69+
for f in _IMPL_FILES
70+
# Base.include(Main, f) loads the file in the Main module context,
71+
# making each defined module accessible as Main.<ModuleName>.
72+
Base.include(Main, f)
73+
end
74+
end
75+
76+
# -----------------------------------------------------------------------
77+
# Public API — thin delegators to the Main-level modules loaded by __init__
78+
# -----------------------------------------------------------------------
79+
#
80+
# Struct types cannot be forwarded by reference at precompile time, so we
81+
# expose factory functions and let users call the Main-level types directly
82+
# when they need the actual types (e.g. for dispatch / isa checks).
83+
# All functions are dispatched at call time via Main.<Module> to avoid
84+
# precompile-time binding issues.
85+
86+
export prove, parse_vcl
87+
export Store, Manager, OctadId, SemanticBlob
88+
export enrich!, get_core
89+
export ProofIntegrity, ProofConsistency, ProofFreshness, ProofConsonance,
90+
ProofOptimalAssignment
91+
export VerdictPass, VerdictFail
92+
export Tropical, TROP_ZERO, TROP_ONE, trop_add, trop_mul, bellman_ford_matrix
93+
94+
# VCL proof evaluation
95+
prove(args...; kw...) = Main.VCLProver.prove(args...; kw...)
96+
parse_vcl(s::AbstractString) = Main.VCLParser.parse_vcl(s)
97+
98+
# Store lifecycle
99+
Store() = Main.VerisimCore.Store()
100+
Manager() = Main.FederationManager.Manager()
101+
OctadId(b) = Main.VerisimCore.OctadId(b)
102+
SemanticBlob(types, bytes) = Main.VerisimCore.SemanticBlob(types, bytes)
103+
enrich!(args...) = Main.VerisimCore.enrich!(args...)
104+
get_core(args...) = Main.VerisimCore.get_core(args...)
105+
106+
# VCL clause constructors
107+
ProofIntegrity(id) = Main.VCLQuery.ProofIntegrity(id)
108+
ProofConsistency(args...) = Main.VCLQuery.ProofConsistency(args...)
109+
ProofFreshness(id, window) = Main.VCLQuery.ProofFreshness(id, window)
110+
ProofConsonance(args...) = Main.VCLQuery.ProofConsonance(args...)
111+
ProofOptimalAssignment(id, n, b) = Main.VCLQuery.ProofOptimalAssignment(id, n, b)
112+
113+
# Tropical types
114+
Tropical(x) = Main.TropicalMatrix.Tropical(x)
115+
TROP_ZERO() = Main.TropicalMatrix.TROP_ZERO
116+
TROP_ONE() = Main.TropicalMatrix.TROP_ONE
117+
trop_add(a, b) = Main.TropicalMatrix.trop_add(a, b)
118+
trop_mul(a, b) = Main.TropicalMatrix.trop_mul(a, b)
119+
bellman_ford_matrix(A) = Main.TropicalMatrix.bellman_ford_matrix(A)
120+
121+
end # module Verisim
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
#
3+
# test/runtests.jl — Pkg.test() entry point for the Verisim package.
4+
#
5+
# Architecture note:
6+
# Each included test file self-loads the impl modules it needs via
7+
# `include(...)`, which is the "flat-include scaffold" convention used
8+
# throughout this research prototype. Running files in sequence causes
9+
# Julia to replace modules on each re-include (a WARNING, not an error);
10+
# this is acceptable here because each @testset creates fresh stores and
11+
# types from the just-loaded module instances.
12+
#
13+
# One additional top-level @testset exercises the package API
14+
# (`using Verisim`) before the individual suites run, verifying that
15+
# src/Verisim.jl loads cleanly and delegates correctly.
16+
17+
using Test
18+
19+
# -----------------------------------------------------------------------
20+
# Package smoke test — must pass before any impl-level tests
21+
# -----------------------------------------------------------------------
22+
23+
@testset "Verisim package API (src/Verisim.jl)" begin
24+
using Verisim
25+
import KnotTheory # needed by TangleGraph at Main level
26+
27+
@testset "package loads and __init__ populates Main" begin
28+
@test isdefined(Main, :VerisimCore)
29+
@test isdefined(Main, :VCLProver)
30+
@test isdefined(Main, :TropicalMatrix)
31+
@test isdefined(Main, :TangleGraph)
32+
end
33+
34+
@testset "prove(ProofIntegrity) via package API" begin
35+
store = Verisim.Store()
36+
manager = Verisim.Manager()
37+
id = Verisim.OctadId(fill(0x42, 16))
38+
blob = Verisim.SemanticBlob(["http://verisim.pkg.test/#smoke"], b"smoke")
39+
40+
Verisim.enrich!(store, id, :semantic, blob, "pkg-test")
41+
42+
v = Verisim.prove(Verisim.ProofIntegrity(id), store, manager)
43+
@test v isa Main.VCLQuery.VerdictPass
44+
end
45+
46+
@testset "parse_vcl round-trip via package API" begin
47+
q = Verisim.parse_vcl("PROOF INTEGRITY FOR " * "ab" ^ 16)
48+
@test q isa Main.VCLQuery.ProofIntegrity
49+
end
50+
end
51+
52+
# -----------------------------------------------------------------------
53+
# Impl-level test suites (each self-loads its own subset of impl modules)
54+
# -----------------------------------------------------------------------
55+
# Module replacement warnings are expected and harmless here.
56+
57+
@testset "VerisimCore" begin include("test_verisim_core.jl") end
58+
@testset "Federation parity" begin include("test_federation_parity.jl") end
59+
@testset "Non-interference" begin include("test_noninterference.jl") end
60+
@testset "Seams" begin include("test_seams.jl") end
61+
@testset "KRLAdapter integration" begin include("test_krladapter_integration.jl") end
62+
@testset "VCL" begin include("test_vcl.jl") end

0 commit comments

Comments
 (0)