Skip to content

Commit c0c23bf

Browse files
hyperpolymathclaude
andcommitted
docs: bespoke architecture, roadmap, topology, and ABI definitions for bqniser
Replace template placeholders with BQN-specific content across all documentation and interface files: - README.adoc: BQN primitives reference, CBQN architecture, use cases - ROADMAP.adoc: Phase 0-6 plan (pattern detection, BQN codegen, CBQN integration, equivalence proofs, multi-source, ecosystem) - TOPOLOGY.md: module map, data flow, key interfaces, invariants - Types.idr: ArrayRank, BQNPrimitive, Train, Modifier1/2, UnderCombinator, BQNType value tags, Result codes with EvalError - Layout.idr: BQN array memory layout (header+shape+data), BQNValueHeader, NumericArrayLayout, CBQN array descriptor - Foreign.idr: CBQN C API declarations (eval, call1, call2, type, bound, readF64Arr, toF64, makeF64Arr, release, toCStr) - main.zig: CBQN embedding bridge with stubbed CBQN calls - build.zig: libbqniser build config with CBQN link placeholder - integration_test.zig: ABI compliance tests for all bqniser_* exports - 0-AI-MANIFEST.a2ml: bqniser-specific structure and invariants - 6a2/*.a2ml: bespoke STATE, META, ECOSYSTEM, AGENTIC, NEUROSYM, PLAYBOOK Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e582a43 commit c0c23bf

16 files changed

Lines changed: 1438 additions & 669 deletions

File tree

.machine_readable/6a2/AGENTIC.a2ml

Lines changed: 11 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 bqniser
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,15 @@ 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 emit BQN rewrites without a corresponding Idris2 equivalence proof
26+
# - Never call CBQN C API directly from Rust — always via Zig FFI bridge
27+
# - Never assume a BQN rewrite is faster without benchmarking
28+
29+
[bqniser-specific]
30+
# BQN primitive glyphs must be valid BQN (per mlochbaum.github.io/BQN/)
31+
# Pattern confidence must be high before emitting a rewrite
32+
# Array layout proofs must match CBQN's actual memory representation
33+
# CBQN version compatibility: target the bqnffi.h stable API
2534

2635
[maintenance-integrity]
2736
fail-closed = true

.machine_readable/6a2/ECOSYSTEM.a2ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
(version "0.1.0")
77
(name "bqniser")
88
(type "tool")
9-
(purpose "Detect array patterns and rewrite as optimised BQN primitives")
9+
(purpose "Detect array computation patterns in code and rewrite as optimised BQN primitives via CBQN")
1010

1111
(position-in-ecosystem
1212
(family "-iser acceleration frameworks")
1313
(meta-framework "iseriser")
1414
(relationship "sibling")
15+
(specialisation "Array language optimisation — BQN/APL family")
1516
(top-3 ("typedqliser" "chapeliser" "verisimiser")))
1617

1718
(related-projects
@@ -32,7 +33,15 @@
3233
(description "Database recovery via constraint propagation"))
3334
(project "proven"
3435
(relationship "dependency")
35-
(description "Shared Idris2 verified library"))
36+
(description "Shared Idris2 verified library — reuse proofs"))
3637
(project "typell"
3738
(relationship "dependency")
38-
(description "Type theory engine"))))
39+
(description "Type theory engine"))
40+
(project "CBQN"
41+
(relationship "external-dependency")
42+
(description "BQN runtime engine by dzaima — vectorised SIMD execution")
43+
(url "https://github.com/dzaima/CBQN"))
44+
(project "BQN"
45+
(relationship "specification")
46+
(description "BQN language specification by Marshall Lochbaum")
47+
(url "https://mlochbaum.github.io/BQN/"))))

.machine_readable/6a2/META.a2ml

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,62 @@
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 BQN array primitives accessible without learning APL syntax")
13+
(decision "Use manifest-driven code generation: user describes WHAT, tool detects patterns and generates BQN")
14+
(consequences "Users write zero BQN; all array optimisation complexity is in bqniser"))
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, CBQN runtime, and user code")
19+
(decision "Idris2 ABI for formal proofs (BQN types, array layout, rewrite equivalence), Zig FFI for CBQN C-ABI bridge")
20+
(consequences "Compile-time correctness guarantees; every rewrite has a proof; zero runtime overhead from proofs"))
2121

22-
(adr "003-rsr-template"
22+
(adr "003-cbqn-runtime"
23+
(status "accepted")
24+
(context "Need a performant BQN execution engine with C FFI")
25+
(decision "Target CBQN (dzaima/CBQN) as the BQN runtime via its bqnffi.h C API")
26+
(consequences "In-process BQN evaluation; no serialisation overhead; vectorised SIMD execution"))
27+
28+
(adr "004-pattern-conservative"
29+
(status "accepted")
30+
(context "Incorrect rewrites would produce wrong results silently")
31+
(decision "Only emit BQN rewrites when (a) pattern confidence is high AND (b) Idris2 equivalence proof exists")
32+
(consequences "False negatives preferred over false positives; users trust the output"))
33+
34+
(adr "005-leading-axis-theory"
35+
(status "accepted")
36+
(context "BQN primitives generalise across array ranks via leading-axis theory")
37+
(decision "BQNiser leverages rank polymorphism: a single rewrite handles scalars, lists, tables, and higher-rank arrays")
38+
(consequences "Fewer pattern rules needed; rewrites are more general than dimension-specific alternatives"))
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
29-
(language "Rust" (purpose "CLI and orchestration"))
30-
(language "Idris2" (purpose "ABI formal proofs"))
31-
(language "Zig" (purpose "FFI C-ABI bridge"))
32-
(build-tool "cargo")
47+
(language "Rust" (purpose "CLI, manifest parsing, pattern detection, orchestration"))
48+
(language "BQN" (purpose "Target language for generated array expressions"))
49+
(language "Idris2" (purpose "ABI formal proofs: types, layout, equivalence"))
50+
(language "Zig" (purpose "FFI C-ABI bridge to CBQN runtime"))
51+
(build-tool "cargo" (purpose "Rust CLI"))
52+
(build-tool "zig build" (purpose "FFI bridge"))
3353
(ci "GitHub Actions (17 workflows)"))
3454

3555
(design-rationale
3656
(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"))))
57+
(explanation "User intent captured in bqniser.toml; pattern detection is automatic; generation is deterministic"))
58+
(principle "Formally verified rewrites"
59+
(explanation "Idris2 dependent types prove each BQN rewrite preserves input-output equivalence"))
60+
(principle "Rank-polymorphic by default"
61+
(explanation "BQN's leading-axis theory means primitives generalise across dimensions automatically"))
62+
(principle "Conservative rewriting"
63+
(explanation "Only rewrite when confidence is high and equivalence proof exists; never silently produce wrong results"))
64+
(principle "In-process execution"
65+
(explanation "CBQN runs in-process via Zig FFI; no IPC, no serialisation, no subprocess overhead"))))
Lines changed: 10 additions & 5 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 bqniser
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
18-
# - { name = "no-unsafe-ffi", pattern = "believe_me|unsafeCoerce", severity = "critical" }
17+
# BQNiser-specific symbolic rules for Hypatia
18+
# - Array rewrite equivalence: source pattern must produce identical output to BQN expression
19+
# - Rank compatibility: detected array rank must be compatible with target BQN primitive
20+
# - Under invertibility: G in F⌾G must have a computational inverse for the domain
21+
# - CBQN FFI safety: all value handles must be released after use
1922

2023
[neural-config]
21-
# Neural pattern detection settings
24+
# Pattern detection could benefit from neural hints:
25+
# - Classify loop bodies as "array-like" vs "stateful" (only array-like are rewritable)
26+
# - Estimate speedup likelihood before committing to a rewrite
2227
# confidence-threshold = 0.85
2328
# model = "hypatia-v2"
Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
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 bqniser
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 = "binary" # Binary CLI tool distributed via crates.io
13+
target = "binary" # cargo install bqniser
14+
# Also: container image for CI/CD use (Chainguard base)
15+
16+
[dependencies]
17+
# External runtime dependency: CBQN must be installed
18+
# - Fedora: dnf install cbqn (if packaged) or build from source
19+
# - Build: git clone https://github.com/dzaima/CBQN && make
20+
# - The Zig FFI bridge links against libcbqn at build time
1421

1522
[incident-response]
16-
# 1. Check .machine_readable/STATE.a2ml for current status
23+
# 1. Check .machine_readable/6a2/STATE.a2ml for current status
1724
# 2. Review recent commits and CI results
18-
# 3. Run `just validate` to check compliance
25+
# 3. Run `just validate` to check RSR compliance
1926
# 4. Run `just security` to audit for vulnerabilities
27+
# 5. If BQN rewrite produces wrong output: check Idris2 equivalence proof
2028

2129
[release-process]
22-
# 1. Update version in STATE.a2ml, META.a2ml, Justfile
30+
# 1. Update version in STATE.a2ml, META.a2ml, Cargo.toml, Zig build
2331
# 2. Run `just release-preflight` (validate + quality + security + maint-hard-pass)
24-
# 3. Optional local permission hardening: `just perms-snapshot && just perms-lock`
32+
# 3. Run `cargo test` and `cd src/interface/ffi && zig build test`
2533
# 4. Tag and push
26-
# 5. Restore local permissions if needed: `just perms-restore`
27-
# 6. Run `just container-push` if applicable
34+
# 5. Run `just container-push` if applicable
2835

2936
[maintenance-operations]
3037
# Baseline audit:
3138
# just maint-audit
3239
# Hard release gate:
3340
# just maint-hard-pass
34-
# Permission audit:
35-
# just perms-audit
41+
# BQN-specific checks:
42+
# Verify CBQN version compatibility
43+
# Run benchmark suite to detect regressions

.machine_readable/6a2/STATE.a2ml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,35 @@
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 "bqniser")
13-
(description "Detect array patterns and rewrite as optimised BQN primitives")
14-
(status "scaffold")
13+
(description "Detect array computation patterns in code and rewrite as optimised BQN primitives")
14+
(target-language "BQN (via CBQN runtime)")
15+
(status "scaffold — architecture defined, ABI types bespoke, codegen pending")
1516
(priority "—")
1617
(ecosystem "-iser family (https://github.com/hyperpolymath/iseriser)"))
1718

1819
(current-position
19-
(phase "initial-scaffold")
20-
(completion-percentage 5)
21-
(milestone "Architecture defined, CLI scaffolded, RSR template complete"))
20+
(phase "scaffold-with-bespoke-abi")
21+
(completion-percentage 10)
22+
(milestone "Bespoke Idris2 ABI types (ArrayRank, BQNPrimitive, Train, Modifier, UnderCombinator), Zig FFI bridge stubs for CBQN C API, CLI scaffolded"))
2223

2324
(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"))
25+
(step 1 "Pattern detection engine: AST analysis of Rust source for array patterns")
26+
(step 2 "BQN codegen: emit BQN expressions using trains, under, modifiers")
27+
(step 3 "CBQN integration: link Zig FFI bridge to libcbqn for in-process eval")
28+
(step 4 "Idris2 equivalence proofs: prove each rewrite preserves semantics")
29+
(step 5 "Numeric array round-trip: Rust Vec<f64> → BQN array → Rust Vec<f64>")
30+
(step 6 "End-to-end example: detect loop, rewrite as BQN, benchmark speedup"))
2931

3032
(blockers-and-issues
31-
(none "Project is in scaffold phase — no blockers yet"))
33+
(blocker "CBQN not yet linked as system library in Zig build")
34+
(note "All FFI functions are correctly stubbed and return safe defaults"))
3235

3336
(critical-next-actions
34-
(action "Implement codegen for primary use case")
35-
(action "Write first working example end-to-end")))
37+
(action "Implement pattern detection for common loop/map/fold patterns")
38+
(action "Link CBQN runtime in Zig FFI build (lib.linkSystemLibrary(\"cbqn\"))")
39+
(action "Write first BQN codegen pass: simple fold → ´ rewrite")))

0 commit comments

Comments
 (0)