This document provides context for AI assistants working with the aggregate-library codebase.
aggregate-library (aLib) is a methods/research repository demonstrating how to build a minimal "overlap" library across diverse programming systems. It serves as a proof-of-concept for spec-driven, conformance-tested library development.
- A methods demonstration for cross-system library overlap
- A stress-test for specification clarity and conformance testing
- A reference implementation in AffineScript showing the methodology
- NOT a replacement for ecosystem standard libraries
- NOT a proposal that all languages share one stdlib
- NOT a dependency to import - implementations borrow the method, not the code
-
Specification First: Define minimal overlap as formal specs
- Interface signatures
- Behavioral semantics with properties
- Executable test cases in YAML
-
Conformance Testing: Validate implementations against specs
- Parse test cases from spec files
- Run against implementations
- Report conformance
-
Reversibility: Changes must be easy to evaluate and undo
- Clear spec boundaries
- Comprehensive test coverage
- No hidden dependencies
-
Ecosystem Neutrality: No "blessed" implementation
- Method applies to any language
- AffineScript is a reference, not a requirement
aggregate-library/
├── specs/ # Specification files (22 operations)
│ ├── arithmetic/ # add, subtract, multiply, divide, modulo
│ ├── comparison/ # equal, not_equal, less_than, etc.
│ ├── logical/ # and, or, not
│ ├── collection/ # map, filter, fold, contains
│ ├── string/ # concat, length, substring
│ └── conditional/ # if_then_else
├── src/
│ ├── ALib.mres # Complete AffineScript implementation
│ ├── InterOp/ # JavaScript interop utilities
│ └── schema/ # Nickel schema definitions
├── scripts/
│ ├── validate-specs.ts # Spec format validator (Deno)
│ └── run-conformance-tests.ts # Conformance test runner (Deno)
├── test/ # Implementation tests
├── deno.json # Deno configuration
└── Justfile # Command runner
Per hyperpolymath language policy:
Allowed:
- ✅ AffineScript: Primary implementation language (compiles to JS)
- ✅ Deno: Test runner and validation scripts (NOT Node/npm/bun)
- ✅ Nickel: Configuration language for schemas
- ✅ Rust, Gleam, Elixir: Optional alternative implementations
Banned:
- ❌ TypeScript (use AffineScript instead)
- ❌ Node.js, npm, Bun (use Deno instead)
- ❌ Python, Go (use Rust/Gleam/Elixir instead)
# 1. Create specification file
# specs/<category>/<operation>.md with:
# - Interface Signature
# - Behavioral Semantics (properties, edge cases)
# - Executable Test Cases (YAML)
# 2. Implement in AffineScript
# Add to src/ALib.mres in appropriate module
# 3. Validate specification format
deno task validate:specs
# 4. Run conformance tests
deno task test
# 5. Update documentation
# Update README.adoc with new operation# Validate all specs
just validate
# Run conformance tests
deno task test
# Check everything
just checkTo create an implementation in another language:
- Read the spec files in
specs/ - Implement the operations matching the interface signatures
- Extract test cases from the YAML blocks
- Run your implementation against the test cases
- Report conformance results
Each spec file must have these sections:
# Operation: operation_name
## Interface Signature
\`\`\`
operation_name: Type1, Type2 -> ResultType
\`\`\`
## Behavioral Semantics
**Purpose**: Brief description
**Parameters**:
- param1: Description
- param2: Description
**Return Value**: Description
**Properties**:
- Mathematical/logical properties (commutative, associative, etc.)
**Edge Cases**:
- Overflow, underflow, division by zero, etc.
## Executable Test Cases
\`\`\`yaml
test_cases:
- input: [arg1, arg2]
output: expected_result
description: "Test description"
\`\`\`The AffineScript implementation is organized into modules:
- Arithmetic: add, subtract, multiply, divide, modulo
- Comparison: equal, notEqual, lessThan, lessEqual, greaterThan, greaterEqual
- Logical: and_, or_, not_
- Collection: map, filter, fold, contains
- String: concat, length, substring
- Conditional: ifThenElse
All operations are pure functions with no side effects.
- Format conformance (required sections)
- YAML syntax validation
- Test case structure validation
- Load test cases from specs
- Execute against implementation
- Compare results
- Report pass/fail
- Verify mathematical properties (commutativity, associativity, etc.)
- Test edge cases
- Validate invariants
# Install dependencies (none needed for specs)
# AffineScript compilation requires affinescript package
# Validate specifications
deno task validate:specs
# Run conformance tests
deno task test
# Check all validations
just validate
# Format Deno code
deno fmt
# Lint Deno code
deno lint- Minimal Surface: Only include operations with broad overlap
- Explicit Semantics: All behavior documented and tested
- Conformance First: Tests drive implementation
- Ecosystem Respect: Don't replace, demonstrate method
- Reversibility: Easy to adopt, easy to abandon
When working with this repository:
- Spec Changes: Always update tests when changing specs
- Implementation: Follow AffineScript idioms, use pure functions
- Testing: Validate before committing
- Documentation: Keep specs, code, and docs in sync
- License: New files use MPL-2.0 (code) / CC-BY-SA-4.0 (docs). Per the 2026-06-02 estate policy, PMPL-1.0-or-later is reserved for
palimpsest-license,palimpsest-plasma, andconsent-aware-httponly — aLib is a sole-owner repo, so MPL-2.0/CC-BY-SA-4.0. (Existing headers are not swept; flag drift, do not bulk-edit.) - Author: Jonathan D.A. Jewell j.d.a.jewell@open.ac.uk
proven- Formal verification reference (Idris2)alib-for-affinescript- Ecosystem-specific proving groundrsr-template-repo- Repository structure templatehypatia- Security scanninggitbot-fleet- Quality enforcement
- Spec Format: See any file in
specs/for examples - AffineScript Docs: https://affinescript-lang.org/
- Deno Docs: https://deno.com/
- Nickel Docs: https://nickel-lang.org/
Last updated: 2026-01-31