Skip to content

Commit 67eda0e

Browse files
hyperpolymathclaude
andcommitted
Bespoke documentation: Futhark GPU compilation pipeline, Idris2 ABI types, Zig FFI
Replace all template placeholders with futharkiser-specific content: - README.adoc: Futhark SOACs, GPU backends, architecture diagram, use cases - ROADMAP.adoc: 7 phases from scaffold through GPU compilation to ecosystem - Idris2 ABI: SOAC, GPUBackend, ArrayShape, MemorySpace, ParallelPattern, FutharkType, GPUBuffer, GPUBufferDescriptor layout (32 bytes, 8-byte aligned) - Zig FFI: GPU context lifecycle, buffer allocation, compilation stubs, memory transfer, backend availability query, layout compile-time assertions - Integration tests: lifecycle, backend query, buffer management, error handling - TOPOLOGY.md: data flow diagram, module map, type correspondence table - Machine-readable 6a2 files: state, meta (6 ADRs), ecosystem, agentic, neurosym, playbook - 0-AI-MANIFEST.a2ml: futharkiser-specific invariants and repository structure Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a1f88a3 commit 67eda0e

16 files changed

Lines changed: 1537 additions & 638 deletions

File tree

.machine_readable/6a2/AGENTIC.a2ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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
4+
# AGENTIC.a2ml — AI agent constraints and capabilities for futharkiser
55
# Defines what AI agents can and cannot do in this repository.
66

77
[metadata]
88
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
9+
last-updated = "2026-03-21"
1010

1111
[agent-permissions]
1212
can-edit-source = true
@@ -22,6 +22,8 @@ can-create-files = true
2222
# - Never use banned languages (TypeScript, Python, Go, etc.)
2323
# - Never place state files in repository root (must be in .machine_readable/)
2424
# - Never use AGPL license (use PMPL-1.0-or-later)
25+
# - Never modify Futhark SOAC definitions without updating both Idris2 ABI and Zig FFI
26+
# - Never change GPUBufferDescriptor layout without updating Layout.idr and main.zig simultaneously
2527

2628
[maintenance-integrity]
2729
fail-closed = true

.machine_readable/6a2/ECOSYSTEM.a2ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
(version "0.1.0")
77
(name "futharkiser")
88
(type "tool")
9-
(purpose "Compile annotated array operations to GPU kernels via Futhark")
9+
(purpose "Compile annotated array operations to GPU kernels via Futhark — identifies map/reduce/scan/scatter patterns, generates Futhark SOACs, compiles to OpenCL/CUDA/multicore GPU code")
1010

1111
(position-in-ecosystem
1212
(family "-iser acceleration frameworks")
1313
(meta-framework "iseriser")
1414
(relationship "sibling")
15+
(domain "GPU computing / array parallelism")
16+
(target-language "Futhark (by Troels Henriksen et al., DIKU Copenhagen)")
1517
(top-3 ("typedqliser" "chapeliser" "verisimiser")))
1618

1719
(related-projects
@@ -27,6 +29,9 @@
2729
(project "verisimiser"
2830
(relationship "sibling-priority-3")
2931
(description "VeriSimDB octad database augmentation"))
32+
(project "halideiser"
33+
(relationship "sibling — image processing overlap")
34+
(description "Halide image processing pipeline generation; overlaps with futharkiser for image convolutions but Halide is schedule-based while Futhark is functional"))
3035
(project "squeakwell"
3136
(relationship "sibling")
3237
(description "Database recovery via constraint propagation"))
@@ -35,4 +40,11 @@
3540
(description "Shared Idris2 verified library"))
3641
(project "typell"
3742
(relationship "dependency")
38-
(description "Type theory engine"))))
43+
(description "Type theory engine")))
44+
45+
(external-dependencies
46+
(project "futhark"
47+
(relationship "compilation-target")
48+
(url "https://futhark-lang.org")
49+
(description "Purely functional array language by DIKU Copenhagen — compiles to OpenCL/CUDA GPU kernels")
50+
(license "ISC"))))

.machine_readable/6a2/META.a2ml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,59 @@
44

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

99
(architecture-decisions
1010
(adr "001-iser-pattern"
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 to make Futhark GPU programming accessible without steep learning curves")
13+
(decision "Use manifest-driven code generation: user describes WHAT array operations to accelerate, futharkiser generates Futhark SOACs and compiles to GPU kernels")
14+
(consequences "Users write zero Futhark/CUDA/OpenCL code; all complexity in the -iser"))
1515

1616
(adr "002-abi-ffi-standard"
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 verified interop between Rust CLI, Futhark GPU kernels, and user code")
19+
(decision "Idris2 ABI for formal proofs of parallelism safety and GPU buffer layouts; Zig FFI for C-ABI bridge to Futhark runtime")
20+
(consequences "Compile-time correctness guarantees for GPU memory management; zero runtime overhead from proofs"))
2121

22-
(adr "003-rsr-template"
22+
(adr "003-futhark-soacs"
23+
(status "accepted")
24+
(context "Futhark's power comes from its second-order array combinators (SOACs)")
25+
(decision "Map source patterns to Futhark SOACs: map, reduce, scan, scatter, flatten/unflatten")
26+
(consequences "Covers the vast majority of data-parallel GPU workloads; Futhark compiler handles fusion and tiling"))
27+
28+
(adr "004-gpu-backends"
29+
(status "accepted")
30+
(context "Different users have different GPU hardware; some have no GPU at all")
31+
(decision "Support all four Futhark backends: OpenCL (widest), CUDA (NVIDIA), multicore CPU, sequential C (debug)")
32+
(consequences "futharkiser works everywhere, from headless servers to developer laptops"))
33+
34+
(adr "005-memory-space-tracking"
35+
(status "accepted")
36+
(context "GPU programming requires explicit management of host vs device memory")
37+
(decision "Track MemorySpace (Device/Host/Shared) in the ABI type system with transfer validity proofs")
38+
(consequences "Prevents invalid cross-boundary accesses at compile time; enables minimisation of host-device copies"))
39+
40+
(adr "006-rsr-template"
2341
(status "accepted")
2442
(context "Need consistent project structure across 29+ -iser repos")
2543
(decision "All repos cloned from rsr-template-repo with full CI/CD and governance")
2644
(consequences "17 workflows, SECURITY.md, CONTRIBUTING, bot directives from day one")))
2745

2846
(development-practices
2947
(language "Rust" (purpose "CLI and orchestration"))
30-
(language "Idris2" (purpose "ABI formal proofs"))
31-
(language "Zig" (purpose "FFI C-ABI bridge"))
48+
(language "Idris2" (purpose "ABI formal proofs — parallelism safety, GPU buffer layout verification"))
49+
(language "Zig" (purpose "FFI C-ABI bridge to Futhark-compiled GPU code"))
50+
(language "Futhark" (purpose "Generated target — compiled to OpenCL/CUDA GPU kernels"))
3251
(build-tool "cargo")
3352
(ci "GitHub Actions (17 workflows)"))
3453

3554
(design-rationale
3655
(principle "Manifest-driven"
37-
(explanation "User intent captured in TOML; all generation is deterministic and reproducible"))
56+
(explanation "User intent captured in futharkiser.toml; all generation is deterministic and reproducible"))
3857
(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"))))
58+
(explanation "Idris2 dependent types prove parallelism safety (associativity of reduce operators, purity of map functions, array shape compatibility) at compile time"))
59+
(principle "Zero GPU expertise required"
60+
(explanation "Users never write Futhark, CUDA, or OpenCL — futharkiser generates everything from high-level array operation annotations"))
61+
(principle "GPU buffer layout proofs"
62+
(explanation "The ABI layer includes a GPUBufferDescriptor struct layout that is verified to match between Idris2 and Zig at compile time (32 bytes, 8-byte aligned)"))))
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
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
4+
# NEUROSYM.a2ml — Neurosymbolic integration metadata for futharkiser
55
# Configuration for Hypatia scanning and symbolic reasoning.
66

77
[metadata]
88
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
9+
last-updated = "2026-03-21"
1010

1111
[hypatia-config]
1212
scan-enabled = true
1313
scan-depth = "standard" # quick | standard | deep
1414
report-format = "logtalk"
1515

1616
[symbolic-rules]
17-
# Custom symbolic rules for this project
17+
# Custom symbolic rules for futharkiser:
18+
# - Verify SOAC enum values match between Idris2 Types.idr and Zig main.zig
19+
# - Verify GPUBufferDescriptor layout (32 bytes, 8-byte aligned) in both layers
20+
# - Verify MemorySpace enum values (Device=0, Host=1, Shared=2) are consistent
1821
# - { name = "no-unsafe-ffi", pattern = "believe_me|unsafeCoerce", severity = "critical" }
22+
# - { name = "soac-consistency", pattern = "SOAC mismatch", severity = "high" }
1923

2024
[neural-config]
21-
# Neural pattern detection settings
25+
# Neural pattern detection for array-parallel code:
2226
# confidence-threshold = 0.85
2327
# model = "hypatia-v2"
28+
# detect-patterns = ["map", "reduce", "scan", "scatter", "stencil"]

.machine_readable/6a2/PLAYBOOK.a2ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
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
4+
# PLAYBOOK.a2ml — Operational playbook for futharkiser
55
# Runbooks, incident response, deployment procedures.
66

77
[metadata]
88
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
9+
last-updated = "2026-03-21"
1010

1111
[deployment]
12-
# method = "gitops" # gitops | manual | ci-triggered
13-
# target = "container" # container | binary | library | wasm
12+
method = "ci-triggered"
13+
target = "binary" # Rust CLI binary + Zig shared library
14+
# Future: container target once Futhark runtime is integrated
1415

1516
[incident-response]
16-
# 1. Check .machine_readable/STATE.a2ml for current status
17+
# 1. Check .machine_readable/6a2/STATE.a2ml for current status
1718
# 2. Review recent commits and CI results
1819
# 3. Run `just validate` to check compliance
1920
# 4. Run `just security` to audit for vulnerabilities
21+
# 5. Verify Idris2 ABI and Zig FFI are in sync (GPUBufferDescriptor layout, Result codes)
2022

2123
[release-process]
22-
# 1. Update version in STATE.a2ml, META.a2ml, Justfile
24+
# 1. Update version in STATE.a2ml, META.a2ml, Cargo.toml, main.zig VERSION constant
2325
# 2. Run `just release-preflight` (validate + quality + security + maint-hard-pass)
2426
# 3. Optional local permission hardening: `just perms-snapshot && just perms-lock`
2527
# 4. Tag and push

.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 "futharkiser")
1313
(description "Compile annotated array operations to GPU kernels via Futhark")
14-
(status "scaffold")
14+
(status "scaffold — documentation bespoked")
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 10)
21+
(milestone "Architecture defined, CLI scaffolded, RSR template complete, Idris2 ABI types bespoked (SOAC, GPUBackend, ArrayShape, MemorySpace, ParallelPattern), Zig FFI bespoked with GPU buffer management, documentation updated"))
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 "Implement pattern detection — identify map/reduce/scan/scatter in source code")
25+
(step 2 "Implement Futhark codegen — generate .fut files from detected patterns")
26+
(step 3 "Integrate Futhark compiler invocation (futhark opencl/cuda/multicore/c)")
27+
(step 4 "GPU buffer allocation and host<->device memory transfer via Zig FFI")
28+
(step 5 "Idris2 proofs of parallelism safety (associativity, purity, shape compatibility)")
29+
(step 6 "First end-to-end example: vector addition on GPU via OpenCL backend")
30+
(step 7 "Benchmarks against hand-written CUDA/OpenCL"))
2931

3032
(blockers-and-issues
3133
(none "Project is in scaffold phase — no blockers yet"))
3234

3335
(critical-next-actions
34-
(action "Implement codegen for primary use case")
35-
(action "Write first working example end-to-end")))
36+
(action "Implement source-level pattern detection for map/reduce/scan")
37+
(action "Generate first .fut Futhark program from detected patterns")
38+
(action "Invoke futhark compiler and link generated C library")))

0-AI-MANIFEST.a2ml

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
# ⚠️ STOP - CRITICAL READING REQUIRED
1+
# STOP - CRITICAL READING REQUIRED
22

33
**THIS FILE MUST BE READ FIRST BY ALL AI AGENTS**
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 **futharkiser**. 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
1111

12+
**futharkiser** compiles annotated array operations to GPU kernels via Futhark.
13+
It identifies array-parallel patterns (map, reduce, scan, scatter) in source code,
14+
generates Futhark programs using second-order array combinators (SOACs), and compiles
15+
them to OpenCL/CUDA/multicore GPU code via the Futhark compiler. The Idris2 ABI layer
16+
formally proves parallelism safety and correct GPU buffer layouts. The Zig FFI layer
17+
provides the C-ABI bridge between the host application and Futhark-compiled kernels.
18+
1219
## CANONICAL LOCATIONS (UNIVERSAL RULE)
1320

1421
### Machine-Readable Metadata: `.machine_readable/` ONLY
1522

16-
These 6 a2ml files MUST exist in `.machine_readable/` directory ONLY:
23+
These 6 a2ml files MUST exist in `.machine_readable/6a2/` directory ONLY:
1724
1. **STATE.a2ml** - Project state, progress, blockers
1825
2. **META.a2ml** - Architecture decisions, governance
1926
3. **ECOSYSTEM.a2ml** - Position in ecosystem, relationships
@@ -46,7 +53,7 @@ Do not place maintenance policy files in repository root.
4653

4754
### Bot Directives: `.machine_readable/bot_directives/` ONLY
4855

49-
Bot-specific instructions for your automated agents.
56+
Bot-specific instructions for automated agents.
5057

5158
### Contractiles: `.machine_readable/contractiles/` ONLY
5259

@@ -55,7 +62,7 @@ Policy enforcement contracts (k9, dust, lust, must, trust).
5562
### AI Configuration & Guides: `.machine_readable/ai/` ONLY
5663

5764
- `AI.a2ml` - Language-specific or LLM-specific patterns
58-
- `PLACEHOLDERS.md` - Bootstrap guide
65+
- `PLACEHOLDERS.adoc` - Bootstrap guide
5966

6067
### Community & Forge Metadata: `.github/` ONLY
6168

@@ -80,42 +87,50 @@ Policy enforcement contracts (k9, dust, lust, must, trust).
8087
6. **Container images** - MUST use Chainguard base (`cgr.dev/chainguard/wolfi-base:latest` or `cgr.dev/chainguard/static:latest`)
8188
7. **Container runtime** - Podman, never Docker. Files are `Containerfile`, never `Dockerfile`
8289
8. **Container orchestration** - `selur-compose`, never `docker-compose`
90+
9. **Futhark specifics** - SOACs are map/reduce/scan/scatter; GPU backends are OpenCL/CUDA/multicore/sequential
91+
10. **ABI/FFI contract** - Idris2 Types.idr defines the domain types (SOAC, GPUBackend, ArrayShape, MemorySpace, ParallelPattern); Zig main.zig must match these exactly
8392

8493
## REPOSITORY STRUCTURE
8594

8695
This repo follows the **Dual-Track** architecture:
8796

8897
```
89-
[YOUR-REPO-NAME]/
98+
futharkiser/
9099
├── 0-AI-MANIFEST.a2ml # THIS FILE (start here)
91100
├── README.adoc # High-level orientation (Rich Human)
92-
├── ROADMAP.adoc # Future direction
101+
├── ROADMAP.adoc # Phased roadmap (scaffold → GPU compilation → proofs)
93102
├── CONTRIBUTING.adoc # Human contribution guide
94-
├── GOVERNANCE.adoc # Decision-making model
95-
├── Justfile # Task runner
103+
├── Cargo.toml # Rust CLI build
96104
├── Containerfile # OCI build
97-
├── LICENSE # Primary license
98-
├── src/ # Source code
105+
├── LICENSE # PMPL-1.0-or-later
106+
├── src/
107+
│ ├── main.rs # CLI entry point (init, validate, generate, build, run)
108+
│ ├── lib.rs # Library API
109+
│ ├── manifest/mod.rs # futharkiser.toml parser
110+
│ ├── codegen/mod.rs # Futhark code generation from detected patterns
99111
│ └── interface/ # Verified Interface Seams
100-
│ ├── abi/ # Idris2 ABI (The Spec)
101-
│ ├── ffi/ # Zig FFI (The Bridge)
102-
│ └── generated/ # C Headers (The Result)
112+
│ ├── abi/ # Idris2 ABI (formal proofs of parallelism safety)
113+
│ │ ├── Types.idr # SOAC, GPUBackend, ArrayShape, MemorySpace, etc.
114+
│ │ ├── Layout.idr # GPU buffer descriptor layout proofs
115+
│ │ └── Foreign.idr # FFI declarations (compile, execute, alloc_buffer)
116+
│ ├── ffi/ # Zig FFI (C-ABI bridge to Futhark runtime)
117+
│ │ ├── build.zig # Build config for libfutharkiser
118+
│ │ ├── src/main.zig # FFI implementation
119+
│ │ └── test/ # Integration tests
120+
│ └── generated/ # Auto-generated C headers
103121
├── container/ # Stapeln container ecosystem
104-
├── docs/ # Technical depths
105-
│ ├── attribution/ # Citations, owners, maintainers (adoc)
106-
│ ├── architecture/ # Topology, diagrams
107-
│ ├── theory/ # Domain theory
108-
│ └── practice/ # Manuals
109-
├── docs/legal/ # Legal exhibits and full texts
122+
├── docs/ # Technical documentation
110123
└── .machine_readable/ # ALL machine-readable metadata
124+
└── 6a2/ # STATE, META, ECOSYSTEM, AGENTIC, NEUROSYM, PLAYBOOK
111125
```
112126

113127
## SESSION STARTUP CHECKLIST
114128

115-
✅ Read THIS file (0-AI-MANIFEST.a2ml) first
116-
✅ Understand canonical location: `.machine_readable/`
117-
✅ State understanding of canonical locations
129+
1. Read THIS file (0-AI-MANIFEST.a2ml) first
130+
2. Understand canonical location: `.machine_readable/`
131+
3. State understanding of canonical locations
132+
4. Read `.machine_readable/6a2/STATE.a2ml` for current project state
118133

119134
## ATTESTATION PROOF
120135

121-
**"I have read the AI manifest. All machine-readable content (state files, anchors, policies, bot directives, contractiles, AI guides) is located in `.machine_readable/` ONLY, and community metadata is in `.github/`. I will not create duplicate files in the root directory."**
136+
**"I have read the AI manifest for futharkiser. All machine-readable content (state files, anchors, policies, bot directives, contractiles, AI guides) is located in `.machine_readable/` ONLY, and community metadata is in `.github/`. I will not create duplicate files in the root directory."**

0 commit comments

Comments
 (0)