Skip to content

Commit bfb9fa6

Browse files
hyperpolymathclaude
andcommitted
docs: bespoke architecture, roadmap, topology, and ABI definitions for alloyiser
Replace all template placeholders with alloyiser-specific content. Architecture: API spec → Alloy model extraction and verification engine. Machine-readable files updated with Alloy domain knowledge (SAT solving, counterexample mapping, scope validation, JVM runtime dependency). AI manifest resolved from template to alloyiser-specific. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f541508 commit bfb9fa6

File tree

7 files changed

+115
-62
lines changed

7 files changed

+115
-62
lines changed

.machine_readable/6a2/AGENTIC.a2ml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# SPDX-License-Identifier: PMPL-1.0-or-later
22
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
33
#
4-
# AGENTIC.a2ml — AI agent constraints and capabilities
5-
# Defines what AI agents can and cannot do in this repository.
4+
# AGENTIC.a2ml — AI agent constraints and capabilities for alloyiser
65

76
[metadata]
87
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
8+
last-updated = "2026-03-21"
109

1110
[agent-permissions]
1211
can-edit-source = true
@@ -22,6 +21,18 @@ can-create-files = true
2221
# - Never use banned languages (TypeScript, Python, Go, etc.)
2322
# - Never place state files in repository root (must be in .machine_readable/)
2423
# - Never use AGPL license (use PMPL-1.0-or-later)
24+
# - Never generate invalid Alloy syntax in .als templates
25+
# - Never hardcode Alloy JAR paths (must come from alloyiser.toml or environment)
26+
# - Never skip counterexample mapping (raw Alloy atoms are not user-facing)
27+
28+
[domain-knowledge]
29+
# Alloy-specific context for AI agents:
30+
# - Alloy uses relational logic, not first-order logic
31+
# - `sig` = entity type, `field` = relation, `fact` = invariant
32+
# - `check` runs SAT solver to find counterexamples to assertions
33+
# - `run` generates satisfying instances (for visualisation)
34+
# - Scope bounds: Alloy checks all states up to N instances per sig
35+
# - Kodkod translates Alloy constraints to SAT; SAT4J solves them
2536

2637
[maintenance-integrity]
2738
fail-closed = true

.machine_readable/6a2/ECOSYSTEM.a2ml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
(version "0.1.0")
77
(name "alloyiser")
88
(type "tool")
9-
(purpose "Extract formal models from API specs and verify with Alloy")
9+
(purpose "Extract formal models from API specifications (OpenAPI, GraphQL, gRPC) and verify invariants using the Alloy Analyzer's SAT solver")
1010

1111
(position-in-ecosystem
1212
(family "-iser acceleration frameworks")
1313
(meta-framework "iseriser")
1414
(relationship "sibling")
15+
(domain "formal verification of API designs")
16+
(unique-value "bridges API specification formats to Alloy's relational logic — finds design bugs before implementation")
1517
(top-3 ("typedqliser" "chapeliser" "verisimiser")))
1618

1719
(related-projects
@@ -32,7 +34,23 @@
3234
(description "Database recovery via constraint propagation"))
3335
(project "proven"
3436
(relationship "dependency")
35-
(description "Shared Idris2 verified library"))
37+
(description "Shared Idris2 verified library — alloyiser uses proven types for model soundness proofs"))
3638
(project "typell"
3739
(relationship "dependency")
38-
(description "Type theory engine"))))
40+
(description "Type theory engine — could power alloyiser's constraint language"))
41+
(project "boj-server"
42+
(relationship "integration-target")
43+
(description "BoJ MCP server — alloyiser will be a cartridge for on-demand spec verification"))
44+
(project "panll"
45+
(relationship "integration-target")
46+
(description "PanLL workspace — alloyiser will provide a panel for visualising Alloy instance graphs")))
47+
48+
(external-dependencies
49+
(dependency "alloy6"
50+
(type "runtime")
51+
(description "MIT Alloy 6 Analyzer JAR — SAT solving via Kodkod/SAT4J")
52+
(url "https://alloytools.org"))
53+
(dependency "openapiv3"
54+
(type "build")
55+
(description "Rust crate for parsing OpenAPI 3.x specifications")
56+
(url "https://crates.io/crates/openapiv3"))))

.machine_readable/6a2/META.a2ml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,53 @@
44

55
(meta
66
(version "0.1.0")
7-
(last-updated "2026-03-20")
7+
(last-updated "2026-03-21")
88

99
(architecture-decisions
10-
(adr "001-iser-pattern"
10+
(adr "001-alloy-as-backend"
1111
(status "accepted")
12-
(context "Need to make powerful languages accessible without steep learning curves")
13-
(decision "Use manifest-driven code generation: user describes WHAT, tool generates HOW")
14-
(consequences "Users write zero target language code; all complexity in the -iser"))
12+
(context "Need a formal verification backend that can find design bugs in API specs without requiring user expertise in formal methods")
13+
(decision "Use Alloy 6 (MIT, Daniel Jackson) — relational logic with SAT solving via Kodkod/SAT4J for bounded model checking")
14+
(consequences "Alloy is well-established, has a Java API for headless use, and can exhaustively check small scopes. Requires JVM dependency for analyzer."))
1515

16-
(adr "002-abi-ffi-standard"
16+
(adr "002-spec-to-model-pipeline"
1717
(status "accepted")
18-
(context "Need verified interop between Rust CLI, target language, and user code")
19-
(decision "Idris2 ABI for formal proofs, Zig FFI for C-ABI bridge")
20-
(consequences "Compile-time correctness guarantees; zero runtime overhead from proofs"))
18+
(context "Need to transform API specifications into Alloy models without requiring users to learn Alloy syntax")
19+
(decision "Pipeline: spec file -> parser -> SpecModel IR -> Alloy codegen -> .als files. Users declare invariants in TOML, alloyiser generates all Alloy code")
20+
(consequences "Users never write Alloy directly. Alloyiser maps OpenAPI concepts (schemas, required, refs) to Alloy concepts (sigs, facts, relations) automatically."))
2121

22-
(adr "003-rsr-template"
22+
(adr "003-iser-pattern"
2323
(status "accepted")
24-
(context "Need consistent project structure across 29+ -iser repos")
25-
(decision "All repos cloned from rsr-template-repo with full CI/CD and governance")
26-
(consequences "17 workflows, SECURITY.md, CONTRIBUTING, bot directives from day one")))
24+
(context "Need consistent architecture across the -iser family")
25+
(decision "Use manifest-driven code generation: user describes WHAT in alloyiser.toml, tool generates HOW")
26+
(consequences "Users write zero Alloy code; all complexity in alloyiser. Same pattern as chapeliser, typedqliser, etc."))
27+
28+
(adr "004-abi-ffi-standard"
29+
(status "accepted")
30+
(context "Need verified interop between Rust CLI, Alloy Analyzer (JVM), and user toolchain")
31+
(decision "Idris2 ABI for formal proofs of model soundness, Zig FFI for C-ABI bridge")
32+
(consequences "Compile-time guarantees that model extraction preserves spec semantics. JVM bridge via JNI or subprocess."))
33+
34+
(adr "005-counterexample-reports"
35+
(status "accepted")
36+
(context "Alloy Analyzer counterexamples are XML atoms — not useful to API designers")
37+
(decision "Map counterexample atoms back to original spec entities and produce human-readable violation reports with suggested fixes")
38+
(consequences "Counterexample 'Pet$0' gets reported as 'The OpenAPI spec allows creating a Pet without an owner field'. Actionable output.")))
2739

2840
(development-practices
29-
(language "Rust" (purpose "CLI and orchestration"))
30-
(language "Idris2" (purpose "ABI formal proofs"))
31-
(language "Zig" (purpose "FFI C-ABI bridge"))
41+
(language "Rust" (purpose "CLI orchestration, spec parsing, report generation"))
42+
(language "Idris2" (purpose "ABI formal proofs: model extraction soundness"))
43+
(language "Zig" (purpose "FFI C-ABI bridge to Alloy Analyzer (JVM)"))
44+
(language "Alloy" (purpose "Generated models — .als files for SAT solving"))
3245
(build-tool "cargo")
3346
(ci "GitHub Actions (17 workflows)"))
3447

3548
(design-rationale
3649
(principle "Manifest-driven"
37-
(explanation "User intent captured in TOML; all generation is deterministic and reproducible"))
38-
(principle "Formally verified bridges"
39-
(explanation "Idris2 dependent types prove interface correctness at compile time"))
40-
(principle "Zero target language exposure"
41-
(explanation "Users never write Chapel/Julia/Futhark/etc. — the -iser handles everything"))))
50+
(explanation "User intent captured in alloyiser.toml; invariants are plain-English names mapped to Alloy expressions"))
51+
(principle "Find bugs before code"
52+
(explanation "API design bugs (orphaned resources, impossible states, race conditions) are cheaper to fix at spec time than implementation time"))
53+
(principle "Formally verified extraction"
54+
(explanation "Idris2 dependent types prove that the model extraction preserves specification semantics — the generated Alloy model is faithful to the source spec"))
55+
(principle "Actionable counterexamples"
56+
(explanation "Reports map Alloy atoms back to spec entities, explain the violation in domain terms, and suggest fixes"))))

.machine_readable/6a2/NEUROSYM.a2ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
# SPDX-License-Identifier: PMPL-1.0-or-later
22
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
33
#
4-
# NEUROSYM.a2ml — Neurosymbolic integration metadata
5-
# Configuration for Hypatia scanning and symbolic reasoning.
4+
# NEUROSYM.a2ml — Neurosymbolic integration metadata for alloyiser
65

76
[metadata]
87
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
8+
last-updated = "2026-03-21"
109

1110
[hypatia-config]
1211
scan-enabled = true
1312
scan-depth = "standard" # quick | standard | deep
1413
report-format = "logtalk"
1514

1615
[symbolic-rules]
17-
# Custom symbolic rules for this project
16+
# Alloyiser-specific symbolic rules:
1817
# - { name = "no-unsafe-ffi", pattern = "believe_me|unsafeCoerce", severity = "critical" }
18+
# - { name = "no-raw-alloy-atoms-in-output", pattern = "\\$\\d+", severity = "warning" }
19+
# Counterexample atoms (Pet$0) must be mapped to spec entity names before display.
20+
# - { name = "scope-bound-check", pattern = "scope\\s*=\\s*0", severity = "error" }
21+
# Scope bound of 0 is meaningless — Alloy needs at least 1 instance per sig.
1922

2023
[neural-config]
2124
# Neural pattern detection settings
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
# SPDX-License-Identifier: PMPL-1.0-or-later
22
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
33
#
4-
# PLAYBOOK.a2ml — Operational playbook
5-
# Runbooks, incident response, deployment procedures.
4+
# PLAYBOOK.a2ml — Operational playbook for alloyiser
65

76
[metadata]
87
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
8+
last-updated = "2026-03-21"
109

1110
[deployment]
12-
# method = "gitops" # gitops | manual | ci-triggered
13-
# target = "container" # container | binary | library | wasm
11+
method = "binary" # alloyiser ships as a Rust binary; Alloy JAR is a runtime dependency
12+
target = "binary" # container | binary | library | wasm
13+
# Container deployment also available via Containerfile (includes JVM + Alloy JAR)
14+
15+
[runtime-dependencies]
16+
# Alloy Analyzer requires a JVM (Java 11+)
17+
# alloyiser invokes java -jar alloy6.jar in headless mode
18+
# Users can set ALLOY_JAR environment variable or configure in alloyiser.toml
1419

1520
[incident-response]
16-
# 1. Check .machine_readable/STATE.a2ml for current status
21+
# 1. Check .machine_readable/6a2/STATE.a2ml for current status
1722
# 2. Review recent commits and CI results
1823
# 3. Run `just validate` to check compliance
19-
# 4. Run `just security` to audit for vulnerabilities
24+
# 4. Run `just assail` to run panic-attacker pre-commit scan
25+
# 5. If Alloy codegen produces invalid .als: check src/codegen/ templates
26+
# 6. If SAT solver times out: reduce scope in alloyiser.toml
2027

2128
[release-process]
22-
# 1. Update version in STATE.a2ml, META.a2ml, Justfile
23-
# 2. Run `just release-preflight` (validate + quality + security + maint-hard-pass)
24-
# 3. Optional local permission hardening: `just perms-snapshot && just perms-lock`
29+
# 1. Update version in STATE.a2ml, META.a2ml, Cargo.toml, Justfile
30+
# 2. Run `just quality` (format + lint + test)
31+
# 3. Run `just assail` (panic-attacker pre-commit scan)
2532
# 4. Tag and push
26-
# 5. Restore local permissions if needed: `just perms-restore`
27-
# 6. Run `just container-push` if applicable
33+
# 5. Mirrors propagate to GitLab and Bitbucket automatically
2834

2935
[maintenance-operations]
30-
# Baseline audit:
31-
# just maint-audit
32-
# Hard release gate:
33-
# just maint-hard-pass
34-
# Permission audit:
35-
# just perms-audit
36+
# Baseline audit: just quality
37+
# Pre-commit scan: just assail
38+
# Container build: podman build -f Containerfile -t alloyiser .

.machine_readable/6a2/STATE.a2ml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,34 @@
55
(state
66
(metadata
77
(version "0.1.0")
8-
(last-updated "2026-03-20")
8+
(last-updated "2026-03-21")
99
(author "Jonathan D.A. Jewell"))
1010

1111
(project-context
1212
(name "alloyiser")
13-
(description "Extract formal models from API specs and verify with Alloy")
13+
(description "Extract formal models from API specs (OpenAPI/GraphQL/gRPC) and verify invariants with the Alloy Analyzer via SAT solving")
1414
(status "scaffold")
1515
(priority "—")
1616
(ecosystem "-iser family (https://github.com/hyperpolymath/iseriser)"))
1717

1818
(current-position
1919
(phase "initial-scaffold")
20-
(completion-percentage 5)
21-
(milestone "Architecture defined, CLI scaffolded, RSR template complete"))
20+
(completion-percentage 8)
21+
(milestone "CLI scaffolded, manifest parser working, ABI types specialised for Alloy model constructs, full documentation written"))
2222

2323
(route-to-mvp
24-
(step 1 "Replace codegen stubs with target-language-specific generation")
25-
(step 2 "Implement Idris2 ABI proofs for core invariants")
26-
(step 3 "Build Zig FFI bridge")
27-
(step 4 "Integration tests with real-world examples")
28-
(step 5 "Documentation and examples"))
24+
(step 1 "Phase 1: OpenAPI 3.x parser — extract entities/relations/constraints into SpecModel IR")
25+
(step 2 "Phase 2: Alloy codegen — generate .als files with sig/field/fact/assert/check constructs")
26+
(step 3 "Phase 3: Alloy Analyzer integration — run SAT solver, parse counterexamples, generate reports")
27+
(step 4 "Phase 4: Multi-format support — GraphQL, gRPC .proto, JSON Schema, AsyncAPI")
28+
(step 5 "Phase 5: Idris2 proofs — formally prove model extraction preserves spec semantics")
29+
(step 6 "Phase 6: Ecosystem — BoJ cartridge, CI/CD action, PanLL panel, VeriSimDB storage"))
2930

3031
(blockers-and-issues
3132
(none "Project is in scaffold phase — no blockers yet"))
3233

3334
(critical-next-actions
34-
(action "Implement codegen for primary use case")
35-
(action "Write first working example end-to-end")))
35+
(action "Implement OpenAPI 3.x parser in src/core/ using openapiv3 crate")
36+
(action "Define SpecModel intermediate representation (entities, relations, constraints)")
37+
(action "Write first Alloy codegen: SpecModel -> .als file with basic sigs and facts")
38+
(action "Create petstore.yaml example and verify generated .als model loads in Alloy")))

0-AI-MANIFEST.a2ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## WHAT IS THIS?
66

7-
This is the AI manifest for **[YOUR-REPO-NAME]**. It declares:
7+
This is the AI manifest for **alloyiser**. It declares:
88
- Canonical file locations (where things MUST be, and nowhere else)
99
- Critical invariants (rules that must NEVER be violated)
1010
- Repository structure and organization
@@ -86,7 +86,7 @@ Policy enforcement contracts (k9, dust, lust, must, trust).
8686
This repo follows the **Dual-Track** architecture:
8787

8888
```
89-
[YOUR-REPO-NAME]/
89+
alloyiser/
9090
├── 0-AI-MANIFEST.a2ml # THIS FILE (start here)
9191
├── README.adoc # High-level orientation (Rich Human)
9292
├── ROADMAP.adoc # Future direction

0 commit comments

Comments
 (0)