Commit graph

12 commits

Author SHA1 Message Date
Scott Scoble
c3ade18feb fix(parser): parse parenthetical type syntax Map(K,V), Set(T), List(T)
parseTypeExpr only handled angle-bracket generics (Map<K,V>, Set<T>, List<T>)
but SpeckDL canonical syntax uses parentheses: Map(Nat, Account), Set(Nat), List(LogEntry).

This caused two bugs:
1. State property types emitted as raw strings (accounts: Map(Nat, Account))
2. Parametric types treated as enum interface names (TigerBeetleLedgerMap(Nat, Account))

Added List(T), Set(T), Map(K,V) handlers alongside existing angle-bracket handlers.
All 41/41 tests passing. TigerBeetle now generates clean TS types:
- accounts: Map<number, Account> (was Map(Nat, Account))
- pending: Set<number> (was Set(Nat))
- log: LogEntry[] (was List(LogEntry))
2026-05-09 18:09:31 -07:00
Scott Scoble
e92f430fb3 fix(compiler): translate 5 SpeckDL expression patterns to JavaScript
- notIn -> !map.has(key): 't.id notIn transfers.keys' -> '!transfers.has(t.id)'
- old(expr) -> drop wrapper: specification construct, no JS equivalent
- union -> Set spread: 'pending union {t.id}' -> 'new Set([...pending, t.id])'
- \ -> Set difference via filter: 'pending \ {id}' -> 'new Set([...pending].filter(x => x !== id))'
- Trailing == at end-of-string -> ===, then clean up empty RHS comparisons

All 41 tests passing. TigerBeetle: 0 notIn, 0 old(, 0 union, 0 \, 0 ==)
2026-05-09 16:08:46 -07:00
Scott Scoble
9de0a5ca0f feat(compiler): parse precondition/postcondition in action blocks
- Add 'precondition' and 'postcondition' ActionStatement types
- Parse precondition: expr and postcondition: expr in action bodies
- Support 'or' continuation lines for multi-clause pre/postconditions
- TigerBeetleLedger now parses 21 preconditions + 24 postconditions
  (previously all dropped, resulting in empty action bodies)
- All 41 existing tests pass

Addresses marcus/engineering#9 (parser gap)
Does NOT wire into generators yet — TypeScript/WASM output
will be empty for pre/postconditions. Generator wiring
is follow-up work.
2026-05-09 09:12:15 -07:00
Scott Scoble
acb464f957 fix(wasm): remove spurious i32.const from uncompiled assignment placeholders
Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 4s
Undcompiled map/record/unrecognized assignments emitted (i32.const 1)
placeholders that left values on the WASM stack. Combined with
the default return i32.const 1 at end of function, this caused
type mismatch errors (expected [], got [i32, i32] or [i32]).

Fix: make uncompiled assignments emit comment-only output with
no stack effect. Scalar assignments already work correctly since
emitExpr feeds into global.set which consumes the value.

Closes #9 WASM E2E portion — parser fix for precondition:/postcondition:
keyword handling still needed.
2026-05-06 05:14:33 -07:00
Scott Scoble
a2f7b7b2e9 fix: add dist-check guard + List<T> type parsing + state machine examples
Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 2s
- check-dist.sh: Prevents DIST DESYNC by verifying all dist/*.js files
  are newer than their src/*.ts sources. Fails build if stale.
- Makefile: Standard build targets (build/check-dist/test/recompile/clean)
- src/index.ts: Integrated dist freshness check before compilation
- src/parser.ts: Added List<T> type parsing alongside existing Set<T>/Map<K,V>
  (e.g., 'log: List<LogEntry>' now parses as { type: 'list', elementType })
- examples/: Restored v0.3 state machine specs (TigerBeetleLedger,
  AccountLedger, ToggleSwitch, TwoPhaseCommit)
- DIST DESYNC is a known recurring anti-pattern — this guard prevents it

Tests: 39/41 pass (2 pre-existing E2E WASM failures due to missing wabt)
2026-05-05 03:11:53 -07:00
Scott Scoble
7230650628 feat(compiler): self-hosting spec + generator multi-enum support
Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 2s
- Add speckl-compile.speckdl — compiler formally specified in SpeckDL
- Generator: multi-enum detection, value→enum mapping, trailing comma cleanup
- Emit blocks collapsed to single-line (parser limitation)
- Generated artifacts: provenance, BOMs, WAT, TypeScript (2 known bugs → engineering#8)
2026-05-03 14:42:03 -07:00
Scott Scoble
39436b4382 WASM E2E test: Speckl specs compile to runnable WebAssembly
Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 3s
- Add __tests__/e2e-wasm.test.ts: full pipeline test
  - Parse Counter speck → generate WAT → assemble with wabt → instantiate → run
  - Verify init, action calls, guard pass/fail, state mutations
  - TigerBeetle WAT validation test (wabt parse + validate + toBinary)
- Fix wasm.ts bugs found by E2E:
  - Guard condition inverted: added i32.eqz to negate comparison
  - Missing local declarations: locals now inserted before body
  - Uncompiled guards left stack values: now emit comments only (no i32.const 1)
- Install wabt npm package for WAT→WASM assembly in tests
- 41/41 tests passing (39 original + 2 E2E)

Milestone: Speckl produces runnable WebAssembly from specs.
2026-05-03 13:13:55 -07:00
Scott Scoble
7ffd65f6b3 speckl: TypeScript state machine generator + Forgejo issue workflow spec
Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 2s
Adds a first-class TypeScript code generator to speckl-compile that emits:
- Const enum for workflow states (IssueWorkflowState)
- Strongly-typed class with guards, state transitions, decision log
- Proper this. prefixing (state vars only, not local params)
- Enum references instead of string literals for state comparisons
- Clean tsc --noEmit compilation

Also includes:
- specs/forgejo-issue-workflow.speckdl — full workflow with 9 actions,
  8 constraints, 5 temporal verifications
- Generator deduplication of duplicate AST nodes
- Support for init block initialization of state variables

The generator was validated against the Forgejo issue workflow spec,
producing IssueWorkflow.ts that compiles with zero errors.

Refs: heartbeat conversation re: speckl-compile extensibility
2026-05-03 12:23:33 -07:00
Scott Scoble
cbee677a11 fix: support hyphenated speck names + provenance block parsing (v0.3.1)
Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 2s
- Fixed speck name regex to allow hyphens (\w → [\w-])
- Added provenance { } block handling in parseMember()
- Updated hyphenated name test from 'My' to 'My-Service-Handler'
- All 48 tests passing (27 parser + 21 validator)
2026-05-02 23:12:27 -07:00
Scott Scoble
8facd5c6c7 Wire up compiler generators + fix parser for SpeckDL edge cases
Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 3s
- Connected PROV-O, CycloneDX, and SPDX generators to CLI entry point
- Fixed parseAuthor regex to handle angle-bracket email format
- Fixed parseDerives to handle hyphenated names and quoted rationale
- Fixed parseSatisfies to handle hyphenated requirement IDs
- Fixed parseSource to handle ref keyword with quoted value
- Added graceful fallbacks (warn instead of throw) for parse errors
- All 5 example .speck files compile and validate successfully
2026-05-02 15:14:31 -07:00
Scott Scoble
1f5ee67404 Add .gitignore for compiler dependencies and build artifacts 2026-04-29 15:12:37 -07:00
Scott Scoble
f19a43fd5f Add SpeckDL compiler scaffold
- CLI entry point with yargs parsing for speckl-compile <file> --output-dir --bom-format
- TypeScript parser with AST types for all SpeckDL primitives
- Generator for PROV-O JSON-LD provenance graphs
- Generator for CycloneDX v1.6 BOMs
- Generator for SPDX 3.0.1 BOMs
- E2E test verifying RetryHandler.speck parsing and all output formats

All tests pass.
2026-04-29 15:12:08 -07:00